Skip to content
Tutorials Center
My learning

Topics

Lesson 25 of 36 ยท Security and Compliance

Compliance, Audit Events and Approvals

Meet audit and governance needs in GitLab with merge request approval rules, compliance frameworks, pipeline execution policies, audit events and signed commits.

Some organizations must prove, not just claim, that their software is built safely. A bank, a hospital or any company with a security certification (for example SOC 2 or ISO 27001) has to show that changes are reviewed, that nobody pushed code alone to production, and that access is tracked. Compliance in GitLab is the set of features that enforce those rules and keep the evidence.

This lesson covers approval rules, separation of duties, compliance frameworks and pipelines, audit events and commit signing. Several features belong to the Premium or Ultimate tiers, and menu names move between versions, so use this text as a map and check the documentation of your version. The examples are JavaScript models of the rules.

Approval rules

A merge request can require approvals before it may merge. In Settings > Merge requests you create approval rules: a number of approvals and the eligible approvers (users, groups or code owners). Examples:

  • "Any change: 1 approval from the Developers group."
  • "Changes to /db/: 1 approval from the database team."
  • "Any change touching billing code: 2 approvals, one of them a Maintainer."

Useful settings on the same page:

  • Prevent approval by the author: the person who wrote the merge request cannot approve it. This is the basic separation of duties.
  • Prevent approvals by users who add commits: someone who pushed to the branch counts as an author, too.
  • Remove all approvals when commits are added: new code needs a fresh review.
  • Require user re-authentication (password or SAML) to approve, for sensitive projects.

Combine this with a protected default branch where nobody may push directly (see Roles, Permissions and Protected Branches), and the rule "all production code was reviewed by a second person" becomes technically enforced rather than a promise.

Merge checks and pipelines

Before the merge button turns green, GitLab can also require that the pipeline succeeded, that all threads are resolved, and that the branch is up to date. Pipelines for merge requests carry the scanner jobs from Security Scanning. Together they form the "evidence" an auditor wants to see: a review, a green test run and a clean security scan for every change.

Compliance frameworks

A compliance framework is a label you attach to projects, such as "PCI-DSS" or "Internal critical". Frameworks make two things easy:

  1. Finding which projects must obey a rule (a report lists projects per framework and their compliance status).
  2. Enforcing controls, for example by attaching a compliance pipeline or, in newer versions, pipeline execution policies. These make GitLab inject a required set of jobs (a mandatory scan, a license check) into the pipelines of every project that carries the framework. Project maintainers cannot remove or skip these jobs, because the policy lives in a separate security-policy project that only administrators or security teams control.
flowchart LR
  F["framework: PCI-DSS"] --> P1["project: payments"]
  F --> P2["project: checkout"]
  POL["policy project (security team)"] -->|"injects required jobs"| P1
  POL -->|"injects required jobs"| P2
  P1 --> R["compliance report"]
  P2 --> R

A framework labels projects; a policy defined elsewhere enforces what runs in them.

Audit events

An audit event is a record of something that changed: who added a member, changed a branch protection, created a token or modified a setting, with the user, IP address and time. In the group or project menu Secure > Audit events (the location depends on the version) you can filter by user, event type and date. Premium adds group and project audit events; Ultimate adds extras such as audit event streaming, which sends events to an external system (SIEM or log store) over HTTPS, so the records stay available even if someone tampers with GitLab.

Auditors typically ask:

  • Who has Owner access, and when did that change?
  • Who changed the protected-branch rules last quarter?
  • When was a deploy token created, and by whom?

Audit events answer those questions; ordinary logs and the activity feed are not tamper-resistant.

Commit signing and verified commits

Anyone can set user.name and user.email to someone else's identity. Signed commits prove who made a commit, using a GPG, SSH or X.509 key that the user registered in their GitLab profile. GitLab shows a Verified badge on commits with a valid signature. A project can require this with the push rule Reject unsigned commits, so unsigned code cannot enter the repository.

Other controls worth knowing

  • Protected environments and deployment approvals control who deploys (see Deployment Strategies and Rollbacks).
  • Dependency and license compliance lists the licenses of your dependencies, so a forbidden license (such as one that conflicts with your product) is caught.
  • Software bill of materials (SBOM): GitLab can produce a list of all components in a build, which customers increasingly ask for.
  • Data retention: artifact expiry and log retention settings help you keep evidence long enough, but not forever.

Stand-in: an approval rule evaluator

This example checks a merge request against approval rules. It implements separation of duties (the author cannot approve), code-owner paths and a minimum count.

JS Approval rules

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The second example filters audit events, like the audit event page does. The events are invented sample data.

JS Searching audit events

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The March events show why audit trails matter: force push was allowed for nine minutes. Without the record nobody would know.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What does 'prevent approval by the author' protect?

    If authors could approve their own work, the review requirement would be meaningless.
  2. 2. What is a compliance framework in GitLab?

    Frameworks mark projects as subject to a standard, so you can report on them and attach required pipelines or policies.
  3. 3. Why use audit event streaming?

    An external SIEM or log store keeps tamper-resistant evidence and lets you alert on suspicious changes.
  4. 4. A commit shows a Verified badge. What does it mean?

    Signing proves who made the commit; the badge says the signature matched a known key.
  5. 5. Why is a policy-injected pipeline hard for project maintainers to bypass?

    Maintainers can edit .gitlab-ci.yml in their project but not the policy project that adds the required jobs.

Summary

  • Approval rules, no author approval and protected branches turn "everything is reviewed" into an enforced rule.
  • Compliance frameworks label projects; policies and compliance pipelines inject mandatory jobs.
  • Audit events record who changed what; stream them outside GitLab for tamper resistance.
  • Signed commits, license and SBOM reports add further evidence. Many of these features need Premium or Ultimate.

Next: Container Registry