Skip to content

feat: activity timeline rules for feedback - #40

Open
mattdjenkinson wants to merge 4 commits into
feat/crd-securityfrom
feat/crd-activity
Open

mattdjenkinson wants to merge 4 commits into
feat/crd-securityfrom
feat/crd-activity

Conversation

@mattdjenkinson

@mattdjenkinson mattdjenkinson commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Part of #11, with datum-cloud/infra#9437. #11 stays open until activity timelines are checked in staging (#13). Stacked on #39.

With CRDs, Milo audits feedback writes itself. The Postgres version's own audit backend, and the Milo rule to drop duplicate events, are no longer needed. Two pieces remain:

  1. What Milo logs, which is datum-cloud/infra#9437:
    • feedback.miloapis.com writes at RequestResponse, so search can index posts.
    • submissions, submissionreviews, securityreports, securityreporttriages and feedbackdigests at Metadata only.
  2. How people's actions read in activity timelines, which is this PR: an ActivityPolicy per kind in config/milo/activity.
Kind Rules
Vote voted on / removed their vote on post
Subscription followed / stopped following post
Submission sent feedback; deleted submission (staff)
SubmissionReview decided on submission name
Post hid / showed again / updated post (staff)
FeedbackSource added / updated / removed feedback source
FeedbackProfile updated their feedback settings
  • Every rule leaves out system: users, so feedback-sync, the operator and uploads don't appear. That includes the follows and votes the operator gives submitters.
  • Rules for the metadata-only kinds use only the verb and object reference. Their names are opaque (sub-…), and nothing from the body is there.
  • Unvote and unfollow name the post through an audit annotation. A custom resource delete's audit event carries a Status, not the deleted object, and the activity service's CEL can't split the <post>.<user> name. post-ref.yaml is a ValidatingAdmissionPolicy with no validations that adds post-ref.feedback.miloapis.com/post to vote and subscription deletes. It has failurePolicy: Ignore, so it never blocks a delete. Without the annotation the entry still appears, without the post.
  • No activity for security reports or triage. The activity service files entries under the actor's context with no per-entry access check, and platform-scope readers see every entry. Entries there would reveal that a report exists.

Tests

  • test/config/activity_test.go:
    • every policy targets a feedback CRD;
    • every match expression and summary template compiles in the activity service's CEL environment;
    • every rule leaves out system: users;
    • rules for metadata-only kinds never read requestObject or responseObject;
    • unvote and unfollow rules, evaluated against real delete audit events from an envtest API server, name the post from the annotation;
    • no policy covers security reports or triage.
  • kustomize build of the Milo components renders 7 policies and the admission policy.
  • In kind against a real Milo (test: end-to-end tests in kind against a real Milo #42): vote and follow deletes carry the post annotation in their audit events.
  • Rendering in a real activity timeline, which needs staging (Deploy to staging #13).

An ActivityPolicy per kind turns people's feedback writes into
sentences: votes, follows, feedback and reports sent, staff decisions,
hiding posts and editing sources. The service's own system: users are
left out. Rules for kinds Milo audits at Metadata only use the verb and
object reference; a test compiles every rule and enforces that.

Copy link
Copy Markdown

Two issues to resolve before merging:

  • The unvote/unfollow rules expect the deleted object's spec, but CRD deletes return a Status response. These entries never appear. Use data actually present in the delete audit event and test that response shape.
  • Security-report activity is placed in the platform timeline, whose readers may not have security-report access. This reveals report existence and staff actions, though not the vulnerability text. Please restrict or omit those entries, or explicitly confirm that this visibility is intended.

The Metadata-only audit policy also needs to ship before these rules are enabled.

…ort activity

CRD deletes return a Status in the audit event, not the deleted object, so
the unvote and unfollow rules that read responseObject.spec never matched.
A ValidatingAdmissionPolicy with no validations now adds the post's name to
vote and subscription deletes as the audit annotation
post-ref.feedback.miloapis.com/post, and the rules read it there. Without
the annotation the entries still appear, without the post.

The activity service files entries under the actor's context with no
per-entry access check, and platform-scope readers see every entry, so
security report and triage entries would reveal that reports exist. Their
ActivityPolicies are removed.

Tests evaluate rules in the activity service's CEL environment against
delete events written by an envtest API server, check no delete rule reads
request or response bodies, and check no policy covers security reports.
@mattdjenkinson

Copy link
Copy Markdown
Contributor Author

Both fixed in 1bf67c5.

  • Unvote and unfollow: right, a delete's audit event has only a Status. A ValidatingAdmissionPolicy with no validations now adds the post name to vote and subscription deletes as the audit annotation post-ref.feedback.miloapis.com/post, and the rules read that. It has failurePolicy: Ignore, so it never blocks a delete. The tests evaluate the rules against real delete events from an envtest API server, and test: end-to-end tests in kind against a real Milo #42 checks the annotation in Milo's audit events in kind.
  • Security reports: I've removed the security report and triage activity policies, and a test makes sure none come back. The PR description is updated.

The Metadata-only audit policy is datum-cloud/infra#9437, and it's listed in the README's rollout prerequisites.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants