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

Very badly formed SPDX generates exceptions other than SPDXParsingError #831

Open
king-doug-conti opened this issue Oct 10, 2024 · 0 comments

Comments

@king-doug-conti
Copy link

The README says that when using parse_file() from parse_anything.py "Unsuccessful parsing will raise SPDXParsingError with a list of all encountered problems." However, other Exceptions can be raised for very badly formed files.

As an example, if the SPDX file is a valid JSON format, and there is a string where an array or object should be, it issues:

AttributeError: 'str' object has no attribute 'get'

In my test case, I took a valid spdx.json file, and replaced a package with a string value:

    # self.json_data is valid spdx in json format
    bad_spdx = json.loads(self.json_data)
    bad_spdx['packages'][0] = 'bad value'
    bad_spdx_json = json.dumps(bad_spdx) 

    with open("spdx.json", 'w') as f:
        f.write(bad_spdx_json)

    parse_file("spdx.json")

I would expect such a case to raise an SPDXParsingError with an indication like "packages[0] was expected to be an array, but was not"

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

1 participant