support inspect-manifest for CycloneDx 1.4 - #592
Conversation
1caeffc to
3e37835
Compare
AyanSinhaMahapatra
left a comment
There was a problem hiding this comment.
Thanks! A few initial nits and comments for you.
| Requires the `jsonschema` library. | ||
| """ | ||
| try: | ||
| import jsonschema |
There was a problem hiding this comment.
Isn't jsonschema in install_requires? Will this ever fail?
There was a problem hiding this comment.
Isn't
jsonschemaininstall_requires?
I was just being consistent with spdx.validate_document 😅
https://github.com/nexB/scancode.io/blob/0b4053ebe8c229c18308c0e96af8346842b75a7b/scanpipe/spdx/__init__.py#L648-L659
Will this ever fail?
Let me confirm if it!
There was a problem hiding this comment.
Will this ever fail?
I checked, it will never fail. Will get this removed.
There was a problem hiding this comment.
Maybe we can remove this in spdx too (?)
There was a problem hiding this comment.
Maybe we can remove this in spdx too (?)
I will enter an issue for that and if there is no objection then we can go ahead and remove it.
Sounds good?
There was a problem hiding this comment.
This is just a tiny nit, too small for a separate issue, just keep this conversation open for others to comment.
|
@kpriyadarshi I ran a inspect_manifest pipeline from your branch and it worked great! The license_expression also seems to work fine: I'll check with some more complicated cyclonedx boms, and let you know! |
ed8e2ed to
a496619
Compare
a496619 to
685ef9d
Compare
tdruez
left a comment
There was a problem hiding this comment.
@keshav-space great start, here's some suggestions to improve the code:
- We do not use typing in ScanCode.io at the moment, you want to be consistent with the existing codebase convention.
- Do not use the
or []syntax. - Do not use
objnoriterableas variable names but try to name things what they are. - Some docstring are not ending with a
. - The integraiton test is great, but we are missing a unit test for each functions of the cyclonedx module.
5ae8195 to
75ecd2a
Compare
tdruez
left a comment
There was a problem hiding this comment.
@keshav-space see my various comments for refinements, also:
- You have "CycloneDx" and "CYCLONEDX" occurrences that need to be replaced by the proper syntax: "CycloneDX".
- I gave you "write" access on the repo so in the future you can create branches directly on the repo.
| resolver = jsonschema.RefResolver( | ||
| base_uri="file://" + str(pathlib.Path(__file__).parent), referrer=schema | ||
| ) | ||
|
|
||
| validator = jsonschema.Draft7Validator(schema=schema, resolver=resolver) | ||
|
|
||
| validator.validate(instance=document) |
There was a problem hiding this comment.
Is this complexity needed?
The basic jsonschema.validate(instance=document, schema=schema) is not enough in the CycloneDX case?
There was a problem hiding this comment.
jsonschema.validate(instance=document, schema=schema) will work, but if BOM contains an invalid SPDX license expression, then hoppr-cyclonedx-models won't be able to parse it. The same thing goes for JSF.
- CycloneDx `component` can have a `list of components`, those are dumped to extra_data as `nestedComponents`. Furthermore, these lists of components are recursively parsed and treated as normal package. - The Component may have multiple URLs in externalReferences. The first URL of the reference is added to the applicable package_data URL, while the rest are dumped in extra_data as externalReferences. Fixes aboutcode-org#583 Signed-off-by: Keshav Priyadarshi <git@keshav.space>
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
75ecd2a to
b78ee53
Compare
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
b78ee53 to
043bbb9
Compare
componentcan have alist of components, those are dumped to extra_data asnestedComponents. Furthermore, these lists of components are recursively parsed and treated as normal package.fixes #583
Signed-off-by: Keshav Priyadarshi git@keshav.space