zrhoffman commented on code in PR #7764:
URL: https://github.com/apache/trafficcontrol/pull/7764#discussion_r1316168351
##########
traffic_ops/app/db/seeds.sql:
##########
@@ -97,6 +103,23 @@ FROM public.role
WHERE "name" in ('operations', 'read-only', 'portal', 'federation', 'steering')
ON CONFLICT DO NOTHING;
+INSERT INTO public.role_capability
+SELECT id, perm FROM public.role
+CROSS JOIN (
+ VALUES ('DNS-SEC:READ'), ('DNS-SEC:DELETE')
+) AS perms(perm)
+WHERE "priv_level" < 20 AND "priv_level" > 8
+ ON CONFLICT DO NOTHING;
Review Comment:
> I increased the check from 0 to 8.. not sure if that is the right way but
hopefully it helps.
Additional perms are no longer granted to portal (`6`), but this still
grants `DNS-SEC:READ` and `DNS-SEC:DELETE` to a bunch of roles that did not
have it before: trouter (`1`), read-only (`4`), steering (`7`), and federation
(`8`):
```diff
--- apache.sql 2023-09-05 11:04:30.851468321 -0600
+++ 7764.sql 2023-09-05 11:05:02.572109742 -0600
@@ -3024,6 +3024,14 @@
6 DELIVERY-SERVICE-SAFE:UPDATE A_TIMESTAMP
7 DELIVERY-SERVICE-SAFE:UPDATE A_TIMESTAMP
8 DELIVERY-SERVICE-SAFE:UPDATE A_TIMESTAMP
+1 DNS-SEC:DELETE A_TIMESTAMP
+4 DNS-SEC:READ A_TIMESTAMP
+4 DNS-SEC:DELETE A_TIMESTAMP
+7 DNS-SEC:READ A_TIMESTAMP
+7 DNS-SEC:DELETE A_TIMESTAMP
+8 DNS-SEC:READ A_TIMESTAMP
+8 DNS-SEC:DELETE A_TIMESTAMP
+1 DELIVERY-SERVICE-SAFE:UPDATE A_TIMESTAMP
3 ACME:READ A_TIMESTAMP
4 ACME:READ A_TIMESTAMP
6 ACME:READ A_TIMESTAMP
```
Previous convo:
https://github.com/apache/trafficcontrol/pull/7764#discussion_r1312398427
##########
traffic_ops/app/db/migrations/2022050916074300_add_reserved_statuses.up.sql:
##########
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
under
- * the License.
- */
-
-INSERT INTO public.status ("name", description) VALUES ('ONLINE', 'Server is
online.') ON CONFLICT ("name") DO NOTHING;
-INSERT INTO public.status ("name", description) VALUES ('OFFLINE', 'Server is
Offline. Not active in any configuration.') ON CONFLICT ("name") DO NOTHING;
-INSERT INTO public.status ("name", description) VALUES ('REPORTED', 'Server is
online and reported in the health protocol.') ON CONFLICT ("name") DO NOTHING;
-INSERT INTO public.status ("name", description) VALUES ('ADMIN_DOWN', 'Sever
is administrative down and does not receive traffic.') ON CONFLICT ("name") DO
NOTHING;
-INSERT INTO public.status ("name", description) VALUES ('PRE_PROD', 'Pre
Production. Not active in any configuration.') ON CONFLICT ("name") DO NOTHING;
Review Comment:
After this migration is removed and the statuses are created only from
`seeds.sql`, they are created in a different order than they were previously:
```diff
--- apache.sql 2023-09-05 11:04:30.851468321 -0600
+++ 7764.sql 2023-09-05 11:05:02.572109742 -0600
@@ -3449,12 +3457,12 @@
--
COPY public.status (id, name, description, last_updated) FROM stdin;
-1 ONLINE Server is online. A_TIMESTAMP
-2 OFFLINE Server is Offline. Not active in any configuration.
A_TIMESTAMP
+1 OFFLINE Server is Offline. Not active in any configuration.
A_TIMESTAMP
+2 ONLINE Server is online. A_TIMESTAMP
3 REPORTED Server is online and reported in the health protocol.
A_TIMESTAMP
4 ADMIN_DOWN Sever is administrative down and does not receive
traffic. A_TIMESTAMP
-5 PRE_PROD Pre Production. Not active in any configuration.
A_TIMESTAMP
-10 CCR_IGNORE Server is ignored by traffic router. A_TIMESTAMP
+5 CCR_IGNORE Server is ignored by traffic router. A_TIMESTAMP
+6 PRE_PROD Pre Production. Not active in any configuration.
A_TIMESTAMP
\.
```
I am fine with a different order, but the T3C integration tests still
[fail](https://github.com/apache/trafficcontrol/actions/runs/6044075807/job/16402166989?pr=7764),
claiming none of these statuses exist:
```go
--- FAIL: TestT3cActionLog (3.22s)
servers.go:33: Received unexpected error: no Status named REPORTED
Messages: Could not create server 'atlanta-edge-01': no Status named REPORTED -
alerts: []
```
##########
traffic_ops/app/db/seeds.sql:
##########
@@ -97,6 +103,23 @@ FROM public.role
WHERE "name" in ('operations', 'read-only', 'portal', 'federation', 'steering')
ON CONFLICT DO NOTHING;
+INSERT INTO public.role_capability
+SELECT id, perm FROM public.role
+CROSS JOIN (
+ VALUES ('DNS-SEC:READ'), ('DNS-SEC:DELETE')
+) AS perms(perm)
+WHERE "priv_level" < 20 AND "priv_level" > 8
+ ON CONFLICT DO NOTHING;
+
+INSERT INTO public.role_capability (role_id, cap_name)
+SELECT id, perm
+FROM public.role
+CROSS JOIN (
+ VALUES ('DELIVERY-SERVICE-SAFE:UPDATE')
+) AS perms(perm)
+WHERE "priv_level" < 20 AND "priv_level" > 2
+ ON CONFLICT DO NOTHING;
Review Comment:
This still grants `DELIVERY-SERVICE-SAFE:UPDATE` to the `trouter` user, but
`trouter` should not have `DELIVERY-SERVICE-SAFE:UPDATE` (see
`DELIVERY-SERVICE-SAFE:UPDATE` in the diff above).
Previous discussion:
https://github.com/apache/trafficcontrol/pull/7764#discussion_r1312398811
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]