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

Improve --cyclonedx output option #2987

Open
DennisClark opened this issue Jun 8, 2022 · 13 comments
Open

Improve --cyclonedx output option #2987

DennisClark opened this issue Jun 8, 2022 · 13 comments
Assignees
Milestone

Comments

@DennisClark
Copy link
Member

Running scancode-toolkit-31.0.0b5 on MacOS 11.6.6
The --json-pp output option works fine, but
the --cyclonedx output option fails.

scancode-toolkit-31.0.0b5 % ./scancode --license --copyright --cyclonedx scancode_results_cyclonedx.json samples
Setup plugins...
Collect file inventory...
Scan files for: licenses, copyrights with 1 process(es)...
[####################] 66
ERROR: failed to run output plugin: cyclonedx:
Traceback (most recent call last):
File "//scancode-toolkit-31.0.0b5/src/scancode/cli.py", line 1067, in run_codebase_plugins
plugin.process_codebase(codebase, **kwargs)
File "//scancode-toolkit-31.0.0b5/src/formattedcode/output_cyclonedx.py", line 735, in process_codebase
bom = CycloneDxBom.from_codebase(codebase)
File "//scancode-toolkit-31.0.0b5/src/formattedcode/output_cyclonedx.py", line 633, in from_codebase
packages = codebase.attributes.packages
AttributeError: 'CodebaseAttributes' object has no attribute 'packages'

Scanning done.
Summary: licenses, copyrights with 1 process(es)
Errors count: 0
Scan Speed: 1.12 files/sec.
Initial counts: 44 resource(s): 33 file(s) and 11 directorie(s)
Final counts: 44 resource(s): 33 file(s) and 11 directorie(s)
Timings:
scan_start: 2022-06-08T180404.780531
scan_end: 2022-06-08T180436.257832
setup_scan:licenses: 2.00s
setup: 2.00s
scan: 29.42s
total: 31.49s
Removing temporary files...done.

@DennisClark DennisClark added the bug label Jun 8, 2022
@pombredanne
Copy link
Member

@DennisClark can you try with "--package" ? It should not crash anyway.

@DennisClark
Copy link
Member Author

Running it with
./scancode --license --copyright --package --cyclonedx scancode_results_cyclonedx.json samples
works without failing. About to review the results.

@DennisClark
Copy link
Member Author

DennisClark commented Jun 9, 2022

I got beyond the crash by specifying the --package option. Now there is a rather different problem which might be called "lost in translation". The samples provided for testing with sctk did not produce really interesting results, so I extracted a folder from `libX11-1.7.2.tar.bz2' and scanned that. The results using the --json-pp output option are extensive and detailed, but running the same scan with the --cyclonedx output option produces a very limited file with hardly any content. Associated files attached. Here are my commands:

./scancode --license --copyright --package --cyclonedx libX11-1.7.2-scan-cyclonedx.json /Users/me/Downloads/libX11-1.7.2
and
./scancode --license --copyright --package --json-pp libX11-1.7.2-scan-json-pp.json /Users/me/Downloads/libX11-1.7.2

libX11-1.7.2.tar.bz2.zip

libX11-1.7.2-scan-cyclonedx.json.zip

libX11-1.7.2-scan-json-pp.json.zip

@pombredanne
Copy link
Member

@DennisClark Thanks... that's super useful to track this issue.

AyanSinhaMahapatra added a commit that referenced this issue Jun 21, 2022
Avoids crashing when generating a cyclonedx sbom from scancode-toolkit
when there aren't any package options specified. Also show a warning
message in the CLI and add a warning in the BOM metadata.

Reference: #2987
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
@AyanSinhaMahapatra
Copy link
Member

@DennisClark The above PR addresses the crash.

  1. We do not crash anymore
  2. We show the following CLI warning:

CycloneDxPluginNoPackagesWarning: The --cyclonedx-xml option will not output any component/dependency data as there are no package data in the present scan. To get package data please rerun the scan with --package or --system-package CLI options enabled.

  1. We also add the same message to the BOM metadata in warnings.

Please review the warning text also btw.

As for the did not produce really interesting results and produces a very limited file with hardly any content part of the issue, we need some more work and investigation. So let's keep this issue open.

@DennisClark
Copy link
Member Author

@AyanSinhaMahapatra The warning text provided in your comment is good and very informative, thanks. No changes suggested.

AyanSinhaMahapatra added a commit that referenced this issue Jun 27, 2022
Avoids crashing when generating a cyclonedx sbom from scancode-toolkit
when there aren't any package options specified. Also show a warning
message in the CLI and add a warning in the BOM metadata.

Reference: #2987
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
JonoYang added a commit that referenced this issue Jun 27, 2022
Do not fail without packages in cyclonedx #2987
@DennisClark
Copy link
Member Author

a helpful link here:
https://cyclonedx.org/schema/bom-1.4.schema.json

@DennisClark
Copy link
Member Author

another helpful link:
https://cyclonedx.org/use-cases/

KevinJi22 pushed a commit to KevinJi22/scancode-toolkit that referenced this issue Jul 25, 2022
Avoids crashing when generating a cyclonedx sbom from scancode-toolkit
when there aren't any package options specified. Also show a warning
message in the CLI and add a warning in the BOM metadata.

Reference: nexB#2987
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
@pombredanne
Copy link
Member

The bug is fixed and we are keeping this open to ensure we can report more useful data.

@pombredanne pombredanne added this to the v32.0 milestone Aug 11, 2022
@AyanSinhaMahapatra AyanSinhaMahapatra modified the milestones: v32.0, v32.1 Jan 4, 2023
@AyanSinhaMahapatra AyanSinhaMahapatra changed the title Output option --cyclonedx fails in scancode-toolkit-31.0.0b5 Improve --cyclonedx output option Jan 6, 2023
@AyanSinhaMahapatra
Copy link
Member

From @pombredanne at this comment:

please add an issue for follow up work to:

  • support newer/newest versions of the spec
  • add support for dependencies and more details

@AyanSinhaMahapatra
Copy link
Member

See a sample output at #3016 (comment) for reference

@eastmadc
Copy link

eastmadc commented Jul 7, 2023

CycloneDX v1.5 was released last month. @pombredanne do you think it would be worthwhile to add this support? Would you maintain legacy version support as well?
https://cyclonedx.org/news/cyclonedx-v1.5-released/

@pombredanne
Copy link
Member

pombredanne commented Jul 7, 2023

@eastmadc sure! I think the work will consist in migrating to this library https://gitlab.com/hoppr/hoppr-cyclonedx-models/-/tree/main/hoppr_cyclonedx_models that we already use in ScanCode.io and already has support for CycloneDX 1.5 (@jhlmco and team Thank you BTW.. ! )

Would you maintain legacy version support as well?

I think we should.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants