Skip to content

fix: add config option to exclude language packages with file ownership overlap#4905

Open
kimjune01 wants to merge 3 commits into
anchore:mainfrom
kimjune01:fix/exclude-language-overlap-4760
Open

fix: add config option to exclude language packages with file ownership overlap#4905
kimjune01 wants to merge 3 commits into
anchore:mainfrom
kimjune01:fix/exclude-language-overlap-4760

Conversation

@kimjune01
Copy link
Copy Markdown

Closes #4760.

Cause

When OS packages (deb, apk, rpm) install language packages (Python, Ruby, npm, etc.) via system package managers, syft catalogs both the OS package and the language package. The file ownership overlap relationship exists between them, but there was no mechanism to deduplicate.

The existing exclude-binary-overlap-by-ownership option handles binary packages, but an equivalent for language packages was missing.

Fix

Adds exclude-language-overlap-by-ownership config option that removes language packages when they have a file ownership overlap relationship with an OS package. This mirrors the existing binary exclusion logic. The option defaults to false to avoid changing existing behavior.

The implementation follows the same pattern as ExcludeBinaryPackagesByFileOwnershipOverlap: iterate relationships, identify OS-parent/language-child pairs, and delete the child package.

Tests

Unit tests cover:

  • OS → language package overlap (deb→python, apk→npm, rpm→ruby) — child removed
  • Binary → language package overlap — both kept
  • OS → OS overlap — both kept
  • Language → language overlap — both kept

Signed-off-by: June Kim kimjune01@gmail.com

@kimjune01
Copy link
Copy Markdown
Author

Pushed two test-only follow-ups (b4844d0, 64376c2): the original tests built pkg.Package literals without SetID(), so c.Package(r.From.ID()) returned nil and the assertion compared "" == "" — the suite passed without exercising the code under test. Added SetID() on the test packages and an assert.NotEqual(t, "", result) guard so the no-op can't recur. Verified by injecting a panic in the function body: pre-fix tests pass (proof of no-op), post-fix tests fail with the panic (proof of exercise).

kimjune01 added 3 commits May 18, 2026 12:29
…ip overlap

Adds a new configuration option `exclude-language-overlap-by-ownership` that
allows users to exclude language packages (Python, NPM, Ruby, etc.) from the
SBOM when they overlap with OS packages (deb, rpm, apk).

This prevents duplicate entries for packages installed via system package
managers that are also detected by language-specific catalogers.

Example: python3-django deb package vs. django Python package

The feature is disabled by default to maintain backward compatibility.

Resolves anchore#4760

Signed-off-by: June Kim <kimjune01@gmail.com>
Previously the table-driven test built pkg.Package literals without
calling SetID(), leaving every package ID as the empty string. The
collection generated its own ID on Add() but the original literals
remained empty, so the relationship From/To IDs were all '' and
c.Package('') returned nil. The function exited at the nil check
without ever evaluating identifyOverlappingLanguageRelationship, and
the assertion compared two empty strings — the test passed
unconditionally.

Inject panic('reached') before the return: tests passed (proof of
no-op). After SetID() is called and we drop the dynamic logic-mirror
in the assertion, panic injection now triggers — the function is
actually exercised.

Signed-off-by: June Kim <kimjune01@gmail.com>
Same root cause as the prior commit: pkg.Package literals had no IDs,
so child.ID() == "" and the assertion compared empty to empty when
the function correctly returned "" for the no-match case AND when it
should have returned the child ID — both branches passed trivially.
Verified by panic injection: prior to this fix the test passed even
when the function panicked at entry.

Signed-off-by: June Kim <kimjune01@gmail.com>
@kimjune01 kimjune01 force-pushed the fix/exclude-language-overlap-4760 branch from 64376c2 to a0b55b8 Compare May 18, 2026 19:42
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.

OS package (deb) components duplicated as pypi components

1 participant