spdx / tools-python

A Python library to parse, validate and create SPDX documents.
http://spdx.org
Apache License 2.0
179 stars 131 forks source link

IndexError on parsing failure #764

Closed bmihaila-synopsys closed 11 months ago

bmihaila-synopsys commented 12 months ago

When parsing this file https://github.com/chainguard-dev/bom-shelter/blob/main/in-the-lab/spdx-popular-containers/data/spdx-trivy-vmware_log-intelligence-fluentd-sha256%3A086af034f561f343f633be9d9f9e95f65ae6c61b8ddb2c6755ef5bb25b40f53a.json there is a parsing error with licenses. However, when trying to create and raise an SPDXParsingError the library bugs itself with IndexError. See below:

File \".../site-packages/spdx_tools/spdx/parser/jsonlikedict/dict_parsing_functions.py\", line 31, in parse_field_or_log_error
return parsing_method(field)
           ^^^^^^^^^^^^^^^^^^^^^
File \.../site-packages/spdx_tools/spdx/parser/jsonlikedict/license_expression_parser.py\", line 23, in parse_license_expression
raise SPDXParsingError([f\"Error parsing LicenseExpression: {err.args[0]}: {license_expression_str}\"])
                                                                ~~~~~~~~^^^\nIndexError: tuple index out of range"}
maxhbr commented 11 months ago

Thanks for pointing out that our logic to generate the parsing errors has a bug.

As related information, the following error gets thrown by the online tools: 2023-09-27_08-42-38