-
-
Save nscuro/cf97dfb4ae07b835ca721aafa7ac48f8 to your computer and use it in GitHub Desktop.
Dependency-Track GHSA Cleanup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION "delete_ghsa_vulnerabilities"() RETURNS BOOLEAN | |
LANGUAGE "plpgsql" | |
AS | |
$$ | |
DECLARE "v_vulnerability_id" BIGINT; | |
BEGIN | |
FOR "v_vulnerability_id" IN SELECT "ID" FROM "VULNERABILITY" WHERE "VULNID" LIKE 'GHSA-%' | |
LOOP | |
IF "v_vulnerability_id" IS NOT NULL THEN | |
DELETE FROM "AFFECTEDVERSIONATTRIBUTION" | |
WHERE "VULNERABILITY" = "v_vulnerability_id"; | |
DELETE FROM "ANALYSISCOMMENT" | |
USING "ANALYSIS" | |
WHERE "ANALYSISCOMMENT"."ANALYSIS_ID" = "ANALYSIS"."ID" | |
AND "ANALYSIS"."VULNERABILITY_ID" = "v_vulnerability_id"; | |
DELETE FROM "ANALYSIS" | |
WHERE "VULNERABILITY_ID" = "v_vulnerability_id"; | |
DELETE FROM "COMPONENTS_VULNERABILITIES" | |
WHERE "VULNERABILITY_ID" = "v_vulnerability_id"; | |
DELETE FROM "SERVICECOMPONENTS_VULNERABILITIES" | |
WHERE "VULNERABILITY_ID" = "v_vulnerability_id"; | |
DELETE FROM "FINDINGATTRIBUTION" | |
WHERE "VULNERABILITY_ID" = "v_vulnerability_id"; | |
DELETE FROM "VULNERABLESOFTWARE_VULNERABILITIES" | |
WHERE "VULNERABILITY_ID" = "v_vulnerability_id"; | |
DELETE FROM "VULNERABILITY" | |
WHERE "ID" = "v_vulnerability_id"; | |
END IF; | |
END LOOP; | |
RETURN TRUE; | |
END; | |
$$; | |
BEGIN; | |
SELECT "delete_ghsa_vulnerabilities"(); | |
COMMIT; | |
DROP FUNCTION "delete_ghsa_vulnerabilities"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment