Skip to content

Commit 52ce6bc

Browse files
authored
fix: engine is invalid when name is missing (gocsaf#710)
1 parent 9393271 commit 52ce6bc

File tree

3 files changed

+177
-7
lines changed

3 files changed

+177
-7
lines changed

csaf/advisory.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,8 +891,8 @@ func (rs Revisions) Validate() error {
891891

892892
// Validate validates an Engine.
893893
func (e *Engine) Validate() error {
894-
if e.Version == nil {
895-
return errors.New("'version' is missing")
894+
if e.Name == nil {
895+
return errors.New("'name' is missing")
896896
}
897897
return nil
898898
}

csaf/advisory_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ func TestLoadAdvisory(t *testing.T) {
1414
name string
1515
args args
1616
wantErr bool
17-
}{{
18-
name: "Valid documents",
19-
args: args{jsonDir: "csaf-documents/valid"},
20-
wantErr: false,
21-
},
17+
}{
18+
{
19+
name: "Valid documents",
20+
args: args{jsonDir: "csaf-documents/valid"},
21+
wantErr: false,
22+
},
2223
{
2324
name: "Garbage trailing data",
2425
args: args{jsonDir: "csaf-documents/trailing-garbage-data"},
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
{
2+
"document": {
3+
"category": "csaf_vex",
4+
"csaf_version": "2.0",
5+
"distribution": {
6+
"tlp": {
7+
"label": "WHITE",
8+
"url": "https://www.first.org/tlp/v1/"
9+
}
10+
},
11+
"notes": [
12+
{
13+
"category": "summary",
14+
"title": "Test document summary",
15+
"text": "Auto generated test CSAF document"
16+
}
17+
],
18+
"publisher": {
19+
"category": "vendor",
20+
"name": "ACME Inc.",
21+
"namespace": "https://www.example.com"
22+
},
23+
"title": "Test CSAF document",
24+
"tracking": {
25+
"current_release_date": "2020-01-01T00:00:00Z",
26+
"generator": {
27+
"date": "2020-01-01T00:00:00Z",
28+
"engine": {
29+
"name": "csaf-tool"
30+
}
31+
},
32+
"id": "Avendor-advisory-0004",
33+
"initial_release_date": "2020-01-01T00:00:00Z",
34+
"revision_history": [
35+
{
36+
"date": "2020-01-01T00:00:00Z",
37+
"number": "1",
38+
"summary": "Initial version"
39+
}
40+
],
41+
"status": "final",
42+
"version": "1"
43+
}
44+
},
45+
"product_tree": {
46+
"branches": [
47+
{
48+
"category": "vendor",
49+
"name": "AVendor",
50+
"branches": [
51+
{
52+
"category": "product_name",
53+
"name": "product_1",
54+
"branches": [
55+
{
56+
"category": "product_version",
57+
"name": "1.1",
58+
"product": {
59+
"name": "AVendor product_1 1.1",
60+
"product_id": "CSAFPID_0001"
61+
}
62+
},
63+
{
64+
"category": "product_version",
65+
"name": "1.2",
66+
"product": {
67+
"name": "AVendor product_1 1.2",
68+
"product_id": "CSAFPID_0002"
69+
}
70+
},
71+
{
72+
"category": "product_version",
73+
"name": "2.0",
74+
"product": {
75+
"name": "AVendor product_1 2.0",
76+
"product_id": "CSAFPID_0003"
77+
}
78+
}
79+
]
80+
}
81+
]
82+
},
83+
{
84+
"category": "vendor",
85+
"name": "AVendor1",
86+
"branches": [
87+
{
88+
"category": "product_name",
89+
"name": "product_2",
90+
"branches": [
91+
{
92+
"category": "product_version",
93+
"name": "1",
94+
"product": {
95+
"name": "AVendor1 product_2 1",
96+
"product_id": "CSAFPID_0004"
97+
}
98+
}
99+
]
100+
}
101+
]
102+
},
103+
{
104+
"category": "vendor",
105+
"name": "AVendor",
106+
"branches": [
107+
{
108+
"category": "product_name",
109+
"name": "product_3",
110+
"branches": [
111+
{
112+
"category": "product_version",
113+
"name": "2022H2",
114+
"product": {
115+
"name": "AVendor product_3 2022H2",
116+
"product_id": "CSAFPID_0005"
117+
}
118+
}
119+
]
120+
}
121+
]
122+
}
123+
]
124+
},
125+
"vulnerabilities": [
126+
{
127+
"cve": "CVE-2020-1234",
128+
"notes": [
129+
{
130+
"category": "description",
131+
"title": "CVE description",
132+
"text": "https://nvd.nist.gov/vuln/detail/CVE-2020-1234"
133+
}
134+
],
135+
"product_status": {
136+
"under_investigation": ["CSAFPID_0001"]
137+
},
138+
"threats": [
139+
{
140+
"category": "impact",
141+
"details": "Customers should upgrade to the latest version of the product",
142+
"date": "2020-01-01T00:00:00Z",
143+
"product_ids": ["CSAFPID_0001"]
144+
}
145+
]
146+
},
147+
{
148+
"cve": "CVE-2020-9876",
149+
"notes": [
150+
{
151+
"category": "description",
152+
"title": "CVE description",
153+
"text": "https://nvd.nist.gov/vuln/detail/CVE-2020-9876"
154+
}
155+
],
156+
"product_status": {
157+
"under_investigation": ["CSAFPID_0001"]
158+
},
159+
"threats": [
160+
{
161+
"category": "impact",
162+
"details": "Still under investigation",
163+
"date": "2020-01-01T00:00:00Z",
164+
"product_ids": ["CSAFPID_0001"]
165+
}
166+
]
167+
}
168+
]
169+
}

0 commit comments

Comments
 (0)