Skip to content

Commit caa0cb0

Browse files
committed
feat: reduce VulnerabilityReport size by omitting empty fields
1 parent 6345f00 commit caa0cb0

File tree

6 files changed

+9
-35
lines changed

6 files changed

+9
-35
lines changed

deploy/helm/crds/aquasecurity.github.io_clustervulnerabilityreports.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,7 @@ spec:
269269
description: VulnerabilityID the vulnerability identifier.
270270
type: string
271271
required:
272-
- fixedVersion
273-
- installedVersion
274-
- lastModifiedDate
275-
- publishedDate
276-
- resource
277272
- severity
278-
- title
279273
- vulnerabilityID
280274
type: object
281275
type: array

deploy/helm/crds/aquasecurity.github.io_vulnerabilityreports.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,7 @@ spec:
270270
description: VulnerabilityID the vulnerability identifier.
271271
type: string
272272
required:
273-
- fixedVersion
274-
- installedVersion
275-
- lastModifiedDate
276-
- publishedDate
277-
- resource
278273
- severity
279-
- title
280274
- vulnerabilityID
281275
type: object
282276
type: array

deploy/static/trivy-operator.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,13 +1476,7 @@ spec:
14761476
description: VulnerabilityID the vulnerability identifier.
14771477
type: string
14781478
required:
1479-
- fixedVersion
1480-
- installedVersion
1481-
- lastModifiedDate
1482-
- publishedDate
1483-
- resource
14841479
- severity
1485-
- title
14861480
- vulnerabilityID
14871481
type: object
14881482
type: array
@@ -2916,13 +2910,7 @@ spec:
29162910
description: VulnerabilityID the vulnerability identifier.
29172911
type: string
29182912
required:
2919-
- fixedVersion
2920-
- installedVersion
2921-
- lastModifiedDate
2922-
- publishedDate
2923-
- resource
29242913
- severity
2925-
- title
29262914
- vulnerabilityID
29272915
type: object
29282916
type: array

pkg/apis/aquasecurity/v1alpha1/vulnerability_types.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,29 +83,29 @@ type Vulnerability struct {
8383
VulnerabilityID string `json:"vulnerabilityID"`
8484

8585
// Resource is a vulnerable package, application, or library.
86-
Resource string `json:"resource"`
86+
Resource string `json:"resource,omitempty"`
8787

8888
// InstalledVersion indicates the installed version of the Resource.
89-
InstalledVersion string `json:"installedVersion"`
89+
InstalledVersion string `json:"installedVersion,omitempty"`
9090

9191
// FixedVersion indicates the version of the Resource in which this vulnerability has been fixed.
92-
FixedVersion string `json:"fixedVersion"`
92+
FixedVersion string `json:"fixedVersion,omitempty"`
9393
// PublishedDate indicates the date of published CVE.
94-
PublishedDate string `json:"publishedDate"`
94+
PublishedDate string `json:"publishedDate,omitempty"`
9595
// LastModifiedDate indicates the last date CVE has been modified.
96-
LastModifiedDate string `json:"lastModifiedDate"`
96+
LastModifiedDate string `json:"lastModifiedDate,omitempty"`
9797
// Severity level of a vulnerability or a configuration audit check.
9898
// +kubebuilder:validation:Enum={CRITICAL,HIGH,MEDIUM,LOW,UNKNOWN}
9999
Severity Severity `json:"severity"`
100-
Title string `json:"title"`
100+
Title string `json:"title,omitempty"`
101101
Description string `json:"description,omitempty"`
102102
CVSSSource string `json:"cvsssource,omitempty"`
103103
PrimaryLink string `json:"primaryLink,omitempty"`
104104
// +optional
105-
Links []string `json:"links"`
105+
Links []string `json:"links,omitempty"`
106106
Score *float64 `json:"score,omitempty"`
107107
// +optional
108-
Target string `json:"target"`
108+
Target string `json:"target,omitempty"`
109109
// +optional
110110
CVSS types.VendorCVSS `json:"cvss,omitempty"`
111111
// +optional

pkg/plugins/trivy/plugin_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7165,7 +7165,6 @@ var (
71657165
Severity: v1alpha1.SeverityMedium,
71667166
Title: "openssl: information disclosure in fork()",
71677167
PrimaryLink: "https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-1549",
7168-
Links: []string{},
71697168
},
71707169
{
71717170
VulnerabilityID: "CVE-2019-1547",
@@ -7175,7 +7174,6 @@ var (
71757174
Severity: v1alpha1.SeverityLow,
71767175
Title: "openssl: side-channel weak encryption vulnerability",
71777176
PrimaryLink: "https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-1547",
7178-
Links: []string{},
71797177
},
71807178
},
71817179
}

pkg/webhook/webhookreporter_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func Test_sendReports(t *testing.T) {
2525
}{
2626
{
2727
name: "happy path, vuln report data",
28-
want: `{"metadata":{},"report":{"updateTimestamp":null,"scanner":{"name":"","vendor":"","version":""},"registry":{"server":""},"artifact":{"repository":""},"os":{"family":""},"summary":{"criticalCount":0,"highCount":0,"mediumCount":0,"lowCount":0,"unknownCount":0,"noneCount":0},"vulnerabilities":[{"vulnerabilityID":"CVE-2022-1234","resource":"","installedVersion":"1.2.3","fixedVersion":"3.4.5","severity":"CRITICAL","title":"foo bar very baz", "lastModifiedDate":"", "links":null, "publishedDate":"", "target":"","class":"os-pkgs"}]}}`,
28+
want: `{"metadata":{},"report":{"updateTimestamp":null,"scanner":{"name":"","vendor":"","version":""},"registry":{"server":""},"artifact":{"repository":""},"os":{"family":""},"summary":{"criticalCount":0,"highCount":0,"mediumCount":0,"lowCount":0,"unknownCount":0,"noneCount":0},"vulnerabilities":[{"vulnerabilityID":"CVE-2022-1234","installedVersion":"1.2.3","fixedVersion":"3.4.5","severity":"CRITICAL","title":"foo bar very baz", "class":"os-pkgs"}]}}`,
2929
inputReport: v1alpha1.VulnerabilityReport{
3030
Report: v1alpha1.VulnerabilityReportData{
3131
Vulnerabilities: []v1alpha1.Vulnerability{

0 commit comments

Comments
 (0)