Skip to content

Fix Godeps parsing crashes on unknown fields, null Deps, and invalid import paths (fixes #5569) - #5570

Open
patelshivani2283-lab wants to merge 1 commit into
aboutcode-org:developfrom
patelshivani2283-lab:fix-godeps-parsing-crashes
Open

patelshivani2283-lab wants to merge 1 commit into
aboutcode-org:developfrom
patelshivani2283-lab:fix-godeps-parsing-crashes

Conversation

@patelshivani2283-lab

Copy link
Copy Markdown

Summary

Fixes #5569

Resolves multiple crashes when parsing Go Godeps.json files:

  1. Safely ignore unknown top-level fields in Godep.loads without crashing with TypeError: attribute name must be string, not 'NoneType'.
  2. Safely filter unknown dependency fields in Godep.parse_deps without crashing with KeyError: '<key>'.
  3. Safely handle null in Deps without raising TypeError: 'NoneType' object is not iterable.
  4. Validate and strip import_path in dependency entries before constructing PURLs to prevent ValueError: purl is missing the required name component or creating invalid pkg:golang/None dependencies.
  5. Safely handle non-dict and malformed JSON inputs.
  6. Add unit tests covering all edge cases, and update CHANGELOG.rst and AUTHORS.rst.

Verification

Ran all test_godeps.py tests with pytest:

scancode-toolkit/tests/packagedcode/test_godeps.py ................ [100%]
16 passed in 0.72s

…import paths (fixes aboutcode-org#5569)

- Ignore unknown top-level and dependency fields in Godep.loads and parse_deps
- Safely handle null Deps without TypeError crashes
- Safely handle non-dict and malformed JSON inputs
- Validate and strip dependency import_path before PURL creation to prevent ValueError crashes or pkg:golang/None
- Add comprehensive unit tests covering all edge cases
- Update CHANGELOG.rst and AUTHORS.rst

Signed-off-by: Shivani Patel <[email protected]>

This branch has not been deployed

No deployments
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 this pull request may close these issues.

[BUG] Godeps parsing crashes on unknown fields, null Deps, and invalid dependency import_path

1 participant