Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add missing Properties #39

Merged
merged 8 commits into from May 20, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions cyclonedx.go
Expand Up @@ -626,6 +626,7 @@ type Vulnerability struct {
Tools *[]Tool `json:"tools,omitempty" xml:"tools>tool,omitempty"`
Analysis *VulnerabilityAnalysis `json:"analysis,omitempty" xml:"analysis,omitempty"`
Affects *[]Affects `json:"affects,omitempty" xml:"affects>target,omitempty"`
Properties *[]Property `json:"properties,omitempty" xml:"properties>property,omitempty"`
}

type VulnerabilityAnalysis struct {
Expand Down
11 changes: 11 additions & 0 deletions cyclonedx_test.go
Expand Up @@ -217,3 +217,14 @@ func TestLicenses_UnmarshalXML(t *testing.T) {
err = xml.Unmarshal([]byte("<Licenses><somethingElse>expressionValue</somethingElse></Licenses>"), licenses)
assert.Error(t, err)
}

func TestVulnerability_Properties(t *testing.T) {
// GIVEN
properties := []Property{}
vuln := Vulnerability{
Properties: &properties,
}

// EXPECT
assert.Equal(t, 0, len(*vuln.Properties))
nscuro marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Up @@ -118,6 +118,24 @@
}
]
}
],
"properties": [
{
"name": "Foo",
"value": "Bar"
},
{
"name": "Foo",
"value": "You"
},
{
"name": "Foo",
"value": "Two"
},
{
"name": "Bar",
"value": "Foo"
}
]
}
]
Expand Down
18 changes: 18 additions & 0 deletions testdata/valid-vulnerability.json
Expand Up @@ -116,6 +116,24 @@
}
]
}
],
"properties": [
{
"name": "Foo",
"value": "Bar"
},
{
"name": "Foo",
"value": "You"
},
{
"name": "Foo",
"value": "Two"
},
{
"name": "Bar",
"value": "Foo"
}
]
}
]
Expand Down
6 changes: 6 additions & 0 deletions testdata/valid-vulnerability.xml
Expand Up @@ -116,6 +116,12 @@
</versions>
</target>
</affects>
<!-- <properties>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: #40

<property name="Foo">Bar</property>
<property name="Foo">You</property>
<property name="Foo">Two</property>
<property name="Bar">Foo</property>
</properties> -->
</vulnerability>
</vulnerabilities>
</bom>