Skip to content

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
    • 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
      • 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
        • WHEN the unsafe findings are already detected in target branch's security report
          • THEN the Vulnerability-Check approval rule is NOT required
  • 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

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

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
Edited by Mehmet Emin INAC

Merge request reports