Fix `Vulnerability-Check` approval rule logic
What does this MR do?
The documentation for Vulnerability-Check
merge request approval rule clearly states that the rule will take place if there are new critical, high or unknown severity findings.
See the docs for more information: https://docs.gitlab.com/ee/user/application_security/index.html#enabling-security-approvals-within-a-project
An approval is required when a security report:
- Contains a new vulnerability of high, critical, or unknown severity, regardless of dismissal.
- Is not generated during pipeline execution.
This MR fixes the logic to check existing vulnerabilities for the project which isn't the case with the current implementation.
Related to #222643 (closed)
Acceptance Criteria
GIVEN we have an MR for a project with the Vulnerability-Check
approval rule is enabled
-
WHEN there is an unsafe severity(critical, medium, unknown) finding in security report of MR pipeline
-
WHEN there is no pipeline for the target branch
-
THEN the
Vulnerability-Check
approval rule is required
-
THEN the
-
WHEN there is a pipeline for the target branch
-
WHEN the target branch's pipeline does not have security reports
-
THEN the
Vulnerability-Check
approval rule is required
-
THEN the
-
WHEN target branch's pipeline has security reports
-
WHEN the unsafe findings are not detected in target branch's security report
-
THEN the
Vulnerability-Check
approval rule is required
-
THEN the
-
WHEN the unsafe findings are already detected in target branch's security report
-
THEN the
Vulnerability-Check
approval rule is NOT required
-
THEN the
-
WHEN the unsafe findings are not detected in target branch's security report
-
WHEN the target branch's pipeline does not have security reports
-
WHEN there is no pipeline for the target branch
-
WHEN there is not any unsafe severity(critical, medium, unknown) finding in security report of MR pipeline
-
THEN the
Vulnerability-Check
approval rule is NOT required
-
THEN the
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry - [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides - [-] Database guides
-
Separation of EE specific content
Availability and Testing
- [-] Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process.
- [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team