diff --git a/commands/curation/curationaudit.go b/commands/curation/curationaudit.go index 09b48796..b2e05687 100644 --- a/commands/curation/curationaudit.go +++ b/commands/curation/curationaudit.go @@ -269,7 +269,7 @@ func convertBlocked(pkgStatus []*PackageStatus) formats.TwoLevelSummaryCount { if _, ok := blocked[polAndCond]; !ok { blocked[polAndCond] = formats.SummaryCount{} } - uniqId := uniqPkgAppearanceId(pkg.ParentName, pkg.ParentVersion, pkg.PackageName, pkg.PackageVersion) + uniqId := getPackageId(pkg.PackageName, pkg.PackageVersion) blocked[polAndCond][uniqId]++ } } @@ -280,10 +280,9 @@ func formatPolicyAndCond(policy, cond string) string { return fmt.Sprintf("Policy: %s, Condition: %s", policy, cond) } -// The unique identifier of a package includes both the package name with its version and the parent package with its version -func uniqPkgAppearanceId(parentName, parentVersion, packageName, packageVersion string) string { - return fmt.Sprintf("%s:%s-%s:%s", - parentName, parentVersion, packageName, packageVersion) +// The unique identifier of a package includes the package name with its version +func getPackageId(packageName, packageVersion string) string { + return fmt.Sprintf("%s:%s", packageName, packageVersion) } func (ca *CurationAuditCommand) doCurateAudit(results map[string]*CurationReport) error { diff --git a/commands/curation/curationaudit_test.go b/commands/curation/curationaudit_test.go index 3beb3e91..5777bc91 100644 --- a/commands/curation/curationaudit_test.go +++ b/commands/curation/curationaudit_test.go @@ -889,7 +889,7 @@ func Test_convertResultsToSummary(t *testing.T) { CuratedPackages: &formats.CuratedPackages{ Blocked: formats.TwoLevelSummaryCount{ formatPolicyAndCond("policy1", "cond1"): formats.SummaryCount{ - uniqPkgAppearanceId("parent-test1", "1.0.0", "test1", "1.0.0"): 1, + getPackageId("test1", "1.0.0"): 1, }, }, Approved: 4, @@ -960,12 +960,12 @@ func Test_convertResultsToSummary(t *testing.T) { CuratedPackages: &formats.CuratedPackages{ Blocked: formats.TwoLevelSummaryCount{ formatPolicyAndCond("policy1", "cond1"): formats.SummaryCount{ - uniqPkgAppearanceId("parent-test1", "1.0.0", "test1", "1.0.0"): 1, + getPackageId("test1", "1.0.0"): 1, }, formatPolicyAndCond("policy2", "cond2"): formats.SummaryCount{ - uniqPkgAppearanceId("parent-test1", "1.0.0", "test1", "1.0.0"): 1, - uniqPkgAppearanceId("parent-test2", "2.0.0", "test2", "2.0.0"): 1, - uniqPkgAppearanceId("parent-test3", "3.0.0", "test3", "3.0.0"): 1, + getPackageId("test1", "1.0.0"): 1, + getPackageId("test2", "2.0.0"): 1, + getPackageId("test3", "3.0.0"): 1, }, }, Approved: 2, diff --git a/formats/summary.go b/formats/summary.go index 159027bc..ce546aaa 100644 --- a/formats/summary.go +++ b/formats/summary.go @@ -95,7 +95,7 @@ func (s *ScanVulnerabilitiesSummary) GetTotalIssueCount() (total int) { } func (s *CuratedPackages) GetTotalPackages() int { - return s.Approved + s.Blocked.GetTotal() + return s.Approved + s.Blocked.GetCountOfKeys(false) } func (s *ScanVulnerabilitiesSummary) getTotalIssueCount(unique bool) (total int) { diff --git a/tests/testdata/other/jobSummary/multi_command_job.md b/tests/testdata/other/jobSummary/multi_command_job.md index 5ee6abd6..f383ea6b 100644 --- a/tests/testdata/other/jobSummary/multi_command_job.md +++ b/tests/testdata/other/jobSummary/multi_command_job.md @@ -17,5 +17,5 @@ #### Curation | Status | Id | Details | |--------|----|---------| -| ❌ | /application1 |
Total number of packages: 6
🟢 Total Number of Approved: 4
🔴 Total Number of Blocked: 2
├── Policy: cvss_score, Condition:cvss score higher than 4.0 (1)
└── Policy: Malicious, Condition: Malicious package (1)
| -| ❌ | /application2 |
Total number of packages: 6
🟢 Total Number of Approved: 4
🔴 Total Number of Blocked: 2
├── Policy: License, Condition: GPL (1)
└── Policy: Aged, Condition: Package is aged (1)
| \ No newline at end of file +| ❌ | /application1 |
Total Number of Packages: 6
🟢 Total Number of Approved Packages: 4
🔴 Total Number of Blocked Packages: 2
├── Policy: cvss_score, Condition:cvss score higher than 4.0 (1)
└── Policy: Malicious, Condition: Malicious package (1)
| +| ❌ | /application2 |
Total Number of Packages: 6
🟢 Total Number of Approved Packages: 4
🔴 Total Number of Blocked Packages: 2
├── Policy: License, Condition: GPL (1)
└── Policy: Aged, Condition: Package is aged (1)
| \ No newline at end of file diff --git a/utils/securityJobSummary.go b/utils/securityJobSummary.go index 8493fe53..f94724c9 100644 --- a/utils/securityJobSummary.go +++ b/utils/securityJobSummary.go @@ -206,9 +206,9 @@ func getBlockedCurationSummaryString(summary formats.ScanSummaryResult) (content if !summary.HasBlockedCuration() { return } - content += fmt.Sprintf("Total number of packages: %d", summary.CuratedPackages.GetTotalPackages()) - content += fmt.Sprintf("
🟢 Total Number of Approved: %d", summary.CuratedPackages.Approved) - content += fmt.Sprintf("
🔴 Total Number of Blocked: %d", summary.CuratedPackages.Blocked.GetTotal()) + content += fmt.Sprintf("Total Number of Packages: %d", summary.CuratedPackages.GetTotalPackages()) + content += fmt.Sprintf("
🟢 Total Number of Approved Packages: %d", summary.CuratedPackages.Approved) + content += fmt.Sprintf("
🔴 Total Number of Blocked Packages: %d", summary.CuratedPackages.Blocked.GetCountOfKeys(false)) if summary.CuratedPackages.Blocked.GetTotal() > 0 { var blocked []struct { BlockedName string