Vuln dashboard: Update query to find Vulnerability records with no associated VulnerabilityInstall records. (#20203)
Related to: https://github.com/fleetdm/confidential/issues/7180 Changes: - Updated the `nativeQueryToFindVulnsWithNoAssociatedRecords` query to improve the performance of the update-reports script on large deployments
This commit is contained in:
@@ -906,12 +906,10 @@ module.exports = {
|
||||
|
||||
// Check for Vulnerabilities that have no associated Host or VulnerabilityInstall records.
|
||||
let nativeQueryToFindVulnsWithNoAssociatedRecords =
|
||||
`SELECT id
|
||||
FROM vulnerability
|
||||
WHERE id NOT IN (
|
||||
SELECT vulnerability
|
||||
FROM vulnerabilityinstall
|
||||
);`;
|
||||
`SELECT v.id
|
||||
FROM vulnerability v
|
||||
LEFT JOIN vulnerabilityinstall vi ON v.id = vi.vulnerability
|
||||
WHERE vi.vulnerability IS NULL;`;
|
||||
let rawResultFromDatabase = await sails.sendNativeQuery(nativeQueryToFindVulnsWithNoAssociatedRecords);
|
||||
let vulnerabilityRecordIdsWithNoAssociatedRecords = rawResultFromDatabase.rows;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user