Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/harbor/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ type VulnerabilityItem struct {
ID string `json:"id"`
Pkg string `json:"package"`
Version string `json:"version"`
Status string `json:"status,omitempty"`
FixVersion string `json:"fix_version,omitempty"`
Severity Severity `json:"severity"`
Description string `json:"description"`
Expand Down
1 change: 1 addition & 0 deletions pkg/scan/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func (t *transformer) transformVulnerabilities(source []trivy.Vulnerability) []h
ID: v.VulnerabilityID,
Pkg: v.PkgName,
Version: v.InstalledVersion,
Status: v.Status,
FixVersion: v.FixedVersion,
Severity: t.toHarborSeverity(v.Severity),
Description: v.Description,
Expand Down
8 changes: 8 additions & 0 deletions pkg/scan/transformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func TestTransformer_Transform(t *testing.T) {
PkgName: "PKG-01",
InstalledVersion: "PKG-01-VER",
FixedVersion: "PKG-01-FIX-VER",
Status: "fixed",
Severity: "CRITICAL",
Description: "CVE-0000-0001.DESC",
References: []string{
Expand Down Expand Up @@ -72,6 +73,7 @@ func TestTransformer_Transform(t *testing.T) {
PkgName: "PKG-02",
InstalledVersion: "PKG-02-VER",
FixedVersion: "",
Status: "won't fix",
Severity: "HIGH",
Description: "CVE-0000-0002.DESC",
References: []string{
Expand All @@ -85,6 +87,7 @@ func TestTransformer_Transform(t *testing.T) {
VulnerabilityID: "CVE-0000-0003",
PkgName: "PKG-03",
InstalledVersion: "PKG-03-VER",
Status: "fixed",
FixedVersion: "PKG-03-FIX-VER",
Severity: "MEDIUM",
Description: "CVE-0000-0003.DESC",
Expand All @@ -101,6 +104,7 @@ func TestTransformer_Transform(t *testing.T) {
PkgName: "PKG-04",
InstalledVersion: "PKG-04-VER",
FixedVersion: "PKG-04-FIX-VER",
Status: "fixed",
Severity: "LOW",
Description: "CVE-0000-0004.DESC",
References: []string{
Expand Down Expand Up @@ -144,6 +148,7 @@ func TestTransformer_Transform(t *testing.T) {
ID: "CVE-0000-0001",
Pkg: "PKG-01",
Version: "PKG-01-VER",
Status: "fixed",
FixVersion: "PKG-01-FIX-VER",
Severity: harbor.SevCritical,
Description: "CVE-0000-0001.DESC",
Expand Down Expand Up @@ -173,6 +178,7 @@ func TestTransformer_Transform(t *testing.T) {
ID: "CVE-0000-0002",
Pkg: "PKG-02",
Version: "PKG-02-VER",
Status: "won't fix",
FixVersion: "",
Severity: harbor.SevHigh,
Description: "CVE-0000-0002.DESC",
Expand All @@ -188,6 +194,7 @@ func TestTransformer_Transform(t *testing.T) {
ID: "CVE-0000-0003",
Pkg: "PKG-03",
Version: "PKG-03-VER",
Status: "fixed",
FixVersion: "PKG-03-FIX-VER",
Severity: harbor.SevMedium,
Description: "CVE-0000-0003.DESC",
Expand All @@ -203,6 +210,7 @@ func TestTransformer_Transform(t *testing.T) {
ID: "CVE-0000-0004",
Pkg: "PKG-04",
Version: "PKG-04-VER",
Status: "fixed",
FixVersion: "PKG-04-FIX-VER",
Severity: harbor.SevLow,
Description: "CVE-0000-0004.DESC",
Expand Down
1 change: 1 addition & 0 deletions pkg/trivy/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type Vulnerability struct {
VulnerabilityID string `json:"VulnerabilityID"`
PkgName string `json:"PkgName"`
InstalledVersion string `json:"InstalledVersion"`
Status string `json:"Status"`
Copy link

Copilot AI Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider defining constants for the valid status values (e.g., "fixed", "won't fix") and using them here and in tests to avoid scattering magic strings.

Suggested change
Status string `json:"Status"`
Status string `json:"Status"` // Use constants like StatusFixed, StatusWontFix, etc.

Copilot uses AI. Check for mistakes.
FixedVersion string `json:"FixedVersion"`
Title string `json:"Title"`
Description string `json:"Description"`
Expand Down
3 changes: 3 additions & 0 deletions test/integration/api/rest_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ func TestRestAPI(t *testing.T) {
Pkg: "musl",
Version: "1.1.22-r4",
FixVersion: "1.1.22-r5",
Status: "fixed",
Severity: harbor.SevMedium,
Description: "In musl libc through 1.2.1, wcsnrtombs mishandles particular combinations of destination buffer size and source character limit, as demonstrated by an invalid write access (buffer overflow).",
Links: []string{
Expand All @@ -161,6 +162,7 @@ func TestRestAPI(t *testing.T) {
Pkg: "musl-utils",
Version: "1.1.22-r4",
FixVersion: "1.1.22-r5",
Status: "fixed",
Severity: harbor.SevMedium,
Description: "In musl libc through 1.2.1, wcsnrtombs mishandles particular combinations of destination buffer size and source character limit, as demonstrated by an invalid write access (buffer overflow).",
Links: []string{
Expand Down Expand Up @@ -335,6 +337,7 @@ func TestRestAPI(t *testing.T) {
Pkg: "libssl1.1",
Version: "1.1.1c-r0",
FixVersion: "1.1.1d-r0",
Status: "fixed",
Severity: harbor.SevMedium,
Description: "OpenSSL 1.1.1 introduced a rewritten random number generator (RNG). This was intended to include protection in the event of a fork() system call in order to ensure that the parent and child processes did not share the same RNG state. However this protection was not being used in the default case. A partial mitigation for this issue is that the output from a high precision timer is mixed into the RNG state so the likelihood of a parent and child process sharing state is significantly reduced. If an application already calls OPENSSL_init_crypto() explicitly using OPENSSL_INIT_ATFORK then this problem does not occur at all. Fixed in OpenSSL 1.1.1d (Affected 1.1.1-1.1.1c).",
Links: []string{
Expand Down
Loading