fix: normalize python package names from dependency lists #4408
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Because package names in METADATA files may have upper case like Werkzeug or Jinja2, but Syft artifacts have normalized names and are lower case, like werkzeug or jinja2, Syft would miss emitting dependency relationships. Therefore, normalize dependency names before comparing with existing artifacts.
Description
Syft's cataloging of venv/site-packages uses a dependency resolving post processor to compare the
requiresstatements from the METADATA file to other python artifacts emitted and create relationships between them. However, the name comparison between the requires statements from the METADATA files was normalized via a different codepath than the artifact names, so there were missed relationships because, for example"Werkzeug" != "werkzeug".Therefore, normalize the dependency names via the same normalization used for artifact names before building the relationships.
Fixes #4401
Type of change
Checklist: