From a96a61e8270f7d5feae1c58063ad9e81c97503a7 Mon Sep 17 00:00:00 2001 From: memeeerit Date: Mon, 13 Nov 2023 17:55:54 -0500 Subject: [PATCH] delete old ssvc upon new one --- .../src/main/java/edu/rit/se/nvip/DatabaseHelper.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/reconciler/src/main/java/edu/rit/se/nvip/DatabaseHelper.java b/reconciler/src/main/java/edu/rit/se/nvip/DatabaseHelper.java index 1cd8d49d8..0043cd664 100644 --- a/reconciler/src/main/java/edu/rit/se/nvip/DatabaseHelper.java +++ b/reconciler/src/main/java/edu/rit/se/nvip/DatabaseHelper.java @@ -799,9 +799,15 @@ public boolean exploitExists(String cveId) { } public void insertSSVCSet(Set vulns) { - try (Connection conn = getConnection(); PreparedStatement pstmt = conn.prepareStatement(INSERT_SSVC)) { + String deleteOldSSVC = "DELETE FROM ssvc WHERE cve_id = ?"; + try (Connection conn = getConnection(); PreparedStatement pstmt = conn.prepareStatement(INSERT_SSVC); + PreparedStatement deleteStmt = conn.prepareStatement(deleteOldSSVC)) { conn.setAutoCommit(false); for (CompositeVulnerability vuln : vulns) { + deleteStmt.setString(1, vuln.getCveId()); + deleteStmt.executeUpdate(); + + // Get SSVC data final SSVC ssvc = vuln.getSSVC();