Skip to content

Commit

Permalink
fix: add missing Properties (#39)
Browse files Browse the repository at this point in the history
* test: expose missing Properties via failing test

Signed-off-by: Mike de Senna <desenna@gmail.com>

* fix: add missing Properties

Signed-off-by: Mike de Senna <desenna@gmail.com>

* test: rename to clarify what's being tested

Signed-off-by: Mike de Senna <desenna@gmail.com>

* test: update testdata json + xml

Signed-off-by: Mike de Senna <desenna@gmail.com>

* test: don't panic

Signed-off-by: Mike de Senna <desenna@gmail.com>

* test: UPDATE_SNAPSHOTS=true make test

Signed-off-by: Mike de Senna <desenna@gmail.com>

* Revert "test: UPDATE_SNAPSHOTS=true make test"

This reverts commit 75c4a5f.

Signed-off-by: Mike de Senna <desenna@gmail.com>

* test: comment out xml until fixed, gen new snapshot

Signed-off-by: Mike de Senna <desenna@gmail.com>
  • Loading branch information
desenna committed May 20, 2022
1 parent 207c038 commit 5f285ff
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 0 deletions.
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))
}
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>
<property name="Foo">Bar</property>
<property name="Foo">You</property>
<property name="Foo">Two</property>
<property name="Bar">Foo</property>
</properties> -->
</vulnerability>
</vulnerabilities>
</bom>

0 comments on commit 5f285ff

Please sign in to comment.