Skip to content

Commit 9aa8d62

Browse files
committed
fix: link populated name in activity summaries for generateName creates
Activity summary templates linked audit.objectRef.name, which is empty for resources created with generateName (the assigned name lives in responseObject.metadata.name). Reading audit.objectRef.name errored with "no such key: name", so the activity was never produced and the create was silently missing from the user's activity feed. Confirmed in production for Connector and Domain. Link the populated name and scope each affected rule so the field is guaranteed present, matching the existing has()-guarded match style used by the delete rules. Key changes: - Connector, ConnectorAdvertisement, TrafficProtectionPolicy, BackendTLSPolicy, Gateway: create/update summaries link responseObject.metadata.name; their match conditions gain has(audit.responseObject.metadata.name) so the field is always present (events without it fall through to the existing create/update fallback) - Domain: guard the requestObject.spec and spec.domainName path segments before linking the domain name Claude-Session: https://claude.ai/code/session_01KnYuL5Pf1R5ysZoxxNkKiu
1 parent b1eded2 commit 9aa8d62

6 files changed

Lines changed: 22 additions & 22 deletions

File tree

config/milo/activity/policies/backendtlspolicy-policy.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ spec:
1616
auditRules:
1717
# BackendTLSPolicy creation with spec available
1818
- name: create
19-
match: "!audit.user.username.startsWith('system:') && audit.verb == 'create' && has(audit.requestObject.spec)"
20-
summary: "{{ actor }} created backend TLS policy {{ link(audit.objectRef.name, audit.objectRef) }}"
19+
match: "!audit.user.username.startsWith('system:') && audit.verb == 'create' && has(audit.requestObject.spec) && has(audit.responseObject.metadata.name)"
20+
summary: "{{ actor }} created backend TLS policy {{ link(audit.responseObject.metadata.name, audit.objectRef) }}"
2121

2222
# BackendTLSPolicy creation fallback (no spec)
2323
- name: create-fallback
@@ -36,8 +36,8 @@ spec:
3636

3737
# BackendTLSPolicy update with spec available - excludes status subresource
3838
- name: update
39-
match: "!audit.user.username.startsWith('system:') && audit.verb in ['update', 'patch'] && !has(audit.objectRef.subresource) && has(audit.requestObject.spec)"
40-
summary: "{{ actor }} updated backend TLS policy {{ link(audit.objectRef.name, audit.objectRef) }}"
39+
match: "!audit.user.username.startsWith('system:') && audit.verb in ['update', 'patch'] && !has(audit.objectRef.subresource) && has(audit.requestObject.spec) && has(audit.responseObject.metadata.name)"
40+
summary: "{{ actor }} updated backend TLS policy {{ link(audit.responseObject.metadata.name, audit.objectRef) }}"
4141

4242
# BackendTLSPolicy update fallback (no spec)
4343
- name: update-fallback

config/milo/activity/policies/connector-policy.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ spec:
1616
auditRules:
1717
# Connector creation with spec available
1818
- name: create
19-
match: "!audit.user.username.startsWith('system:') && audit.verb == 'create' && has(audit.requestObject.spec)"
20-
summary: "{{ actor }} created connector {{ link(audit.objectRef.name, audit.objectRef) }}"
19+
match: "!audit.user.username.startsWith('system:') && audit.verb == 'create' && has(audit.requestObject.spec) && has(audit.responseObject.metadata.name)"
20+
summary: "{{ actor }} created connector {{ link(audit.responseObject.metadata.name, audit.objectRef) }}"
2121

2222
# Connector creation fallback (no spec)
2323
- name: create-fallback
@@ -36,8 +36,8 @@ spec:
3636

3737
# Connector update with spec available - excludes status subresource
3838
- name: update
39-
match: "!audit.user.username.startsWith('system:') && audit.verb in ['update', 'patch'] && !has(audit.objectRef.subresource) && has(audit.requestObject.spec)"
40-
summary: "{{ actor }} updated connector {{ link(audit.objectRef.name, audit.objectRef) }}"
39+
match: "!audit.user.username.startsWith('system:') && audit.verb in ['update', 'patch'] && !has(audit.objectRef.subresource) && has(audit.requestObject.spec) && has(audit.responseObject.metadata.name)"
40+
summary: "{{ actor }} updated connector {{ link(audit.responseObject.metadata.name, audit.objectRef) }}"
4141

4242
# Connector update fallback (no spec)
4343
- name: update-fallback

config/milo/activity/policies/connectoradvertisement-policy.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ spec:
1717
auditRules:
1818
# ConnectorAdvertisement creation with spec available
1919
- name: create
20-
match: "!audit.user.username.startsWith('system:') && audit.verb == 'create' && has(audit.requestObject.spec)"
21-
summary: "{{ actor }} created connector advertisement {{ link(audit.objectRef.name, audit.objectRef) }}"
20+
match: "!audit.user.username.startsWith('system:') && audit.verb == 'create' && has(audit.requestObject.spec) && has(audit.responseObject.metadata.name)"
21+
summary: "{{ actor }} created connector advertisement {{ link(audit.responseObject.metadata.name, audit.objectRef) }}"
2222

2323
# ConnectorAdvertisement creation fallback (no spec)
2424
- name: create-fallback
@@ -37,8 +37,8 @@ spec:
3737

3838
# ConnectorAdvertisement update with spec available - excludes status subresource
3939
- name: update
40-
match: "!audit.user.username.startsWith('system:') && audit.verb in ['update', 'patch'] && !has(audit.objectRef.subresource) && has(audit.requestObject.spec)"
41-
summary: "{{ actor }} updated connector advertisement {{ link(audit.objectRef.name, audit.objectRef) }}"
40+
match: "!audit.user.username.startsWith('system:') && audit.verb in ['update', 'patch'] && !has(audit.objectRef.subresource) && has(audit.requestObject.spec) && has(audit.responseObject.metadata.name)"
41+
summary: "{{ actor }} updated connector advertisement {{ link(audit.responseObject.metadata.name, audit.objectRef) }}"
4242

4343
# ConnectorAdvertisement update fallback (no spec)
4444
- name: update-fallback

config/milo/activity/policies/domain-policy.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ spec:
1818
# Domain creation with spec.domainName available - use domain name as display text
1919
- name: create
2020
match: "!audit.user.username.startsWith('system:') && audit.verb == 'create' && has(audit.requestObject.spec)"
21-
summary: "{{ actor }} created domain {{ link(audit.requestObject.spec.domainName, audit.objectRef) }}"
21+
summary: "{{ actor }} created domain {{ has(audit.requestObject.spec) && has(audit.requestObject.spec.domainName) ? link(audit.requestObject.spec.domainName, audit.objectRef) : '' }}"
2222

2323
# Domain creation fallback (no spec)
2424
- name: create-fallback
@@ -38,7 +38,7 @@ spec:
3838
# Domain update with spec available - excludes status subresource
3939
- name: update
4040
match: "!audit.user.username.startsWith('system:') && audit.verb in ['update', 'patch'] && !has(audit.objectRef.subresource) && has(audit.requestObject.spec)"
41-
summary: "{{ actor }} updated domain {{ link(audit.requestObject.spec.domainName, audit.objectRef) }}"
41+
summary: "{{ actor }} updated domain {{ has(audit.requestObject.spec) && has(audit.requestObject.spec.domainName) ? link(audit.requestObject.spec.domainName, audit.objectRef) : '' }}"
4242

4343
# Domain update fallback (no spec)
4444
- name: update-fallback

config/milo/activity/policies/gateway-policy.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ spec:
1616
auditRules:
1717
# Gateway creation with spec available
1818
- name: create
19-
match: "!audit.user.username.startsWith('system:') && audit.verb == 'create' && has(audit.requestObject.spec)"
20-
summary: "{{ actor }} created gateway {{ link(audit.objectRef.name, audit.objectRef) }}"
19+
match: "!audit.user.username.startsWith('system:') && audit.verb == 'create' && has(audit.requestObject.spec) && has(audit.responseObject.metadata.name)"
20+
summary: "{{ actor }} created gateway {{ link(audit.responseObject.metadata.name, audit.objectRef) }}"
2121

2222
# Gateway creation fallback (no spec)
2323
- name: create-fallback
@@ -36,8 +36,8 @@ spec:
3636

3737
# Gateway update with spec available - excludes status subresource
3838
- name: update
39-
match: "!audit.user.username.startsWith('system:') && audit.verb in ['update', 'patch'] && !has(audit.objectRef.subresource) && has(audit.requestObject.spec)"
40-
summary: "{{ actor }} updated gateway {{ link(audit.objectRef.name, audit.objectRef) }}"
39+
match: "!audit.user.username.startsWith('system:') && audit.verb in ['update', 'patch'] && !has(audit.objectRef.subresource) && has(audit.requestObject.spec) && has(audit.responseObject.metadata.name)"
40+
summary: "{{ actor }} updated gateway {{ link(audit.responseObject.metadata.name, audit.objectRef) }}"
4141

4242
# Gateway update fallback (no spec)
4343
- name: update-fallback

config/milo/activity/policies/trafficprotectionpolicy-policy.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ spec:
1616
auditRules:
1717
# TrafficProtectionPolicy creation with spec available
1818
- name: create
19-
match: "!audit.user.username.startsWith('system:') && audit.verb == 'create' && has(audit.requestObject.spec)"
20-
summary: "{{ actor }} created traffic protection policy {{ link(audit.objectRef.name, audit.objectRef) }}"
19+
match: "!audit.user.username.startsWith('system:') && audit.verb == 'create' && has(audit.requestObject.spec) && has(audit.responseObject.metadata.name)"
20+
summary: "{{ actor }} created traffic protection policy {{ link(audit.responseObject.metadata.name, audit.objectRef) }}"
2121

2222
# TrafficProtectionPolicy creation fallback (no spec)
2323
- name: create-fallback
@@ -36,8 +36,8 @@ spec:
3636

3737
# TrafficProtectionPolicy update with spec available - excludes status subresource
3838
- name: update
39-
match: "!audit.user.username.startsWith('system:') && audit.verb in ['update', 'patch'] && !has(audit.objectRef.subresource) && has(audit.requestObject.spec)"
40-
summary: "{{ actor }} updated traffic protection policy {{ link(audit.objectRef.name, audit.objectRef) }}"
39+
match: "!audit.user.username.startsWith('system:') && audit.verb in ['update', 'patch'] && !has(audit.objectRef.subresource) && has(audit.requestObject.spec) && has(audit.responseObject.metadata.name)"
40+
summary: "{{ actor }} updated traffic protection policy {{ link(audit.responseObject.metadata.name, audit.objectRef) }}"
4141

4242
# TrafficProtectionPolicy update fallback (no spec)
4343
- name: update-fallback

0 commit comments

Comments
 (0)