Audit project CI/CD settings changes

What does this MR do and why?

Closes #8073

Changes to a project's CI/CD settings aren't audited today. The existing project auditor covers merge request and approval settings, and the CI/CD settings auditor only covers merge pipelines and merge trains. Several of the remaining settings change what pipelines expose or what they can do, so a change to them matters during an incident: who made pipelines public, who pointed the project at a different CI/CD configuration file, who let fork pipelines run in the parent project.

This MR adds 10 audit events, each recording the old and new value:

Setting Event Why it matters
Public pipelines (public_builds) project_public_builds_updated Exposes job logs and artifacts to anyone who can see the project
CI/CD configuration file (ci_config_path) project_ci_config_path_updated Changes which pipeline definition runs
Git strategy (build_allow_git_fetch) project_build_allow_git_fetch_updated Requested in the issue
Job timeout (build_timeout) project_build_timeout_updated Requested in the issue
Auto-cancel redundant pipelines project_auto_cancel_pending_pipelines_updated Requested in the issue
Minimum role to use pipeline variables project_cicd_pipeline_variables_minimum_override_role_updated Controls who can inject variables into pipelines
Run pipelines for forks in the parent project project_cicd_allow_fork_pipelines_to_run_in_parent_project_updated Lets fork code run with the parent project's resources
Allow job tokens to push to the repository project_cicd_push_repository_for_job_token_allowed_updated Lets CI jobs write to the repository
ID token sub claim components project_cicd_id_token_sub_claim_components_updated Changes the claims cloud providers trust for OIDC
Automatic pipeline cleanup (delete_pipelines_in_seconds) project_cicd_delete_pipelines_in_seconds_updated Controls how long pipeline evidence is kept

How it works

  • Projects::ProjectChangesAuditor gets a CI_CD_COLUMNS list for the five projects columns.
  • Ci::ProjectCiCdSettingChangesAuditor gets a SECURITY_COLUMNS list for the five project_ci_cd_settings columns.
  • Both use the existing audit_changes helper, guarded by should_audit? so a change between two blank values (for example nil to "") isn't recorded.

Not in this MR

  • The other project_ci_cd_settings columns (default Git depth, forward deployment, keep latest artifact, separated caches and so on). They have less security value, and could be added the same way if the group wants them.
  • Runner settings, tracked separately in #8074. CI/CD variables are already audited.

How to set up and validate locally

  1. With an Ultimate license, open a project's Settings > CI/CD > General pipelines and change the visibility of pipelines, the CI/CD configuration file and the timeout.
  2. Under Variables, change the minimum role to use pipeline variables.
  3. Check Secure > Audit events for the project, or log/audit_json.log. Each change produces one event with its old and new value.

Tests

  • ee/spec/lib/projects/project_changes_auditor_spec.rb: each of the five projects columns records the change and streams the right event. ci_config_path going between nil and "" records nothing, and nil to a path is recorded
  • ee/spec/lib/ci/project_ci_cd_setting_changes_auditor_spec.rb: each of the five CI/CD settings columns records the change and streams the right event. A blank-to-blank change records nothing, and turning on automatic pipeline cleanup from nil is recorded

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist.

Context

This is part of the Security Logging team's work to close high-priority gaps in gitlab-org&736 (Comprehensive audit log), so customers can answer the same incident-response questions from audit events that GitLab answers internally from Rails logs.

🤖 Generated with Claude Code

Edited by Daryn Wilkinson

Merge request reports

Loading
Loading