Skip to content

fix: derive dependency package type from the purl in ignored_dependency_scopes filtering - #2218

Open
MGpromax wants to merge 1 commit into
aboutcode-org:mainfrom
MGpromax:fix-ignored-dependency-scopes
Open

fix: derive dependency package type from the purl in ignored_dependency_scopes filtering#2218
MGpromax wants to merge 1 commit into
aboutcode-org:mainfrom
MGpromax:fix-ignored-dependency-scopes

Conversation

@MGpromax

Copy link
Copy Markdown

Closes #2215

ignore_dependency_scope() compares the ignored_dependency_scopes setting against dependency_data["package_type"] -- but dependency data coming from a scancode-toolkit scan has no package_type entry, only a purl. Since the guard requires both package_type and scope to 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_type entry is absent (PackageURL.from_string(purl).type), keeping the explicit entry as the priority when present. The existing test masked the gap by setting package_type explicitly 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).

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>
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.

ignored_dependency_scopes does not exclude npm devDependencies

1 participant