Dispatch scheduled business logic scans from scan execution policies
Why
With Add business_logic to the scan execution policy... (!269279 - merged), a scan execution policy can declare scan: business_logic on a schedule rule, but nothing runs it yet.
This starts the business logic flow when the schedule fires, as the trigger account that Provision the security policy trigger for sched... (!269920 - merged) provides.
What changes
- The scheduled run starts one business logic flow per branch, after the policy's CI part.
- Before each run the account's role is re-synced, and the run is skipped if the account holds more access than the flow.
- Each skip (flag, license, no flow, provisioning error, missing access) is logged with its reason, and never blocks the CI actions.
- The trigger's creation is audited before its account's authorizations refresh, as suggested on Provision the security policy trigger for sched... (!269920 - merged).
Design and limitations: https://gitlab.com/gitlab-org/gitlab/-/work_items/638792+
How to test
In a GDK in GitLab.com mode, with Duo Agent Platform onboarding done, the bl_security_analyzer, autonomous_service_account_execution and agentic_analyzer_security_ingestion flags on, and the top-level group opted in to beta features:
- Add a scan execution policy with a
schedulerule a few minutes ahead andscan: business_logic. - When the cron fires, a
security_policytrigger and its service account appear, and a business logic workflow runs as that account. - When it finishes, its findings appear in the vulnerability report.
Verified in a GDK on master 0b951a99, with all four MRs.
The cron fired, and the admin bot created the trigger and a new account.
The scan's CI job succeeded, and its 3 findings matched the project's existing vulnerabilities.
Context
- Part of the split on review: Add security_policy event type to flow triggers (!269275 - merged), Add business_logic to the scan execution policy... (!269279 - merged), Provision the security policy trigger for sched... (!269920 - merged), then this MR.
- Issue: https://gitlab.com/gitlab-org/gitlab/-/work_items/630266+