Fix wrong scanned artifact count when there are multiple report for an artifact (#18975)

Signed-off-by: stonezdj <daojunz@vmware.com>
This commit is contained in:
stonezdj(Daojun Zhang) 2023-07-25 14:10:10 +08:00 committed by GitHub
parent d7ff8bf55e
commit d92aca9d39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -48,10 +48,9 @@ order by s.critical_cnt desc, s.high_cnt desc, s.medium_cnt desc, s.low_cnt desc
limit 5`
// sql to query the scanned artifact count
scannedArtifactCountSQL = `select count(1)
from artifact a
left join scan_report s on a.digest = s.digest
where s.registration_uuid= ? and s.uuid is not null`
scannedArtifactCountSQL = `select count(1)
from artifact
where exists (select 1 from scan_report s where artifact.digest = s.digest and s.registration_uuid = ?) `
// sql to query the dangerous CVEs
dangerousCVESQL = `select vr.*

View File

@ -68,6 +68,7 @@ func (suite *SecurityDaoTestSuite) TearDownTest() {
`delete from scan_report where uuid = 'uuid'`,
`delete from artifact where digest = 'digest1001'`,
`delete from scanner_registration where uuid='ruuid'`,
`delete from scanner_registration where uuid='uuid2'`,
`delete from vulnerability_record where cve_id='2023-4567-12345'`,
`delete from report_vulnerability_record where report_uuid='ruuid'`,
`delete from vulnerability_record where registration_uuid ='uuid2'`,