Run Secrets FP detection on tracked non-default branches
What does this MR do and why?
Runs Secret Detection false-positive (FP) detection automatically for new findings on tracked non-default branches. The flow now checks out the finding's own branch, not the project default branch. This only applies when the new secrets_fp_detection_non_default_branches feature flag (beta, off by default) and VAC are both enabled.
This is the Secrets version of !258183 (merged), which did the same for SAST.
- Ingestion (
Security::Ingestion::Tasks::HooksExecution): new Secret Detection findings on tracked non-default branches are now eligible. Tracked tags are still skipped, and come in a follow-up. SAST behavior is unchanged. - Secrets FP flow (
Ai::Catalog::FoundationalFlow::SecretsFpDetection::Definition): adds asource_branch_resolver, the same as SAST's. It applies to every way of starting the flow that doesn't pass a branch: automatic, the Check for false positive button, bulk, MCP, and restarts. Vulnerability#fp_detection_source_branch: Secret Detection vulnerabilities use the new flag; other report types still usefp_detection_non_default_branches.- Webhooks: no change.
should_execute_hooksalready skips non-default contexts.
A separate flag keeps this rollout independent of fp_detection_non_default_branches, which is about to be enabled by default (!266285 (merged)).
Before (master)
| SAST FP | Secret Detection FP | |
|---|---|---|
| Default branch | Runs on default branch | Runs on default branch |
| Tracked non-default branches | Runs on the finding's branch (fp_detection_non_default_branches) |
Not triggered. Manual runs check out the default branch |
| Tracked tags | Runs; reads code at the tag's commit | Not triggered |
After (VAC + secrets_fp_detection_non_default_branches on)
| SAST FP | Secret Detection FP | |
|---|---|---|
| Default branch | Unchanged | Unchanged |
| Tracked non-default branches | Unchanged | |
| Untracked non-default branches | Unchanged: not triggered | Unchanged: not triggered |
| Tracked tags | Unchanged | Unchanged: not triggered |
"Not triggered" means not auto-triggered at ingestion. Vulnerabilities created from pipeline findings (dismissing a finding or creating an issue from it) can still start FP detection for any context, as on master.
References
- Epic: gitlab-org#23514
- Spike and technical analysis: #628109 (closed)
- SAST equivalent: !258183 (merged)
- Follow-up for local checkout on tags (SAST): #633758
Screenshots or screen recordings
Not applicable: backend only, no UI changes.
How to set up and validate locally
-
Make sure VAC is enabled for your project, Secret Detection false positive detection is turned on, and experiment and beta GitLab Duo features are on for the group.
-
In the Rails console, enable the feature flag:
Feature.enable(:secrets_fp_detection_non_default_branches) -
Track a non-default branch:
mutation { securityRefsTrack(input: { projectPath: "<group>/<project>" refs: [{ name: "<branch>", refType: BRANCH }] }) { trackedRefs { name } errors } } -
Push a commit with a new Critical or High secret to that branch.
-
Confirm an FP detection session starts for the finding, and that the CI job checks out the tracked branch.
-
Disable the flag, or untrack the branch, and push another secret. Confirm no session starts.
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.