Return every denied rule and non-excepted advisories from evaluation

What does this MR do and why?

This MR is part of work item https://gitlab.com/gitlab-org/gitlab/-/work_items/627538. The former Part 2 was split into three MRs; this one covers rule evaluation. MR A, write buffer and flush worker (!257625 (merged)), is independent. MR C, enforcement hook (!253944 (merged)), needs both.

There are no migrations, no UI changes, and no changelog entry. This MR is not behind a feature flag and needs none: no existing behaviour changes.

PolicyEvaluator now also returns matched_rules: every denied rule for a package, not just the first. This is additive: matched_rule is unchanged, and nothing reads matched_rules until MR C.

Security::DependencyFirewallPolicies::Rule#non_excepted_vulnerabilities returns the advisories a rule weighs, with id-based exceptions removed; purl exceptions do not affect it. MR C uses it to pick the ledger severity. VulnerabilityRule and RiskSeverityRule each had a private copy of this filter; both now call it, giving one implementation in the base class with memoized exception ids and unchanged behaviour.

Testing

56 examples across the policy evaluator spec (31) and rule spec (25) pass locally, as do the existing vulnerability rule, risk severity rule and enforcement service specs, unchanged. RuboCop clean.

References

Screenshots or screen recordings

Not applicable, no UI changes.

How to set up and validate locally

This change has no user-visible effect on its own and is covered by specs:

bin/rspec ee/spec/services/security/dependency_firewall/policy_evaluator_spec.rb ee/spec/lib/security/dependency_firewall_policies/rule_spec.rb

The existing vulnerability_rule_spec.rb and risk_severity_rule_spec.rb cover the refactored subclasses.

Optionally, in bin/rails console, evaluate a package against a policy with two denying rules and see both in matched_rules.

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.

Edited by Arpit Gogia

Merge request reports

Loading
Loading