Skip to content

Add system library dependencies to Fromager SBOM via auditwheel#292

Open
ronnll wants to merge 1 commit into
mainfrom
CALUNGA-226
Open

Add system library dependencies to Fromager SBOM via auditwheel#292
ronnll wants to merge 1 commit into
mainfrom
CALUNGA-226

Conversation

@ronnll
Copy link
Copy Markdown
Contributor

@ronnll ronnll commented May 21, 2026

Wheels built by Calunga can link against system-provided shared libraries, but this information was missing from the SBOM shipped inside each wheel. This adds a new add-system-deps-to-sbom script that runs auditwheel show on each manylinux wheel after repair, parses the system library references and their versioned symbols, and injects them as SPDX Package entries with DEPENDS_ON relationships in the Fromager SBOM.

Assisted-by: Claude Opus 4.6 noreply@anthropic.com

Summary by Sourcery

Augment Fromager-generated SBOMs for manylinux wheels with system library dependency information derived from auditwheel output.

New Features:

  • Add a script to extract system shared library dependencies via auditwheel and inject them as SPDX packages with DEPENDS_ON relationships into the Fromager SBOM for each repaired manylinux wheel.

Tests:

  • Add a test script to validate that system dependency information is correctly added to the SBOM for built wheels.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 21, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds a post-repair step that inspects manylinux wheels with auditwheel to discover system-provided shared library dependencies and injects them into the Fromager SBOM as SPDX Packages with DEPENDS_ON relationships.

File-Level Changes

Change Details Files
Introduce a script to scan manylinux wheels with auditwheel and augment the Fromager SBOM with system library dependencies and their versioned symbols.
  • Add add-system-deps-to-sbom script that runs auditwheel show on each repaired manylinux wheel.
  • Parse auditwheel output to extract linked system libraries and their versioned symbols.
  • Emit corresponding SPDX Package entries and DEPENDS_ON relationships into the existing Fromager SBOM embedded in the wheel.
builder/scripts/add-system-deps-to-sbom
Wire the new SBOM augmentation step into the wheel build pipeline so it executes after auditwheel repair.
  • Update build-wheels script to invoke add-system-deps-to-sbom after repairing manylinux wheels.
  • Ensure the step only runs for relevant wheel types and integrates with existing Fromager SBOM generation.
builder/scripts/build-wheels
Add tests for the system dependency SBOM enrichment logic.
  • Introduce test-add-system-deps script to cover parsing of auditwheel show output.
  • Verify that expected SPDX Package entries and DEPENDS_ON relationships are produced for representative system library dependencies.
builder/scripts/test-add-system-deps

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 security issue, and left some high level feedback:

Security issues:

  • Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'. (link)

General comments:

  • Consider hardening the auditwheel output parsing logic (e.g., handling unexpected formats, missing sections, or future auditwheel changes) so that failures degrade gracefully without breaking the wheel build or corrupting the SBOM.
  • It may be worth ensuring the new add-system-deps-to-sbom step is idempotent (e.g., not duplicating SPDX Package/DEPENDS_ON entries when re-run) to avoid subtle SBOM growth or inconsistencies in incremental or retried builds.
  • Since this script relies on auditwheel and manylinux-specific behavior, consider isolating any platform- or tool-specific assumptions behind small helper functions so future changes (e.g., non-manylinux targets or different tools) are easier to support.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider hardening the auditwheel output parsing logic (e.g., handling unexpected formats, missing sections, or future auditwheel changes) so that failures degrade gracefully without breaking the wheel build or corrupting the SBOM.
- It may be worth ensuring the new add-system-deps-to-sbom step is idempotent (e.g., not duplicating SPDX Package/DEPENDS_ON entries when re-run) to avoid subtle SBOM growth or inconsistencies in incremental or retried builds.
- Since this script relies on auditwheel and manylinux-specific behavior, consider isolating any platform- or tool-specific assumptions behind small helper functions so future changes (e.g., non-manylinux targets or different tools) are easier to support.

## Individual Comments

### Comment 1
<location path="builder/scripts/test-add-system-deps" line_range="276-277" />
<code_context>
        r = subprocess.run([sys.executable, str(SCRIPT_DIR / "add-system-deps-to-sbom"), str(whl)],
                           capture_output=True, text=True)
</code_context>
<issue_to_address>
**security (python.lang.security.audit.dangerous-subprocess-use-audit):** Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.

*Source: opengrep*
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread builder/scripts/test-add-system-deps Outdated
@ronnll
Copy link
Copy Markdown
Contributor Author

ronnll commented May 27, 2026

@jvulgan PTAL. The script has helper functions which are intentionally kept this way instead of being added to the main function for a more fail safe approach. Also, this was tested locally with the test-add-system-deps, but ill double check by by inspecting a package when merged. Lastly,, this was mostly generated by Claude but I've checked each line to ensure it's accurate. Sorry it's a bit long, but please feel free to ask any questions you have.

Comment thread builder/scripts/add_system_deps_to_sbom.py
Comment thread builder/scripts/add_system_deps_to_sbom.py
Comment thread builder/scripts/add_system_deps_to_sbom.py
Comment thread builder/scripts/test-add-system-deps Outdated
Comment thread builder/scripts/test-add-system-deps Outdated
Comment thread builder/scripts/add_system_deps_to_sbom.py
Comment thread builder/scripts/build-wheels Outdated
@ronnll ronnll requested a review from jvulgan May 28, 2026 08:01
@ronnll
Copy link
Copy Markdown
Contributor Author

ronnll commented May 28, 2026

@jvulgan updated, ptal!

Wheels built by Calunga can link against system-provided shared
libraries, but this information was missing from the SBOM shipped
inside each wheel. This adds a new add-system-deps-to-sbom script that
runs auditwheel show on each manylinux wheel after repair, parses the
system library references and their versioned symbols, and injects them
as SPDX Package entries with DEPENDS_ON relationships in the Fromager SBOM.

Assisted-by: Claude Opus 4.6 <noreply@anthropic.com>
@ronnll
Copy link
Copy Markdown
Contributor Author

ronnll commented May 29, 2026

@jvulgan changes made. PTAL!

@jvulgan
Copy link
Copy Markdown
Contributor

jvulgan commented May 29, 2026

/lgtm

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.

2 participants