Grant API access to security policy bot
What does this MR do and why?
Grant API access to the security policy bot.
Security policy bots need API access to perform operations like downloading artifacts from previous jobs in scheduled pipeline execution policies. Without API access, jobs in later stages cannot download artifacts from earlier policy jobs, resulting in 403 Forbidden - This action cannot be performed by internal users errors.
Background
This is the final part (Phase 3) of a 3-phase implementation to fix artifact download between scheduled policy jobs, as described in epic &21707:
| Phase | Issue | Description | Status |
|---|---|---|---|
| 1 | #594740 (closed) | Refactor security policy bot permissions to use YAML format | |
| 2 | #594741 (closed) | Update security policy bot role to minimal access | |
| 3 | #594742 | Grant API access to security policy bot role |
Changelog: fixed EE: true
References
- Parent Epic: &21707
- Related Issue: #594742
- Phase 1 MR: !230498 (merged)
- Phase 2 MR: !232174 (closed)
Screenshots or screen recordings
| Before | After |
|---|---|
![]() |
![]() |
How to set up and validate locally
- Create a new group.
- Create a new project on the group.
- Add a CI config file
policy-ci.yml:stages: - build - test create_artifact: stage: build script: - echo "Hello from artifact" > message.txt artifacts: paths: - message.txt read_artifact: stage: test script: - cat message.txt needs: - create_artifact - Add a
.gitlab/security-policies/policy.ymlfile to the project with content (Replacepath/to/projectwith the path to your project):--- experiments: pipeline_execution_schedule_policy: enabled: true pipeline_execution_policy: [] approval_policy: [] pipeline_execution_schedule_policy: - name: test description: enabled: true pipeline_config_strategy: schedule content: include: - project: path/to/project file: policy-ci.yml schedules: - type: daily start_time: 10:00 time_window: value: 600 distribution: random - Go back to the group page and on the left sidebar, select Secure and Policies.
- Select Edit policy project and select your project. Then select Save.
- Create another project in the group to test the pipeline.
- Copy the project ID
- Start the schedule worker manually to trigger the schedule (replace
YOUR_PROJECT_IDwith the id of your project)project_id = YOUR_PROJECT_ID schedule = Security::PipelineExecutionProjectSchedule.find_by_project_id(project_id) Security::PipelineExecutionPolicies::RunScheduleWorker.new.perform(schedule.id) - Go to Build -> Pipelines in your project and wait for the scheduled pipeline to appear.
- Verify that the
read_artifactjob succeeds
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Closes #594742
Edited by Andy Schoenen

