Allow service accounts in bypass_settings to automatically bypass merge request approval policies

Summary

Currently, service accounts configured in bypass_settings.service_accounts can bypass push protections from merge request approval policies, but they cannot automatically bypass approval requirements on merge requests they create. This creates friction for automation tools like Renovate that need to:

  1. Create merge requests for visibility and audit purposes
  2. Run CI/CD pipelines before integration
  3. Auto-merge without manual approval intervention

Proposal

Extend the bypass_settings.service_accounts functionality to automatically bypass merge request approval policy requirements when:

  • A service account listed in bypass_settings.service_accounts creates a merge request
  • The merge request is ready to be merged (all pipelines pass, no conflicts, etc.)

This would eliminate the need for:

  • Manual approval by users
  • Calling the mergeRequestBypassSecurityPolicy GraphQL mutation
  • Using workarounds like branch name exceptions that can be exploited by regular users

Use Case

Automated Dependency Management with Renovate:

  1. Renovate detects an outdated dependency
  2. Renovate (using service account) pushes changes to branch renovate/xyz
  3. Renovate creates a merge request with platform automerge enabled
  4. Merge request pipeline runs (tests, security scans, etc.)
  5. After pipeline succeeds, MR automatically merges without requiring manual approval
  6. Audit trail is preserved through the MR history

Current Workarounds and Their Issues:

  • Branch name exceptions (e.g., renovate/*): Any user can create branches matching this pattern and bypass approvals, creating a security risk
  • GraphQL mutation: Requires additional automation logic and doesn't support true "hands-off" workflows
  • Direct push to default branch: Loses visibility, audit trail, and pre-merge CI/CD validation

Expected Behavior

When a service account in bypass_settings.service_accounts creates a merge request:

  1. MR approval policy restrictions should be automatically bypassed
  2. No "Approval required" message in MR widget
  3. Audit events generated documenting the bypass (e.g., security_policy_service_account_mr_bypass)
  4. MR can auto-merge when all other conditions are met (passing pipelines, no conflicts)
  5. Full audit trail maintained through MR history

Benefits

  • Security: Avoids broad branch-based exceptions that any user can exploit
  • Visibility: Maintains MR workflow for review and audit purposes
  • Automation: Enables true hands-off automated dependency updates
  • Compliance: Preserves audit trail while allowing approved automation

Implementation Considerations

  • Should respect all other merge requirements (passing pipelines, no conflicts, etc.)
  • Should generate appropriate audit events
  • Should be clearly documented to distinguish from push bypass behavior
  • May need UI indicator showing the bypass is in effect for transparency
Edited by 🤖 GitLab Bot 🤖