Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,16 @@ datum-cloud/enhancements#943.
Never apply two of them with the same manager: an apply drops fields its
manager applied before and left out. Staff can only patch
`spec.hidden` on posts.
- `Submission`, `SubmissionReview`, `SecurityReport` and
`SecurityReportTriage` are audited at `Metadata` only (a Milo audit policy
rule). Security reports are never indexed, synced or sent to the AI gateway.
- `Submission`, `SubmissionReview`, `SecurityReport`, `SecurityReportTriage`
and `FeedbackDigest` are audited at `Metadata` only (a rule in Milo's audit
policy in datum-cloud/infra), so their activity rules can't read request or
response bodies. Security reports are never indexed, synced or sent to the
AI gateway, and have no ActivityPolicy: platform-timeline readers see every
activity entry, whoever made it.
- A delete's audit event has a `Status` response, never the object. Activity
rules for deletes use `objectRef` or an audit annotation (see
`config/milo/activity/post-ref.yaml`); the activity service's CEL has no
string functions, so names can't be split.

## Commands

Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ GET /{submissions|securityreports}/{name}/attachments/{ref} (staff)
- A `Fixed` or `Disclosed` report with public credit gets a `SecurityAcknowledgement` with the name, link, month and severity. It's deleted if that stops being true.
- **`move-to-security` reconciler:** carries out `MoveToSecurity` review decisions. It creates a report owned by the submitter, named `<submission>-<submission UID>` and annotated with the submission's name and UID (`feedback.miloapis.com/moved-from-submission`, `-uid`). It reads the report back and checks the name, UID and owner before it copies the attachments and deletes the submission, which takes its review and files with it. If a report it didn't create already has that name, it keeps the submission and its files and sets `Applied=False` with reason `ReportNameTaken` on the review; the move is tried again when a report is deleted. Only the operator can set the moved-from annotations, and they can't change.

## Audit and activity

Milo audits feedback writes like any other CRD. Its audit policy (in `datum-cloud/infra`) logs feedback writes at `RequestResponse`, so search can index posts from the audit log. It logs `submissions`, `submissionreviews`, `securityreports`, `securityreporttriages` and `feedbackdigests`, with their subresources, at `Metadata` only: private context and vulnerability details never reach the audit log, activity or search.

`config/milo/activity` holds an `ActivityPolicy` per kind, so people's actions read as sentences in activity timelines: voting, following, sending feedback, staff decisions, hiding posts and editing sources. The service's own components are `system:` users and are left out. A delete's audit event carries a `Status`, not the deleted object, so a `ValidatingAdmissionPolicy` (`post-ref.yaml`) adds the post's name to vote and subscription deletes as the audit annotation `post-ref.feedback.miloapis.com/post`, and the unvote and unfollow rules read it there. Security reports and their triage have no `ActivityPolicy`: the activity service shows every entry to anyone who can read the platform timeline, with no per-entry access check, so an entry would reveal that a report exists. `test/config` compiles every rule in the activity service's CEL environment, checks that rules never read bodies a metadata-only kind or a delete won't have, renders delete events written by an envtest API server, and checks no policy covers security reports.

## Roles

| Role | For |
Expand Down Expand Up @@ -131,8 +137,9 @@ config/crd/ generated CRDs, installed in Milo
config/base/ operator and uploads Deployments, Services, leader election RBAC
config/components/ milo-integration: Milo kubeconfig, client and webhook certificates
config/milo/ applied to Milo: IAM (iam/), RBAC for the service's
components (rbac/), webhook config (webhook/), and
optional role bindings (bindings/)
components (rbac/), webhook config (webhook/),
activity rules (activity/), and optional role
bindings (bindings/)
config/samples/ an example of every resource
test/config/ checks config/ against the CRDs
```
Expand Down
13 changes: 13 additions & 0 deletions config/milo/activity/feedbackprofiles.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# A user's feedback settings.
apiVersion: activity.miloapis.com/v1alpha1
kind: ActivityPolicy
metadata:
name: feedback.miloapis.com-feedbackprofiles
spec:
resource:
apiGroup: feedback.miloapis.com
kind: FeedbackProfile
auditRules:
- name: update
match: "!audit.user.username.startsWith('system:') && audit.verb in ['create', 'update', 'patch'] && has(audit.responseStatus.code) && audit.responseStatus.code >= 200 && audit.responseStatus.code < 300 && !(has(audit.requestURI) && audit.requestURI.contains('dryRun='))"
summary: "{{ actor }} updated their feedback settings"
19 changes: 19 additions & 0 deletions config/milo/activity/feedbacksources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Which GitHub organizations and repositories feed the roadmap.
apiVersion: activity.miloapis.com/v1alpha1
kind: ActivityPolicy
metadata:
name: feedback.miloapis.com-feedbacksources
spec:
resource:
apiGroup: feedback.miloapis.com
kind: FeedbackSource
auditRules:
- name: create
match: "!audit.user.username.startsWith('system:') && audit.verb == 'create' && has(audit.responseStatus.code) && audit.responseStatus.code >= 200 && audit.responseStatus.code < 300 && !(has(audit.requestURI) && audit.requestURI.contains('dryRun='))"
summary: "{{ actor }} added feedback source {{ link(audit.responseObject.metadata.name, audit.objectRef) }}"
- name: update
match: "!audit.user.username.startsWith('system:') && audit.verb in ['update', 'patch'] && !has(audit.objectRef.subresource) && has(audit.responseStatus.code) && audit.responseStatus.code >= 200 && audit.responseStatus.code < 300 && !(has(audit.requestURI) && audit.requestURI.contains('dryRun='))"
summary: "{{ actor }} updated feedback source {{ link(audit.objectRef.name, audit.objectRef) }}"
- name: delete
match: "!audit.user.username.startsWith('system:') && audit.verb == 'delete' && has(audit.responseStatus.code) && audit.responseStatus.code >= 200 && audit.responseStatus.code < 300 && !(has(audit.requestURI) && audit.requestURI.contains('dryRun='))"
summary: "{{ actor }} removed feedback source {{ audit.objectRef.name }}"
25 changes: 25 additions & 0 deletions config/milo/activity/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# ActivityPolicies: how feedback writes read in activity timelines. Only
# people's actions appear; the service's own components are system: users.
# Kinds logged at Metadata (submissions, reviews) have rules that use only
# the verb and object reference. post-ref.yaml is the admission policy that
# names the post in vote and subscription delete events.
#
# Security reports and their triage have no ActivityPolicy, so they make no
# activity entries at all. The activity service files an entry under the
# actor's context and offers no per-entry access check: anyone who can read
# the platform timeline sees every entry, including a reporter's own, and
# the Security Team works in the platform context. An entry would tell those
# readers that a report exists and what staff did with it, which only the
# Security Team (and the reporter) may know. The audit log keeps the record.
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component

resources:
- post-ref.yaml
- votes.yaml
- subscriptions.yaml
- submissions.yaml
- submissionreviews.yaml
- posts.yaml
- feedbacksources.yaml
- feedbackprofiles.yaml
41 changes: 41 additions & 0 deletions config/milo/activity/post-ref.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Names the post in the audit event when someone removes a vote or stops
# following a post, so the activity rules in votes.yaml and subscriptions.yaml
# can say which post it was.
#
# A delete's audit event has no object body: the API server answers a custom
# resource delete with a Status (name, group, resource and UID only) and the
# request body, if any, is DeleteOptions. The name is <post>.<user>, but the
# activity service's CEL has no string functions to split it. Admission sees
# the object being deleted (oldObject), and an audit annotation from a
# ValidatingAdmissionPolicy is recorded at every audit level as
# "post-ref.feedback.miloapis.com/post".
#
# The policy has no validations, so it never refuses a delete, and it runs in
# the API server, so there is no webhook to be unavailable. With
# failurePolicy Ignore, an evaluation error leaves the annotation out and the
# activity entry falls back to not naming the post.
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicy
metadata:
name: post-ref.feedback.miloapis.com
spec:
failurePolicy: Ignore
matchConstraints:
resourceRules:
- apiGroups: ["feedback.miloapis.com"]
apiVersions: ["*"]
operations: ["DELETE"]
resources: ["votes", "subscriptions"]
auditAnnotations:
- key: post
valueExpression: "string(oldObject.spec.postRef.name)"
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicyBinding
metadata:
name: post-ref.feedback.miloapis.com
spec:
policyName: post-ref.feedback.miloapis.com
# There are no validations to act on; audit annotations are recorded
# whatever the actions are.
validationActions: ["Audit"]
21 changes: 21 additions & 0 deletions config/milo/activity/posts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Posts are logged in full. feedback-sync and the operator are system:
# actors, so only staff hiding and showing posts appears. A merge patch that
# sets spec.hidden reads as hiding or showing; other staff edits as updates.
apiVersion: activity.miloapis.com/v1alpha1
kind: ActivityPolicy
metadata:
name: feedback.miloapis.com-posts
spec:
resource:
apiGroup: feedback.miloapis.com
kind: Post
auditRules:
- name: hide
match: "!audit.user.username.startsWith('system:') && audit.verb in ['update', 'patch'] && !has(audit.objectRef.subresource) && type(audit.requestObject) == map && has(audit.requestObject.spec) && type(audit.requestObject.spec) == map && has(audit.requestObject.spec.hidden) && audit.requestObject.spec.hidden == true && has(audit.responseStatus.code) && audit.responseStatus.code >= 200 && audit.responseStatus.code < 300 && !(has(audit.requestURI) && audit.requestURI.contains('dryRun='))"
summary: "{{ actor }} hid post {{ link(audit.objectRef.name, audit.objectRef) }}"
- name: show
match: "!audit.user.username.startsWith('system:') && audit.verb in ['update', 'patch'] && !has(audit.objectRef.subresource) && type(audit.requestObject) == map && has(audit.requestObject.spec) && type(audit.requestObject.spec) == map && has(audit.requestObject.spec.hidden) && audit.requestObject.spec.hidden == false && has(audit.responseStatus.code) && audit.responseStatus.code >= 200 && audit.responseStatus.code < 300 && !(has(audit.requestURI) && audit.requestURI.contains('dryRun='))"
summary: "{{ actor }} showed post {{ link(audit.objectRef.name, audit.objectRef) }} again"
- name: update
match: "!audit.user.username.startsWith('system:') && audit.verb in ['update', 'patch'] && !has(audit.objectRef.subresource) && has(audit.responseStatus.code) && audit.responseStatus.code >= 200 && audit.responseStatus.code < 300 && !(has(audit.requestURI) && audit.requestURI.contains('dryRun='))"
summary: "{{ actor }} updated post {{ link(audit.objectRef.name, audit.objectRef) }}"
14 changes: 14 additions & 0 deletions config/milo/activity/submissionreviews.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Reviews are logged at Metadata only. Staff decide by updating the review;
# the decision can't change after that, so an update is the decision.
apiVersion: activity.miloapis.com/v1alpha1
kind: ActivityPolicy
metadata:
name: feedback.miloapis.com-submissionreviews
spec:
resource:
apiGroup: feedback.miloapis.com
kind: SubmissionReview
auditRules:
- name: decide
match: "!audit.user.username.startsWith('system:') && audit.verb in ['update', 'patch'] && !has(audit.objectRef.subresource) && has(audit.responseStatus.code) && audit.responseStatus.code >= 200 && audit.responseStatus.code < 300 && !(has(audit.requestURI) && audit.requestURI.contains('dryRun='))"
summary: "{{ actor }} decided on submission {{ link(audit.objectRef.name, audit.objectRef) }}"
17 changes: 17 additions & 0 deletions config/milo/activity/submissions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Submissions are logged at Metadata only, so rules use the verb and the
# object reference and never the request or response body.
apiVersion: activity.miloapis.com/v1alpha1
kind: ActivityPolicy
metadata:
name: feedback.miloapis.com-submissions
spec:
resource:
apiGroup: feedback.miloapis.com
kind: Submission
auditRules:
- name: send
match: "!audit.user.username.startsWith('system:') && audit.verb == 'create' && has(audit.responseStatus.code) && audit.responseStatus.code >= 200 && audit.responseStatus.code < 300 && !(has(audit.requestURI) && audit.requestURI.contains('dryRun='))"
summary: "{{ actor }} sent feedback"
- name: delete
match: "!audit.user.username.startsWith('system:') && audit.verb == 'delete' && has(audit.responseStatus.code) && audit.responseStatus.code >= 200 && audit.responseStatus.code < 300 && !(has(audit.requestURI) && audit.requestURI.contains('dryRun='))"
summary: "{{ actor }} deleted submission {{ audit.objectRef.name }}"
23 changes: 23 additions & 0 deletions config/milo/activity/subscriptions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Follows are logged in full, so the follow rule reads the post from the
# request. A delete's audit event has no subscription in it, so the unfollow
# rule reads the post from the audit annotation post-ref.yaml adds. Follows
# the operator creates when someone votes or their submission is decided are
# system: actors and don't appear.
apiVersion: activity.miloapis.com/v1alpha1
kind: ActivityPolicy
metadata:
name: feedback.miloapis.com-subscriptions
spec:
resource:
apiGroup: feedback.miloapis.com
kind: Subscription
auditRules:
- name: follow
match: "!audit.user.username.startsWith('system:') && audit.verb == 'create' && has(audit.requestObject.spec) && has(audit.requestObject.spec.postRef) && has(audit.responseStatus.code) && audit.responseStatus.code >= 200 && audit.responseStatus.code < 300 && !(has(audit.requestURI) && audit.requestURI.contains('dryRun='))"
summary: "{{ actor }} followed {{ link(audit.requestObject.spec.postRef.name, {'apiGroup': 'feedback.miloapis.com', 'apiVersion': 'v1alpha1', 'resource': 'posts', 'name': audit.requestObject.spec.postRef.name}) }}"
- name: unfollow
match: "!audit.user.username.startsWith('system:') && audit.verb == 'delete' && has(audit.annotations) && 'post-ref.feedback.miloapis.com/post' in audit.annotations && has(audit.responseStatus.code) && audit.responseStatus.code >= 200 && audit.responseStatus.code < 300 && !(has(audit.requestURI) && audit.requestURI.contains('dryRun='))"
summary: "{{ actor }} stopped following {{ link(audit.annotations['post-ref.feedback.miloapis.com/post'], {'apiGroup': 'feedback.miloapis.com', 'apiVersion': 'v1alpha1', 'resource': 'posts', 'name': audit.annotations['post-ref.feedback.miloapis.com/post']}) }}"
- name: unfollow-post-unknown
match: "!audit.user.username.startsWith('system:') && audit.verb == 'delete' && has(audit.responseStatus.code) && audit.responseStatus.code >= 200 && audit.responseStatus.code < 300 && !(has(audit.requestURI) && audit.requestURI.contains('dryRun='))"
summary: "{{ actor }} stopped following a post"
24 changes: 24 additions & 0 deletions config/milo/activity/votes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Votes are logged in full (RequestResponse), so the create rule reads the
# post from the request. A delete's audit event has no vote in it (the
# response is a Status, the request DeleteOptions), so the unvote rule reads
# the post from the audit annotation post-ref.yaml adds; without it, the entry
# doesn't name the post. The operator's writes (status, votes it gives
# submitters) are system: actors and don't appear.
apiVersion: activity.miloapis.com/v1alpha1
kind: ActivityPolicy
metadata:
name: feedback.miloapis.com-votes
spec:
resource:
apiGroup: feedback.miloapis.com
kind: Vote
auditRules:
- name: vote
match: "!audit.user.username.startsWith('system:') && audit.verb == 'create' && has(audit.requestObject.spec) && has(audit.requestObject.spec.postRef) && has(audit.responseStatus.code) && audit.responseStatus.code >= 200 && audit.responseStatus.code < 300 && !(has(audit.requestURI) && audit.requestURI.contains('dryRun='))"
summary: "{{ actor }} voted on {{ link(audit.requestObject.spec.postRef.name, {'apiGroup': 'feedback.miloapis.com', 'apiVersion': 'v1alpha1', 'resource': 'posts', 'name': audit.requestObject.spec.postRef.name}) }}"
- name: unvote
match: "!audit.user.username.startsWith('system:') && audit.verb == 'delete' && has(audit.annotations) && 'post-ref.feedback.miloapis.com/post' in audit.annotations && has(audit.responseStatus.code) && audit.responseStatus.code >= 200 && audit.responseStatus.code < 300 && !(has(audit.requestURI) && audit.requestURI.contains('dryRun='))"
summary: "{{ actor }} removed their vote on {{ link(audit.annotations['post-ref.feedback.miloapis.com/post'], {'apiGroup': 'feedback.miloapis.com', 'apiVersion': 'v1alpha1', 'resource': 'posts', 'name': audit.annotations['post-ref.feedback.miloapis.com/post']}) }}"
- name: unvote-post-unknown
match: "!audit.user.username.startsWith('system:') && audit.verb == 'delete' && has(audit.responseStatus.code) && audit.responseStatus.code >= 200 && audit.responseStatus.code < 300 && !(has(audit.requestURI) && audit.requestURI.contains('dryRun='))"
summary: "{{ actor }} removed a vote"
5 changes: 3 additions & 2 deletions config/milo/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# What the service registers in Milo: ProtectedResources and Roles (iam/),
# Kubernetes RBAC for the service's own components (rbac/) and the admission
# webhooks Milo calls (webhook/). The CRDs are in config/crd. bindings/ is
# Kubernetes RBAC for the service's own components (rbac/), the admission
# webhooks Milo calls (webhook/) and activity timeline rules (activity/). The CRDs are in config/crd. bindings/ is
# separate and optional: who holds the roles is the deployment's choice.
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
Expand All @@ -9,3 +9,4 @@ components:
- iam/
- rbac/
- webhook/
- activity/
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ toolchain go1.27.4

require (
github.com/evanphx/json-patch/v5 v5.9.11
github.com/google/cel-go v0.29.2
github.com/johannesboyne/gofakes3 v1.2.0
github.com/spf13/cobra v1.10.2
gocloud.dev v0.48.0
Expand All @@ -28,6 +29,7 @@ require (
cloud.google.com/go/storage v1.69.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.62.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.62.0 // indirect
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
github.com/aws/aws-sdk-go-v2 v1.47.3 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.22 // indirect
github.com/aws/aws-sdk-go-v2/config v1.33.9 // indirect
Expand Down Expand Up @@ -113,6 +115,7 @@ require (
go.yaml.in/yaml/v2 v2.4.4 // indirect
go.yaml.in/yaml/v3 v3.0.6 // indirect
golang.org/x/crypto v0.58.0 // indirect
golang.org/x/exp v0.0.0-20261014143641-f0251eb4aa3e // indirect
golang.org/x/mod v0.42.0 // indirect
golang.org/x/net v0.62.0 // indirect
golang.org/x/oauth2 v0.37.0 // indirect
Expand Down
Loading
Loading