Skip to content

Commit e67f95f

Browse files
committed
docs(observability-proxy): explain why both application roots need the namespace root
The reason given for the second access review held only for the metrics root. The log root needs it too, because an ownerless pod keeps the lineage labels its creator set and can claim any application. The tenant ClusterRole comment also named only the namespace roots, though the application roots now depend on the same rule. Assisted-by: LLM Signed-off-by: ZverGuy <[email protected]>
1 parent 16cee4d commit e67f95f

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

‎internal/observabilityproxy/route.go‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,14 @@ func ParseRoute(escapedPath string) (Route, *HTTPError) {
132132
}
133133

134134
// Reviews lists every access a request on the route needs. An application
135-
// root also needs read access to its namespace root: its pod and PVC
136-
// branches match by name across the window, so a name another application
137-
// held earlier reaches that application's series, and a grant narrowed by
138-
// resourceNames would read more than it names.
135+
// root also needs read access to its namespace root, because its scope
136+
// narrows within the namespace but does not isolate: on both roots the
137+
// identity comes from lineage labels that the lineage webhook keeps as set
138+
// on an object it finds no owner for, so anyone who can create a pod there
139+
// can label it as the application; on the metrics root the pod and PVC
140+
// branches also match by name across the window, so a name another
141+
// application held earlier reaches that application's series. A grant
142+
// narrowed by resourceNames would read more than it names.
139143
func (r Route) Reviews() []authorizationv1.ResourceAttributes {
140144
switch r.Kind {
141145
case ApplicationLog:

‎internal/observabilityproxy/server_app_test.go‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,10 @@ func TestServerApplicationMetricsBranches(t *testing.T) {
282282

283283
// A grant narrowed to application "a" by resourceNames must not reach "b"
284284
// through any endpoint of either root. Without read access to the
285-
// namespace roots it does not reach "a" either: the pod and PVC branches
286-
// match by name, and a name another application used earlier in the
287-
// window would pull its series in.
285+
// namespace roots it does not reach "a" either: an ownerless pod keeps the
286+
// lineage labels its creator set, so it can claim to be "a" on both roots,
287+
// and on the metrics root the pod and PVC branches match by name, so a name
288+
// another application used earlier in the window would pull its series in.
288289
func TestServerApplicationNarrowedGrant(t *testing.T) {
289290
h := newPolicyHarness(t, Config{}, appMetricsUpstream([]string{"a-0"}, nil, http.StatusOK), appPolicy, nil)
290291
paths := []string{

‎packages/system/observability-proxy/templates/tenant-clusterroles.yaml‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Aggregated into cozy-tenant-view (and consequently use, admin, super-admin).
22
# No API server serves cozystack.io logs or metrics: the rule exists only for
33
# the SubjectAccessReview the observability proxy asks before it answers a
4-
# read under /apis/cozystack.io/v1alpha1/namespaces/<ns>/{logs,metrics}/.
4+
# read under /apis/cozystack.io/v1alpha1/namespaces/<ns>/{logs,metrics}/,
5+
# and before a read under an application root,
6+
# /apis/apps.cozystack.io/v1alpha1/namespaces/<ns>/<plural>/<name>/{log,metrics}/,
7+
# which needs the namespace root too. Narrowing this role also cuts off the
8+
# application roots.
59
apiVersion: rbac.authorization.k8s.io/v1
610
kind: ClusterRole
711
metadata:

0 commit comments

Comments
 (0)