-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
feat: add cyclonedx.model.dependency.Dependency.provides
#735
Open
uzairchhapra
wants to merge
6
commits into
CycloneDX:main
Choose a base branch
from
uzairchhapra:feat/691-uzair-provides
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fb4598d
feat: add `cyclonedx.model.dependency.Dependency.provides`
uzairchhapra 00536a7
chore(test): add unit test `test_dependency_with_provides`
uzairchhapra abf6abf
ft: update `validate` and `register_dependency` to read `provides`
uzairchhapra 8cdb39b
chore: set view schema to 1.6 for provides
uzairchhapra 2525660
chore(test): add test `get_bom_with_provides_valid`
uzairchhapra bd370af
fix: rename test to apply only for v1.6
uzairchhapra 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 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 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 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 |
---|---|---|
|
@@ -1310,6 +1310,28 @@ def get_bom_with_definitions_standards() -> Bom: | |
) | ||
|
||
|
||
def get_bom_v1_6_with_provides() -> Bom: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please rename to there is no intention to have models for certain CDX versions only. |
||
c1 = get_component_toml_with_hashes_with_references('crypto-library') | ||
c2 = get_component_setuptools_simple('some-library') | ||
c3 = get_component_crypto_asset_algorithm('crypto-algorithm') | ||
return _make_bom( | ||
components=[c1, c2, c3], | ||
dependencies=[ | ||
Dependency( | ||
ref=c1.bom_ref, | ||
dependencies=[Dependency(ref=c2.bom_ref)], | ||
provides=[Dependency(ref=c3.bom_ref)] | ||
), | ||
Dependency( | ||
ref=c2.bom_ref | ||
), | ||
Dependency( | ||
uzairchhapra marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ref=c3.bom_ref | ||
), | ||
], | ||
) | ||
|
||
|
||
# --- | ||
|
||
|
||
|
113 changes: 113 additions & 0 deletions
113
tests/_data/snapshots/get_bom_v1_6_with_provides-1.6.json.bin
This file contains 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,113 @@ | ||
{ | ||
"components": [ | ||
{ | ||
"bom-ref": "crypto-algorithm", | ||
"cryptoProperties": { | ||
"algorithmProperties": { | ||
"certificationLevel": [ | ||
"fips140-1-l1", | ||
"fips140-2-l3", | ||
"other" | ||
], | ||
"classicalSecurityLevel": 2, | ||
"cryptoFunctions": [ | ||
"sign", | ||
"unknown" | ||
], | ||
"curve": "9n8y2oxty3ao83n8qc2g2x3qcw4jt4wj", | ||
"executionEnvironment": "software-plain-ram", | ||
"implementationPlatform": "generic", | ||
"mode": "ecb", | ||
"nistQuantumSecurityLevel": 2, | ||
"padding": "pkcs7", | ||
"parameterSetIdentifier": "a-parameter-set-id", | ||
"primitive": "kem" | ||
}, | ||
"assetType": "algorithm", | ||
"oid": "an-oid-here" | ||
}, | ||
"name": "My Algorithm", | ||
"tags": [ | ||
"algorithm" | ||
], | ||
"type": "cryptographic-asset", | ||
"version": "1.0" | ||
}, | ||
{ | ||
"author": "Test Author", | ||
"bom-ref": "some-library", | ||
"licenses": [ | ||
{ | ||
"license": { | ||
"id": "MIT" | ||
} | ||
} | ||
], | ||
"name": "setuptools", | ||
"purl": "pkg:pypi/[email protected]?extension=tar.gz", | ||
"type": "library", | ||
"version": "50.3.2" | ||
}, | ||
{ | ||
"bom-ref": "crypto-library", | ||
"externalReferences": [ | ||
{ | ||
"comment": "No comment", | ||
"hashes": [ | ||
{ | ||
"alg": "SHA-256", | ||
"content": "806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b" | ||
} | ||
], | ||
"type": "distribution", | ||
"url": "https://cyclonedx.org" | ||
} | ||
], | ||
"hashes": [ | ||
{ | ||
"alg": "SHA-256", | ||
"content": "806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b" | ||
} | ||
], | ||
"name": "toml", | ||
"purl": "pkg:pypi/[email protected]?extension=tar.gz", | ||
"type": "library", | ||
"version": "0.10.2" | ||
} | ||
], | ||
"dependencies": [ | ||
{ | ||
"ref": "crypto-algorithm" | ||
}, | ||
{ | ||
"dependsOn": [ | ||
"some-library" | ||
], | ||
"provides": [ | ||
"crypto-algorithm" | ||
], | ||
"ref": "crypto-library" | ||
}, | ||
{ | ||
"ref": "some-library" | ||
} | ||
], | ||
"metadata": { | ||
"timestamp": "2023-01-07T13:44:32.312678+00:00" | ||
}, | ||
"properties": [ | ||
{ | ||
"name": "key1", | ||
"value": "val1" | ||
}, | ||
{ | ||
"name": "key2", | ||
"value": "val2" | ||
} | ||
], | ||
"serialNumber": "urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac", | ||
"version": 1, | ||
"$schema": "http://cyclonedx.org/schema/bom-1.6.schema.json", | ||
"bomFormat": "CycloneDX", | ||
"specVersion": "1.6" | ||
} |
77 changes: 77 additions & 0 deletions
77
tests/_data/snapshots/get_bom_v1_6_with_provides-1.6.xml.bin
This file contains 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,77 @@ | ||
<?xml version="1.0" ?> | ||
<bom xmlns="http://cyclonedx.org/schema/bom/1.6" serialNumber="urn:uuid:1441d33a-e0fc-45b5-af3b-61ee52a88bac" version="1"> | ||
<metadata> | ||
<timestamp>2023-01-07T13:44:32.312678+00:00</timestamp> | ||
</metadata> | ||
<components> | ||
<component type="cryptographic-asset" bom-ref="crypto-algorithm"> | ||
<name>My Algorithm</name> | ||
<version>1.0</version> | ||
<cryptoProperties> | ||
<assetType>algorithm</assetType> | ||
<algorithmProperties> | ||
<primitive>kem</primitive> | ||
<parameterSetIdentifier>a-parameter-set-id</parameterSetIdentifier> | ||
<curve>9n8y2oxty3ao83n8qc2g2x3qcw4jt4wj</curve> | ||
<executionEnvironment>software-plain-ram</executionEnvironment> | ||
<implementationPlatform>generic</implementationPlatform> | ||
<certificationLevel>fips140-1-l1</certificationLevel> | ||
<certificationLevel>fips140-2-l3</certificationLevel> | ||
<certificationLevel>other</certificationLevel> | ||
<mode>ecb</mode> | ||
<padding>pkcs7</padding> | ||
<cryptoFunctions> | ||
<cryptoFunction>sign</cryptoFunction> | ||
<cryptoFunction>unknown</cryptoFunction> | ||
</cryptoFunctions> | ||
<classicalSecurityLevel>2</classicalSecurityLevel> | ||
<nistQuantumSecurityLevel>2</nistQuantumSecurityLevel> | ||
</algorithmProperties> | ||
<oid>an-oid-here</oid> | ||
</cryptoProperties> | ||
<tags> | ||
<tag>algorithm</tag> | ||
</tags> | ||
</component> | ||
<component type="library" bom-ref="some-library"> | ||
<author>Test Author</author> | ||
<name>setuptools</name> | ||
<version>50.3.2</version> | ||
<licenses> | ||
<license> | ||
<id>MIT</id> | ||
</license> | ||
</licenses> | ||
<purl>pkg:pypi/[email protected]?extension=tar.gz</purl> | ||
</component> | ||
<component type="library" bom-ref="crypto-library"> | ||
<name>toml</name> | ||
<version>0.10.2</version> | ||
<hashes> | ||
<hash alg="SHA-256">806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b</hash> | ||
</hashes> | ||
<purl>pkg:pypi/[email protected]?extension=tar.gz</purl> | ||
<externalReferences> | ||
<reference type="distribution"> | ||
<url>https://cyclonedx.org</url> | ||
<comment>No comment</comment> | ||
<hashes> | ||
<hash alg="SHA-256">806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b</hash> | ||
</hashes> | ||
</reference> | ||
</externalReferences> | ||
</component> | ||
</components> | ||
<dependencies> | ||
<dependency ref="crypto-algorithm"/> | ||
<dependency ref="crypto-library"> | ||
<dependency ref="some-library"/> | ||
<provides ref="crypto-algorithm"/> | ||
</dependency> | ||
<dependency ref="some-library"/> | ||
</dependencies> | ||
<properties> | ||
<property name="key1">val1</property> | ||
<property name="key2">val2</property> | ||
</properties> | ||
</bom> |
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of adding a new parameter here, how about adding a new method instead:
register_provision(self, target: Dependable, provides: Optional[Iterable[Dependable]] = None)
.what do you think about this?
this would fit the original architectural plans better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll give this a try