-
-
Notifications
You must be signed in to change notification settings - Fork 53
feat: add CPE to component #138
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
80622b2
Added CPE to component
jblu42 55c9eae
Fixing problems with CPE addition
jblu42 eb405c3
Again fixes for Style and CPE reference
jblu42 80209cc
Added CPE as argument before deprecated arguments
jblu42 134b1e3
Added testing for CPE addition and error fixing
jblu42 18f39af
Fixed output tests
jblu42 5652e2e
Fixed minor test fixtures issues
jblu42 7c78f62
Fixed missing comma in JSON 1.2 test file
jblu42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<bom xmlns="http://cyclonedx.org/schema/bom/1.0" version="1"> | ||
<components> | ||
<component type="library"> | ||
<name>setuptools</name> | ||
<version>50.3.2</version> | ||
<cpe>cpe:2.3:a:python:setuptools:50.3.2:*:*:*:*:*:*:*</cpe> | ||
<purl>pkg:pypi/[email protected]?extension=tar.gz</purl> | ||
<modified>false</modified> | ||
</component> | ||
</components> | ||
</bom> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<bom xmlns="http://cyclonedx.org/schema/bom/1.1" version="1" | ||
serialNumber="urn:uuid:b409670b-e3e3-4691-b1ee-8eff057d74f5"> | ||
<components> | ||
<component type="library" bom-ref="pkg:pypi/[email protected]?extension=tar.gz"> | ||
<name>setuptools</name> | ||
<version>50.3.2</version> | ||
<cpe>cpe:2.3:a:python:setuptools:50.3.2:*:*:*:*:*:*:*</cpe> | ||
<purl>pkg:pypi/[email protected]?extension=tar.gz</purl> | ||
</component> | ||
</components> | ||
</bom> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"$schema": "http://cyclonedx.org/schema/bom-1.2a.schema.json", | ||
"bomFormat": "CycloneDX", | ||
"specVersion": "1.2", | ||
"serialNumber": "urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79", | ||
"version": 1, | ||
"metadata": { | ||
"timestamp": "2021-09-01T10:50:42.051979+00:00", | ||
"tools": [ | ||
{ | ||
"vendor": "CycloneDX", | ||
"name": "cyclonedx-python-lib", | ||
"version": "VERSION" | ||
} | ||
] | ||
}, | ||
"components": [ | ||
{ | ||
"type": "library", | ||
"bom-ref": "pkg:pypi/[email protected]?extension=tar.gz", | ||
"author": "Test Author", | ||
"name": "setuptools", | ||
"version": "50.3.2", | ||
"cpe": "cpe:2.3:a:python:setuptools:50.3.2:*:*:*:*:*:*:*", | ||
"purl": "pkg:pypi/[email protected]?extension=tar.gz" | ||
} | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<bom xmlns="http://cyclonedx.org/schema/bom/1.2" version="1"> | ||
<metadata> | ||
<timestamp>2021-09-01T10:50:42.051979+00:00</timestamp> | ||
<tools> | ||
<tool> | ||
<vendor>CycloneDX</vendor> | ||
<name>cyclonedx-python-lib</name> | ||
<version>VERSION</version> | ||
</tool> | ||
</tools> | ||
</metadata> | ||
<components> | ||
<component type="library" bom-ref="pkg:pypi/[email protected]?extension=tar.gz"> | ||
<name>setuptools</name> | ||
<version>50.3.2</version> | ||
<cpe>cpe:2.3:a:python:setuptools:50.3.2:*:*:*:*:*:*:*</cpe> | ||
<purl>pkg:pypi/[email protected]?extension=tar.gz</purl> | ||
</component> | ||
</components> | ||
</bom> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"$schema": "http://cyclonedx.org/schema/bom-1.3.schema.json", | ||
"bomFormat": "CycloneDX", | ||
"specVersion": "1.3", | ||
"serialNumber": "urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79", | ||
"version": 1, | ||
"metadata": { | ||
"timestamp": "2021-09-01T10:50:42.051979+00:00", | ||
"tools": [ | ||
{ | ||
"vendor": "CycloneDX", | ||
"name": "cyclonedx-python-lib", | ||
"version": "VERSION" | ||
} | ||
] | ||
}, | ||
"components": [ | ||
{ | ||
"type": "library", | ||
"name": "setuptools", | ||
"version": "50.3.2", | ||
"cpe": "cpe:2.3:a:python:setuptools:50.3.2:*:*:*:*:*:*:*", | ||
"purl": "pkg:pypi/[email protected]?extension=tar.gz", | ||
"bom-ref": "pkg:pypi/[email protected]?extension=tar.gz", | ||
madpah marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"licenses": [ | ||
{ | ||
"expression": "MIT License" | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<bom xmlns="http://cyclonedx.org/schema/bom/1.3" version="1"> | ||
<metadata> | ||
<timestamp>2021-09-01T10:50:42.051979+00:00</timestamp> | ||
<tools> | ||
<tool> | ||
<vendor>CycloneDX</vendor> | ||
<name>cyclonedx-python-lib</name> | ||
<version>VERSION</version> | ||
</tool> | ||
</tools> | ||
</metadata> | ||
<components> | ||
<component type="library" bom-ref="pkg:pypi/[email protected]?extension=tar.gz"> | ||
<name>setuptools</name> | ||
<version>50.3.2</version> | ||
<cpe>cpe:2.3:a:python:setuptools:50.3.2:*:*:*:*:*:*:*</cpe> | ||
<purl>pkg:pypi/[email protected]?extension=tar.gz</purl> | ||
</component> | ||
</components> | ||
</bom> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{ | ||
"$schema": "http://cyclonedx.org/schema/bom-1.4.schema.json", | ||
"bomFormat": "CycloneDX", | ||
"specVersion": "1.4", | ||
"serialNumber": "urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79", | ||
"version": 1, | ||
"metadata": { | ||
"timestamp": "2021-09-01T10:50:42.051979+00:00", | ||
"tools": [ | ||
{ | ||
"vendor": "CycloneDX", | ||
"name": "cyclonedx-python-lib", | ||
"version": "VERSION", | ||
"externalReferences": [ | ||
{ | ||
"type": "build-system", | ||
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/actions" | ||
}, | ||
{ | ||
"type": "distribution", | ||
"url": "https://pypi.org/project/cyclonedx-python-lib/" | ||
}, | ||
{ | ||
"type": "documentation", | ||
"url": "https://cyclonedx.github.io/cyclonedx-python-lib/" | ||
}, | ||
{ | ||
"type": "issue-tracker", | ||
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/issues" | ||
}, | ||
{ | ||
"type": "license", | ||
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE" | ||
}, | ||
{ | ||
"type": "release-notes", | ||
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md" | ||
}, | ||
{ | ||
"type": "vcs", | ||
"url": "https://github.com/CycloneDX/cyclonedx-python-lib" | ||
}, | ||
{ | ||
"type": "website", | ||
"url": "https://cyclonedx.org" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"components": [ | ||
{ | ||
"type": "library", | ||
"name": "setuptools", | ||
"version": "50.3.2", | ||
"cpe": "cpe:2.3:a:python:setuptools:50.3.2:*:*:*:*:*:*:*", | ||
"purl": "pkg:pypi/[email protected]?extension=tar.gz", | ||
"bom-ref": "pkg:pypi/[email protected]?extension=tar.gz" | ||
madpah marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<bom xmlns="http://cyclonedx.org/schema/bom/1.4" version="1"> | ||
<metadata> | ||
<timestamp>2021-09-01T10:50:42.051979+00:00</timestamp> | ||
<tools> | ||
<tool> | ||
<vendor>CycloneDX</vendor> | ||
<name>cyclonedx-python-lib</name> | ||
<version>VERSION</version> | ||
<externalReferences> | ||
<reference type="build-system"> | ||
<url>https://github.com/CycloneDX/cyclonedx-python-lib/actions</url> | ||
</reference> | ||
<reference type="distribution"> | ||
<url>https://pypi.org/project/cyclonedx-python-lib/</url> | ||
</reference> | ||
<reference type="documentation"> | ||
<url>https://cyclonedx.github.io/cyclonedx-python-lib/</url> | ||
</reference> | ||
<reference type="issue-tracker"> | ||
<url>https://github.com/CycloneDX/cyclonedx-python-lib/issues</url> | ||
</reference> | ||
<reference type="license"> | ||
<url>https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE</url> | ||
</reference> | ||
<reference type="release-notes"> | ||
<url>https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md</url> | ||
</reference> | ||
<reference type="vcs"> | ||
<url>https://github.com/CycloneDX/cyclonedx-python-lib</url> | ||
</reference> | ||
<reference type="website"> | ||
<url>https://cyclonedx.org</url> | ||
</reference> | ||
</externalReferences> | ||
</tool> | ||
</tools> | ||
</metadata> | ||
<components> | ||
<component type="library" bom-ref="pkg:pypi/[email protected]?extension=tar.gz"> | ||
<name>setuptools</name> | ||
<version>50.3.2</version> | ||
<cpe>cpe:2.3:a:python:setuptools:50.3.2:*:*:*:*:*:*:*</cpe> | ||
<purl>pkg:pypi/[email protected]?extension=tar.gz</purl> | ||
</component> | ||
</components> | ||
</bom> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,60 @@ def test_simple_bom_v1_2(self) -> None: | |
self.assertEqualJsonBom(expected_json.read(), outputter.output_as_string()) | ||
expected_json.close() | ||
|
||
def test_simple_bom_v1_4_with_cpe(self) -> None: | ||
bom = Bom() | ||
c = Component( | ||
name='setuptools', version='50.3.2', bom_ref='pkg:pypi/[email protected]?extension=tar.gz', | ||
cpe='cpe:2.3:a:python:setuptools:50.3.2:*:*:*:*:*:*:*', | ||
purl=PackageURL( | ||
type='pypi', name='setuptools', version='50.3.2', qualifiers='extension=tar.gz' | ||
) | ||
) | ||
bom.add_component(c) | ||
|
||
outputter = get_instance(bom=bom, output_format=OutputFormat.JSON, schema_version=SchemaVersion.V1_4) | ||
self.assertIsInstance(outputter, JsonV1Dot4) | ||
with open(join(dirname(__file__), 'fixtures/bom_v1.4_setuptools_with_cpe.json')) as expected_json: | ||
self.assertValidAgainstSchema(bom_json=outputter.output_as_string(), schema_version=SchemaVersion.V1_4) | ||
self.assertEqualJsonBom(expected_json.read(), outputter.output_as_string()) | ||
expected_json.close() | ||
|
||
def test_simple_bom_v1_3_with_cpe(self) -> None: | ||
bom = Bom() | ||
c = Component( | ||
name='setuptools', version='50.3.2', bom_ref='pkg:pypi/[email protected]?extension=tar.gz', | ||
cpe='cpe:2.3:a:python:setuptools:50.3.2:*:*:*:*:*:*:*', | ||
purl=PackageURL( | ||
type='pypi', name='setuptools', version='50.3.2', qualifiers='extension=tar.gz' | ||
), license_str='MIT License' | ||
) | ||
bom.add_component(c) | ||
|
||
outputter = get_instance(bom=bom, output_format=OutputFormat.JSON) | ||
self.assertIsInstance(outputter, JsonV1Dot3) | ||
with open(join(dirname(__file__), 'fixtures/bom_v1.3_setuptools_with_cpe.json')) as expected_json: | ||
self.assertValidAgainstSchema(bom_json=outputter.output_as_string(), schema_version=SchemaVersion.V1_3) | ||
self.assertEqualJsonBom(expected_json.read(), outputter.output_as_string()) | ||
expected_json.close() | ||
|
||
def test_simple_bom_v1_2_with_cpe(self) -> None: | ||
bom = Bom() | ||
bom.add_component( | ||
Component( | ||
name='setuptools', version='50.3.2', bom_ref='pkg:pypi/[email protected]?extension=tar.gz', | ||
cpe='cpe:2.3:a:python:setuptools:50.3.2:*:*:*:*:*:*:*', | ||
purl=PackageURL( | ||
type='pypi', name='setuptools', version='50.3.2', qualifiers='extension=tar.gz' | ||
), author='Test Author' | ||
) | ||
) | ||
outputter = get_instance(bom=bom, output_format=OutputFormat.JSON, schema_version=SchemaVersion.V1_2) | ||
self.assertIsInstance(outputter, JsonV1Dot2) | ||
with open(join(dirname(__file__), 'fixtures/bom_v1.2_setuptools_with_cpe.json')) as expected_json: | ||
self.assertValidAgainstSchema(bom_json=outputter.output_as_string(), schema_version=SchemaVersion.V1_2) | ||
self.assertEqualJsonBom(expected_json.read(), outputter.output_as_string()) | ||
expected_json.close() | ||
|
||
def test_bom_v1_3_with_component_hashes(self) -> None: | ||
bom = Bom() | ||
c = Component( | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.