Accept dependency settings on dependency scanning scanners
What does this MR do and why?
Merge request approval policies block on dependency scanning findings that the merge request did not introduce. The common case is a new advisory for a dependency that already exists, unchanged, on the target branch. The target branch was scanned before the advisory was published, so the finding is newly detected.
This MR is the first of a stack. It lets dependency_scanning scanner entries in scan_finding rules carry two settings, and adds the feature flag that gates them:
scanners:
- type: dependency_scanning
dependency_change: introduced # introduced | unchanged | any (default)
dependency_type: direct # direct | transitive | any (default)- Both JSON schemas accept
dependency_changeanddependency_type, only ondependency_scanningentries. Plain string scanners and policies without the settings behave as before. The schema isn't gated, the same as foris_malicious. RuleandScannerConfigcarry the settings.anyis the default and is treated as unset.- The settings sit behind the
betafeature flagapproval_policy_dependency_scanning_filters, which is disabled by default. With the flag disabled,ApprovalPolicySource#scanner_configurationsdrops the settings, so rules follow today's evaluation path.
No behavior changes yet: nothing evaluates the settings until the wiring MR in this stack lands. The filtering semantics are described in that MR and in the docs MR.
Approach: the plan was reviewed and agreed on the issue (revision 2): #635482 (comment 4070943000)
References
- Related to #635482
- Feature flag rollout: https://gitlab.com/gitlab-org/gitlab/-/work_items/635635
- Follow-ups:
- Rules with only previously existing states: https://gitlab.com/gitlab-org/gitlab/-/work_items/635632
- Rule builder support: #635633
- Container scanning: #635634
Screenshots or screen recordings
Not applicable: backend only. The settings can be set in YAML mode only (#635633).
How to set up and validate locally
- Run the new specs:
bundle exec rspec ee/spec/lib/security/scan_result_policies/rule_spec.rb ee/spec/lib/security/scan_result_policies/scanner_config_spec.rb ee/spec/models/security/approval_policy_source_spec.rb ee/spec/models/security/orchestration_policy_configuration_spec.rb - In the Rails console, check that the flag gates the settings for a project with a policy that sets
dependency_change: introduced:Feature.disable(:approval_policy_dependency_scanning_filters) # ApprovalPolicySource#scanner_configurations omits dependency_change and dependency_type Feature.enable(:approval_policy_dependency_scanning_filters) # ApprovalPolicySource#scanner_configurations includes them - Save a policy in YAML mode with
dependency_change: introducedon adependency_scanningscanner. It is accepted. The same setting onsastis rejected.
MR stack
This MR is part of a stack of 4 that replaces one 760-line MR. Each MR targets the previous branch (linear chain), so every diff only shows its own change. Merge in order; retarget each MR to master after the one below it merges.
- This MR:
635482-ds-dependency-change-filter(!264451 (merged)): schemas, config plumbing, feature flag. Targetsmaster. 635482-ds-dependency-filter-class(!267117 (merged)):DependencyFilterand theSecurity::Findingscope, unreferenced. Targets the branch above.635482-ds-dependency-filter-wiring(!267118 (merged)): wires the filter into evaluation. Targets the branch above.635482-ds-dependency-filter-docs(!267119 (merged)): documentation. Targets the branch above.
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.