Auto-resolve vulnerabilities based on vulnerability management policy
What does this MR do and why?
This MR adds a new step to the vulnerability ingestion process that transitions the state of no longer detected vulnerabilities to resolved if a vulnerability management policy is configured and the vulnerability matches the criteria set in the policy.
Database queries
Get security policies affecting project:
SELECT
security_policies.id,
security_policies.security_orchestration_policy_configuration_id,
security_policies.created_at,
security_policies.updated_at,
security_policies.policy_index,
security_policies.type,
security_policies.enabled,
security_policies.name,
security_policies.description,
security_policies.checksum,
security_policies.scope,
security_policies.security_policy_management_project_id,
security_policies.content,
security_policies.metadata
FROM
security_policies
JOIN security_policy_project_links ON security_policies.id = security_policy_project_links.security_policy_id
WHERE
security_policy_project_links.project_id = 69 AND
security_policies.type = 3;
Get Security policy rules:
SELECT
vulnerability_management_policy_rules.*
FROM
vulnerability_management_policy_rules
WHERE
vulnerability_management_policy_rules.security_policy_id = 7 AND
rule_index >= 0 AND
vulnerability_management_policy_rules.type = 0;
Get unresolved vulnerability reads:
SELECT
vulnerability_reads.id,
vulnerability_reads.vulnerability_id,
vulnerability_reads.project_id,
vulnerability_reads.scanner_id,
vulnerability_reads.report_type,
vulnerability_reads.severity,
vulnerability_reads.state,
vulnerability_reads.has_issues,
vulnerability_reads.resolved_on_default_branch,
vulnerability_reads.uuid,
vulnerability_reads.location_image,
vulnerability_reads.cluster_agent_id,
vulnerability_reads.casted_cluster_agent_id,
vulnerability_reads.dismissal_reason,
vulnerability_reads.has_merge_request,
vulnerability_reads.has_remediations,
vulnerability_reads.owasp_top_10,
vulnerability_reads.traversal_ids,
vulnerability_reads.archived,
vulnerability_reads.identifier_names,
vulnerability_reads.has_vulnerability_resolution,
vulnerability_reads.auto_resolved
FROM
vulnerability_reads
WHERE
vulnerability_reads.vulnerability_id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100) AND
vulnerability_reads.state IN ( 1, 4, 2 );
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
| Before | After |
|---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.