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

Error in getting package licenses for node image with scancode #985

Closed
nishakm opened this issue Jun 11, 2021 · 2 comments · Fixed by #993
Closed

Error in getting package licenses for node image with scancode #985

nishakm opened this issue Jun 11, 2021 · 2 comments · Fixed by #993

Comments

@nishakm
Copy link
Contributor

nishakm commented Jun 11, 2021

Describe the bug
Traceback when running tern with scancode on node image with the default report

To Reproduce

  1. Install tern and scancode in a development environment
  2. Run tern report -i node:16-slim -x scancode -o output.txt
  3. See error

Error in terminal

2021-06-11 11:58:43,468 - DEBUG - generator - Creating a detailed report of components in image...
Traceback (most recent call last):
  File "/home/nisha/terndev/bin/tern", line 10, in <module>
    sys.exit(main())
  File "/home/nisha/terndev/tern/tern/__main__.py", line 286, in main
    do_main(args)
  File "/home/nisha/terndev/tern/tern/__main__.py", line 116, in do_main
    crun.execute_image(args)
  File "/home/nisha/terndev/tern/tern/analyze/default/container/run.py", line 90, in execute_image
    report.report_out(args, full_image)
  File "/home/nisha/terndev/tern/tern/report/report.py", line 95, in report_out
    report = generate_report(args, *images)
  File "/home/nisha/terndev/tern/tern/report/report.py", line 52, in generate_report
    return generate_format(images, 'default', args.print_inclusive)
  File "/home/nisha/terndev/tern/tern/report/report.py", line 65, in generate_format
    return mgr.driver.generate(images, print_inclusive)
  File "/home/nisha/terndev/tern/tern/formats/default/generator.py", line 144, in generate
    return report + print_licenses_only(image_obj_list)
  File "/home/nisha/terndev/tern/tern/formats/default/generator.py", line 124, in print_licenses_only
    full_license_list = content.get_licenses_only(image_obj_list)
  File "/home/nisha/terndev/tern/tern/report/content.py", line 40, in get_licenses_only
    pkg_licenses = get_layer_packages_licenses(layer)
  File "/home/nisha/terndev/tern/tern/report/content.py", line 19, in get_layer_packages_licenses
    package_licenses = get_package_licenses(package)
  File "/home/nisha/terndev/tern/tern/report/content.py", line 54, in get_package_licenses
    pkg_licenses.add(package.pkg_license)
TypeError: unhashable type: 'list'

Expected behavior
This should execute successfully

@abhaykatheria
Copy link
Contributor

@nishakm @rnjudge The error in issues #982 and #844 is also same, i think its the way scancode is adding packages is resulting in these kind of errors.

@rnjudge
Copy link
Contributor

rnjudge commented Jul 2, 2021

Scancode will sometimes report the declared_license value from the package dictionary as a list (of strings OR dicts) which is causing this error. Tern just needs to be able to translate the list value(s) into a concatenated string. I will submit a PR for this fix shortly.

rnjudge added a commit to rnjudge/tern that referenced this issue Jul 6, 2021
There was a traceback error running Tern with Scancode for multiple
report formats due to Scancode reporting licenses as a list containing a
single string or a list containing a license dictionary when Tern was
expecting just a string. This commit resolves the issue by parsing the
license list to get the license text before assigning it to a Package
object's 'pkg_license' value.

Resolves tern-tools#985 tern-tools#844

Signed-off-by: Rose Judge <[email protected]>
rnjudge added a commit that referenced this issue Jul 6, 2021
There was a traceback error running Tern with Scancode for multiple
report formats due to Scancode reporting licenses as a list containing a
single string or a list containing a license dictionary when Tern was
expecting just a string. This commit resolves the issue by parsing the
license list to get the license text before assigning it to a Package
object's 'pkg_license' value.

Resolves #985 #844

Signed-off-by: Rose Judge <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants