Write audit events when Artifact Registry repositories change

What does this MR do and why?

Artifact Registry repository changes now write audit events. Today only role changes do (!268575 (merged)). This is the same pattern, applied to the repository mutations.

Event Written when Extra details
artifact_registry_repository_created A repository is created format, kind, visibility
artifact_registry_repository_updated A repository is updated changed field names, visibility after the change
artifact_registry_repository_deleted A repository and its artifacts are deleted none
artifact_registry_repository_artifacts_deleted Deletion of every artifact is requested format, kind
artifact_registry_upstream_repository_dissociated An upstream is removed from a virtual repository format, association ID
  • Same scope as role events. The organization's top-level group, or Instance scope when there isn't exactly one. The scope logic moves to ArtifactRegistry::TopLevelGroups.audit_scope so both share it.
  • Written after Artifact Registry succeeds. No event for a refused or failed change.
  • No event for a no-op. Deleting a repository or removing an upstream that's already gone writes nothing. To support this, Client#delete_repository and #dissociate_upstream_repository now return false on the idempotent 404. Each has one caller.
  • Never blocks the change. Building and writing the event both happen inside one rescue. A failure goes to error tracking, and the mutation still succeeds.
  • No credentials. Updates record field names only, because settings can hold upstream credentials.

What it doesn't cover: changes made through the GitLab UI or GraphQL API write these events. A user can also exchange a personal access token for an Artifact Registry token and call the AR management API directly. Those calls write no event here. Auditing them on the AR side is gitlab-org/ops/artifact-registry#718.

Not in this MR:

  • Artifact deletes (versions, manifests, tags, dist-tags). Users can send these straight to Artifact Registry, so they need work on that side too. See https://gitlab.com/gitlab-org/ops/artifact-registry/-/work_items/1949.
  • Previous values on update. The mutation doesn't know them without an extra read.
  • A changelog entry. All five mutations are mounted as experiments.

References

How to set up and validate locally

  1. Enable Artifact Registry for an organization that has one top-level group.
  2. Create a repository with artifactRegistryRepositoryCreate, change its description with artifactRegistryRepositoryUpdate, then delete it with artifactRegistryRepositoryDelete.
  3. Open the top-level group's Secure > Audit events. You should see one created, one updated, and one deleted event.
  4. Run the delete again. No new event appears.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist.

🤖 Generated with Claude Code

Edited by Tim Rizzi

Merge request reports

Loading
Loading