Skip to content

feat: scan source distributions for compiled code#947

Open
tiran wants to merge 1 commit intopython-wheel-build:mainfrom
tiran:scan-compiled
Open

feat: scan source distributions for compiled code#947
tiran wants to merge 1 commit intopython-wheel-build:mainfrom
tiran:scan-compiled

Conversation

@tiran
Copy link
Collaborator

@tiran tiran commented Mar 3, 2026

The new helper function scan_compiled_extensions scans source distributions for compiled code. It detects common extensions like .so and .dylib as well as files with certain headers.

The function is designed to detect packaging issues like sdists with pre-compiled code. It is incapable of detecting supply chain attacks and malicious code.

@LalatenduMohanty
Copy link
Member

@tiran #963 has merged, we should rebase this PR.

@tiran tiran marked this pull request as ready for review March 19, 2026 05:39
@tiran tiran requested a review from a team as a code owner March 19, 2026 05:39
build_env=build_env,
)
# look for compiled code in sdist
scan_compiled_extensions(sdist_root_dir)
Copy link
Member

Choose a reason for hiding this comment

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

@tiran Why not call it in prepare_new_source(), as this is a source validation step, not a build step.

Copy link
Member

Choose a reason for hiding this comment

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

We are ignoring the return value. IMO we should fail if we find pre-compiled code with an override in case we want to ignore the error.

build_env=build_env,
)
# look for compiled code in sdist
scan_compiled_extensions(sdist_root_dir)
Copy link
Member

Choose a reason for hiding this comment

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

We are ignoring the return value. IMO we should fail if we find pre-compiled code with an override in case we want to ignore the error.

)
issues.append(filepath)
elif suffix not in ignore_suffixes:
with filepath.open("rb") as f:
Copy link
Member

Choose a reason for hiding this comment

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

Wondering if we should put open() in a try/except for OSError to be resilient

".rs",
".rst",
".sh",
".tml",
Copy link
Member

Choose a reason for hiding this comment

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

Do you mean toml or html

The new helper function `scan_compiled_extensions` scans source
distributions for compiled code. It detects common extensions like `.so`
and `.dylib` as well as files with certain headers.

The function is designed to detect packaging issues like sdists with
pre-compiled code. It is incapable of detecting supply chain attacks and
malicious code.

Signed-off-by: Christian Heimes <cheimes@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants