Skip to content

Commit 9251aa4

Browse files
committed
feat: reduce VulnerabilityReport size by omitting empty fields
1 parent 113c53a commit 9251aa4

File tree

6 files changed

+38
-68
lines changed

6 files changed

+38
-68
lines changed

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

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

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

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

deploy/static/trivy-operator.yaml

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,13 +1476,6 @@ spec:
14761476
description: VulnerabilityID the vulnerability identifier.
14771477
type: string
14781478
required:
1479-
- fixedVersion
1480-
- installedVersion
1481-
- lastModifiedDate
1482-
- publishedDate
1483-
- resource
1484-
- severity
1485-
- title
14861479
- vulnerabilityID
14871480
type: object
14881481
type: array
@@ -2916,13 +2909,6 @@ spec:
29162909
description: VulnerabilityID the vulnerability identifier.
29172910
type: string
29182911
required:
2919-
- fixedVersion
2920-
- installedVersion
2921-
- lastModifiedDate
2922-
- publishedDate
2923-
- resource
2924-
- severity
2925-
- title
29262912
- vulnerabilityID
29272913
type: object
29282914
type: array
@@ -3204,6 +3190,25 @@ spec:
32043190
app.kubernetes.io/instance: trivy-operator
32053191
type: ClusterIP
32063192
---
3193+
# Source: trivy-operator/templates/rbac/clusterrolebinding.yaml
3194+
apiVersion: rbac.authorization.k8s.io/v1
3195+
kind: ClusterRoleBinding
3196+
metadata:
3197+
name: trivy-operator
3198+
labels:
3199+
app.kubernetes.io/name: trivy-operator
3200+
app.kubernetes.io/instance: trivy-operator
3201+
app.kubernetes.io/version: "0.29.0"
3202+
app.kubernetes.io/managed-by: kubectl
3203+
roleRef:
3204+
apiGroup: rbac.authorization.k8s.io
3205+
kind: ClusterRole
3206+
name: trivy-operator
3207+
subjects:
3208+
- kind: ServiceAccount
3209+
name: trivy-operator
3210+
namespace: trivy-system
3211+
---
32073212
# Source: trivy-operator/templates/rbac/clusterrole.yaml
32083213
apiVersion: rbac.authorization.k8s.io/v1
32093214
kind: ClusterRole
@@ -3355,20 +3360,21 @@ rules:
33553360
verbs:
33563361
- get
33573362
---
3358-
# Source: trivy-operator/templates/rbac/clusterrolebinding.yaml
3363+
# Source: trivy-operator/templates/rbac/leader-election-rolebinding.yaml
33593364
apiVersion: rbac.authorization.k8s.io/v1
3360-
kind: ClusterRoleBinding
3365+
kind: RoleBinding
33613366
metadata:
3362-
name: trivy-operator
3367+
name: trivy-operator-leader-election
3368+
namespace: trivy-system
33633369
labels:
33643370
app.kubernetes.io/name: trivy-operator
33653371
app.kubernetes.io/instance: trivy-operator
33663372
app.kubernetes.io/version: "0.29.0"
33673373
app.kubernetes.io/managed-by: kubectl
33683374
roleRef:
33693375
apiGroup: rbac.authorization.k8s.io
3370-
kind: ClusterRole
3371-
name: trivy-operator
3376+
kind: Role
3377+
name: trivy-operator-leader-election
33723378
subjects:
33733379
- kind: ServiceAccount
33743380
name: trivy-operator
@@ -3402,11 +3408,11 @@ rules:
34023408
verbs:
34033409
- create
34043410
---
3405-
# Source: trivy-operator/templates/rbac/leader-election-rolebinding.yaml
3411+
# Source: trivy-operator/templates/rbac/rolebinding.yaml
34063412
apiVersion: rbac.authorization.k8s.io/v1
34073413
kind: RoleBinding
34083414
metadata:
3409-
name: trivy-operator-leader-election
3415+
name: trivy-operator
34103416
namespace: trivy-system
34113417
labels:
34123418
app.kubernetes.io/name: trivy-operator
@@ -3416,7 +3422,7 @@ metadata:
34163422
roleRef:
34173423
apiGroup: rbac.authorization.k8s.io
34183424
kind: Role
3419-
name: trivy-operator-leader-election
3425+
name: trivy-operator
34203426
subjects:
34213427
- kind: ServiceAccount
34223428
name: trivy-operator
@@ -3453,26 +3459,6 @@ rules:
34533459
- delete
34543460
- update
34553461
---
3456-
# Source: trivy-operator/templates/rbac/rolebinding.yaml
3457-
apiVersion: rbac.authorization.k8s.io/v1
3458-
kind: RoleBinding
3459-
metadata:
3460-
name: trivy-operator
3461-
namespace: trivy-system
3462-
labels:
3463-
app.kubernetes.io/name: trivy-operator
3464-
app.kubernetes.io/instance: trivy-operator
3465-
app.kubernetes.io/version: "0.29.0"
3466-
app.kubernetes.io/managed-by: kubectl
3467-
roleRef:
3468-
apiGroup: rbac.authorization.k8s.io
3469-
kind: Role
3470-
name: trivy-operator
3471-
subjects:
3472-
- kind: ServiceAccount
3473-
name: trivy-operator
3474-
namespace: trivy-system
3475-
---
34763462
# Source: trivy-operator/templates/rbac/view-configauditreports-clusterrole.yaml
34773463
# permissions for end users to view configauditreports
34783464
apiVersion: rbac.authorization.k8s.io/v1

pkg/apis/aquasecurity/v1alpha1/vulnerability_types.go

Lines changed: 9 additions & 9 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}
99-
Severity Severity `json:"severity"`
100-
Title string `json:"title"`
99+
Severity Severity `json:"severity,omitempty"`
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)