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 when using get_license_detection_from_nameless_paragraph() #25

Closed
JonoYang opened this issue Feb 24, 2022 · 3 comments
Closed

Error when using get_license_detection_from_nameless_paragraph() #25

JonoYang opened this issue Feb 24, 2022 · 3 comments

Comments

@JonoYang
Copy link
Member

I was running the scancode.io Docker pipeline on a Docker image and I got the following error:

'license'

Traceback:
  File "/app/scanpipe/pipelines/__init__.py", line 115, in execute
    step(self)
  File "/app/scanpipe/pipelines/docker.py", line 93, in collect_and_create_system_packages
    docker.scan_image_for_system_packages(self.project, image)
  File "/app/scanpipe/pipes/docker.py", line 166, in scan_image_for_system_packages
    for i, (purl, package, layer) in enumerate(installed_packages):
  File "/usr/local/lib/python3.9/site-packages/container_inspector/image.py", line 446, in get_installed_packages
    for purl, package in layer.get_installed_packages(packages_getter):
  File "/app/scanpipe/pipes/debian.py", line 34, in package_getter
    for package in packages:
  File "/usr/local/lib/python3.9/site-packages/packagedcode/debian.py", line 178, in get_installed_packages
    dc = debian_copyright.parse_copyright_file(copyright_location)
  File "/usr/local/lib/python3.9/site-packages/packagedcode/debian_copyright.py", line 95, in parse_copyright_file
    dc = StructuredCopyrightProcessor.from_file(
  File "/usr/local/lib/python3.9/site-packages/packagedcode/debian_copyright.py", line 350, in from_file
    dc.detect_license()
  File "/usr/local/lib/python3.9/site-packages/packagedcode/debian_copyright.py", line 590, in detect_license
    files_license_detections = self.get_license_detections(
  File "/usr/local/lib/python3.9/site-packages/packagedcode/debian_copyright.py", line 618, in get_license_detections
    get_license_detection_from_nameless_paragraph(paragraph=paragraph)
  File "/usr/local/lib/python3.9/site-packages/packagedcode/debian_copyright.py", line 1571, in get_license_detection_from_nameless_paragraph
    start_line, _ = paragraph.get_field_line_numbers('license')
  File "/usr/local/lib/python3.9/site-packages/debian_inspector/copyright.py", line 182, in get_field_line_numbers
    return self.line_numbers_by_field[field_name]

I don't have the full stack trace, but it appears that issue is that we're trying to get the value for the key license at https://github.com/nexB/debian-inspector/blob/main/src/debian_inspector/copyright.py#L182, but the key license does not exist in self.line_numbers_by_field.

@JonoYang
Copy link
Member Author

The issue was not with the code but rather with the copyright file that I was looking at. The copyright file for php v 7.4 has entries where they misspelled the license field as licence.

Files: ext/xmlrpc/libxmlrpc/base64.h ext/xmlrpc/libxmlrpc/base64.c
Copyright: John Walker
Licence: public-domain
 This program is in the public domain.

When we import these paragraphs, the license is not saved to the license field, but rather to the licence field. This makes it seem that this paragraph does not have license information, when it actually does. The line numbers are never set for this paragraph because the license field is not set.

@pombredanne
Copy link
Member

@JonoYang IMHO the parser should accept and recognize these damaged copyright files using a "Licence" English spelling and treating this as a License field. And the code should not crash there

JonoYang added a commit that referenced this issue Mar 1, 2022
    * Add test to ensure license information is saved in the right field

Signed-off-by: Jono Yang <jyang@nexb.com>
pombredanne added a commit that referenced this issue Mar 1, 2022
Rename licence field to license in from_fields #25
@AyanSinhaMahapatra
Copy link
Member

This was fixed in #26 and released in https://github.com/nexB/debian-inspector/releases/tag/v31.0.0. Closing!

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

No branches or pull requests

3 participants