fix: derive dependency package type from the purl in ignored_dependency_scopes filtering - #2218
Open
MGpromax wants to merge 1 commit into
Open
fix: derive dependency package type from the purl in ignored_dependency_scopes filtering#2218MGpromax wants to merge 1 commit into
MGpromax wants to merge 1 commit into
Conversation
ignore_dependency_scope() compared the ignored_dependency_scopes
setting against dependency_data['package_type'], but dependency data
from a scancode-toolkit scan has no package_type entry -- only a
purl. The filter therefore silently never matched on real scan data,
and settings such as {package_type: npm, scope: devDependencies}
did not exclude npm devDependencies.
Derive the package type from the purl when the package_type entry is
absent. The existing test masked the gap by setting package_type
explicitly; a new test covers the purl-only shape.
Closes aboutcode-org#2215
Signed-off-by: Manoj Gowda <manojgowdabs18@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #2215
ignore_dependency_scope()compares theignored_dependency_scopessetting againstdependency_data["package_type"]-- but dependency data coming from a scancode-toolkit scan has nopackage_typeentry, only apurl. Since the guard requires bothpackage_typeandscopeto be truthy, the filter silently never matched on real scan data, which is exactly the reported behavior:{package_type: npm, scope: devDependencies}from the tutorial config not excluding anything.The fix derives the package type from the purl when the
package_typeentry is absent (PackageURL.from_string(purl).type), keeping the explicit entry as the priority when present. The existing test masked the gap by settingpackage_typeexplicitly on the test data; a new test covers the purl-only shape with matching scope, non-matching scope, non-matching type, and the no-purl/no-type case.Both the existing and new tests pass locally (sqlite).