wheel-crypto-scan 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wheel_crypto_scan-0.1.0/.github/dependabot.yml +28 -0
- wheel_crypto_scan-0.1.0/.github/workflows/ci.yml +126 -0
- wheel_crypto_scan-0.1.0/.github/workflows/pypi.yml +71 -0
- wheel_crypto_scan-0.1.0/.gitignore +12 -0
- wheel_crypto_scan-0.1.0/LICENSE +201 -0
- wheel_crypto_scan-0.1.0/NOTICE +9 -0
- wheel_crypto_scan-0.1.0/PKG-INFO +178 -0
- wheel_crypto_scan-0.1.0/README.md +159 -0
- wheel_crypto_scan-0.1.0/SCHEMA.md +168 -0
- wheel_crypto_scan-0.1.0/pyproject.toml +95 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/__init__.py +28 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/__main__.py +6 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/binfmt/__init__.py +101 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/binfmt/detect.py +48 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/binfmt/elf.py +276 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/binfmt/golang.py +106 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/binfmt/macho.py +251 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/binfmt/rust.py +31 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/binfmt/strings.py +67 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/cache.py +100 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/cli.py +299 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/data/ruleset.toml +1649 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/data/schema.json +702 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/discovery.py +102 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/engine.py +564 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/errors.py +76 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/evidence.py +217 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/findings.py +53 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/layers/__init__.py +1 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/layers/binaries.py +151 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/layers/metadata.py +518 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/layers/python_ast.py +527 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/linkage.py +130 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/record.py +212 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/report.py +73 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/ruleset.py +623 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/scan.py +171 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/verdict.py +63 -0
- wheel_crypto_scan-0.1.0/src/wheel_crypto_scan/wheelfile.py +365 -0
- wheel_crypto_scan-0.1.0/tests/helpers/__init__.py +1 -0
- wheel_crypto_scan-0.1.0/tests/helpers/elfbuilder.py +557 -0
- wheel_crypto_scan-0.1.0/tests/helpers/wheelbuilder.py +165 -0
- wheel_crypto_scan-0.1.0/tests/test_acceptance.py +385 -0
- wheel_crypto_scan-0.1.0/tests/test_binfmt_detect.py +44 -0
- wheel_crypto_scan-0.1.0/tests/test_binfmt_dispatch.py +66 -0
- wheel_crypto_scan-0.1.0/tests/test_binfmt_elf.py +400 -0
- wheel_crypto_scan-0.1.0/tests/test_binfmt_golang.py +90 -0
- wheel_crypto_scan-0.1.0/tests/test_binfmt_macho.py +129 -0
- wheel_crypto_scan-0.1.0/tests/test_binfmt_rust.py +50 -0
- wheel_crypto_scan-0.1.0/tests/test_binfmt_strings.py +81 -0
- wheel_crypto_scan-0.1.0/tests/test_cache.py +121 -0
- wheel_crypto_scan-0.1.0/tests/test_cli.py +198 -0
- wheel_crypto_scan-0.1.0/tests/test_discovery.py +96 -0
- wheel_crypto_scan-0.1.0/tests/test_engine.py +454 -0
- wheel_crypto_scan-0.1.0/tests/test_hardening.py +403 -0
- wheel_crypto_scan-0.1.0/tests/test_linkage.py +216 -0
- wheel_crypto_scan-0.1.0/tests/test_metadata.py +442 -0
- wheel_crypto_scan-0.1.0/tests/test_python_ast.py +409 -0
- wheel_crypto_scan-0.1.0/tests/test_record.py +232 -0
- wheel_crypto_scan-0.1.0/tests/test_report.py +70 -0
- wheel_crypto_scan-0.1.0/tests/test_review_fixes.py +228 -0
- wheel_crypto_scan-0.1.0/tests/test_ruleset.py +329 -0
- wheel_crypto_scan-0.1.0/tests/test_ruleset_data.py +212 -0
- wheel_crypto_scan-0.1.0/tests/test_verdict.py +133 -0
- wheel_crypto_scan-0.1.0/tests/test_wheelbuilder.py +75 -0
- wheel_crypto_scan-0.1.0/tests/test_wheelfile.py +278 -0
- wheel_crypto_scan-0.1.0/tools/make_corpus.py +118 -0
- wheel_crypto_scan-0.1.0/tox.ini +43 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Dependabot configuration.
|
|
2
|
+
#
|
|
3
|
+
# The important one is github-actions. Every action in .github/workflows is pinned to a
|
|
4
|
+
# full commit SHA, which is what stops a compromised tag from reaching CI, and which
|
|
5
|
+
# also means nothing updates unless something updates it. That something is Dependabot.
|
|
6
|
+
version: 2
|
|
7
|
+
updates:
|
|
8
|
+
- package-ecosystem: "github-actions"
|
|
9
|
+
directory: "/"
|
|
10
|
+
schedule:
|
|
11
|
+
interval: "weekly"
|
|
12
|
+
# Wait 3 days after a new action version is published before opening a PR.
|
|
13
|
+
# Gives time for supply chain compromises to be caught. Security updates
|
|
14
|
+
# are exempt and arrive immediately.
|
|
15
|
+
cooldown:
|
|
16
|
+
default-days: 3
|
|
17
|
+
open-pull-requests-limit: 10
|
|
18
|
+
|
|
19
|
+
# Runtime dependencies are declared with open lower bounds (pyelftools>=0.31), so
|
|
20
|
+
# this stays quiet until something is pinned or a lower bound actually blocks a
|
|
21
|
+
# release. It is here so that the day one is pinned, it is already watched.
|
|
22
|
+
- package-ecosystem: "pip"
|
|
23
|
+
directory: "/"
|
|
24
|
+
schedule:
|
|
25
|
+
interval: "weekly"
|
|
26
|
+
cooldown:
|
|
27
|
+
default-days: 3
|
|
28
|
+
open-pull-requests-limit: 5
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["**"]
|
|
6
|
+
tags-ignore: ["**"]
|
|
7
|
+
pull_request:
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
concurrency:
|
|
11
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
12
|
+
cancel-in-progress: true
|
|
13
|
+
|
|
14
|
+
permissions:
|
|
15
|
+
contents: read
|
|
16
|
+
|
|
17
|
+
env:
|
|
18
|
+
FORCE_COLOR: "1"
|
|
19
|
+
|
|
20
|
+
jobs:
|
|
21
|
+
test:
|
|
22
|
+
name: tests (py${{ matrix.python-version }})
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
strategy:
|
|
25
|
+
fail-fast: false
|
|
26
|
+
matrix:
|
|
27
|
+
python-version: ["3.11", "3.12", "3.13", "3.14"]
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
30
|
+
with:
|
|
31
|
+
fetch-depth: 0
|
|
32
|
+
fetch-tags: true
|
|
33
|
+
persist-credentials: false
|
|
34
|
+
- uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4 # v10.1.0
|
|
35
|
+
with:
|
|
36
|
+
enable-cache: true
|
|
37
|
+
- name: Install Python ${{ matrix.python-version }}
|
|
38
|
+
run: uv python install ${{ matrix.python-version }}
|
|
39
|
+
- name: Run tests
|
|
40
|
+
run: uvx --with tox-uv tox -e py$(echo '${{ matrix.python-version }}' | tr -d .)
|
|
41
|
+
|
|
42
|
+
lint:
|
|
43
|
+
name: ruff
|
|
44
|
+
runs-on: ubuntu-latest
|
|
45
|
+
steps:
|
|
46
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
47
|
+
with:
|
|
48
|
+
fetch-depth: 0
|
|
49
|
+
fetch-tags: true
|
|
50
|
+
persist-credentials: false
|
|
51
|
+
- uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4 # v10.1.0
|
|
52
|
+
with:
|
|
53
|
+
enable-cache: true
|
|
54
|
+
- name: Lint and format check
|
|
55
|
+
run: uvx --with tox-uv tox -e lint
|
|
56
|
+
|
|
57
|
+
pylint:
|
|
58
|
+
name: pylint
|
|
59
|
+
runs-on: ubuntu-latest
|
|
60
|
+
steps:
|
|
61
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
62
|
+
with:
|
|
63
|
+
fetch-depth: 0
|
|
64
|
+
fetch-tags: true
|
|
65
|
+
persist-credentials: false
|
|
66
|
+
- uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4 # v10.1.0
|
|
67
|
+
with:
|
|
68
|
+
enable-cache: true
|
|
69
|
+
- run: uv python install 3.12
|
|
70
|
+
- name: Run pylint
|
|
71
|
+
run: uvx --with tox-uv tox -e pylint
|
|
72
|
+
|
|
73
|
+
build:
|
|
74
|
+
name: build and verify the distribution
|
|
75
|
+
runs-on: ubuntu-latest
|
|
76
|
+
steps:
|
|
77
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
78
|
+
with:
|
|
79
|
+
fetch-depth: 0
|
|
80
|
+
fetch-tags: true
|
|
81
|
+
persist-credentials: false
|
|
82
|
+
- uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4 # v10.1.0
|
|
83
|
+
with:
|
|
84
|
+
enable-cache: true
|
|
85
|
+
- name: Build sdist and wheel
|
|
86
|
+
run: uv build
|
|
87
|
+
- name: Check metadata
|
|
88
|
+
run: uvx twine check --strict dist/*
|
|
89
|
+
- name: Confirm the ruleset and schema ship in the wheel
|
|
90
|
+
run: |
|
|
91
|
+
set -euo pipefail
|
|
92
|
+
python3 -m zipfile -l dist/*.whl | tee /dev/stderr | grep -q 'data/ruleset.toml'
|
|
93
|
+
python3 -m zipfile -l dist/*.whl | grep -q 'data/schema.json'
|
|
94
|
+
|
|
95
|
+
determinism:
|
|
96
|
+
name: byte-identical output across interpreters
|
|
97
|
+
runs-on: ubuntu-latest
|
|
98
|
+
steps:
|
|
99
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
100
|
+
with:
|
|
101
|
+
fetch-depth: 0
|
|
102
|
+
fetch-tags: true
|
|
103
|
+
persist-credentials: false
|
|
104
|
+
- uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4 # v10.1.0
|
|
105
|
+
with:
|
|
106
|
+
enable-cache: true
|
|
107
|
+
- run: uv python install 3.11 3.14
|
|
108
|
+
- name: Build the corpus
|
|
109
|
+
run: uv run --python 3.12 python tools/make_corpus.py corpus 40
|
|
110
|
+
- name: Scan under 3.11 and 3.14
|
|
111
|
+
run: |
|
|
112
|
+
set -euo pipefail
|
|
113
|
+
for v in 3.11 3.14; do
|
|
114
|
+
uv run --python "$v" --with pyelftools --with packaging \
|
|
115
|
+
python -m wheel_crypto_scan scan corpus -o "out-$v.jsonl" \
|
|
116
|
+
--jobs 4 --no-cache --quiet
|
|
117
|
+
done
|
|
118
|
+
- name: Assert the bytes match
|
|
119
|
+
run: |
|
|
120
|
+
set -euo pipefail
|
|
121
|
+
if ! cmp out-3.11.jsonl out-3.14.jsonl; then
|
|
122
|
+
echo "::error::scan output differs between Python 3.11 and 3.14"
|
|
123
|
+
diff <(jq -S . out-3.11.jsonl) <(jq -S . out-3.14.jsonl) | head -40
|
|
124
|
+
exit 1
|
|
125
|
+
fi
|
|
126
|
+
echo "identical: $(wc -l < out-3.11.jsonl) records, sha256 $(sha256sum < out-3.11.jsonl)"
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
# Publishes on a bare semver tag and nothing else:
|
|
4
|
+
#
|
|
5
|
+
# git tag -a 0.1.0 -m "0.1.0" && git push origin 0.1.0
|
|
6
|
+
#
|
|
7
|
+
# The version comes from the tag through uv-dynamic-versioning, so there is no number
|
|
8
|
+
# in the repository to bump and nothing to keep in sync.
|
|
9
|
+
#
|
|
10
|
+
# Authentication is PyPI Trusted Publishing (OIDC); there is no API token to store.
|
|
11
|
+
|
|
12
|
+
on:
|
|
13
|
+
push:
|
|
14
|
+
tags:
|
|
15
|
+
- '[0-9]+.[0-9]+.[0-9]+'
|
|
16
|
+
|
|
17
|
+
permissions:
|
|
18
|
+
contents: read
|
|
19
|
+
|
|
20
|
+
jobs:
|
|
21
|
+
test:
|
|
22
|
+
name: Run Tox
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
26
|
+
with:
|
|
27
|
+
fetch-depth: 0
|
|
28
|
+
fetch-tags: true
|
|
29
|
+
persist-credentials: false
|
|
30
|
+
- name: Install uv
|
|
31
|
+
uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4 # v10.1.0
|
|
32
|
+
- name: Install interpreters
|
|
33
|
+
run: uv python install 3.11 3.12 3.13 3.14
|
|
34
|
+
# A tag can point at any commit, and CI does not run on tags, so the release
|
|
35
|
+
# path verifies the thing it is about to publish rather than assuming.
|
|
36
|
+
- name: Run all envs
|
|
37
|
+
run: uvx --with tox-uv tox
|
|
38
|
+
|
|
39
|
+
build-and-publish:
|
|
40
|
+
name: Build and publish to PyPI
|
|
41
|
+
needs: test
|
|
42
|
+
if: ${{ github.repository_owner == 'EmilienM' }}
|
|
43
|
+
|
|
44
|
+
runs-on: ubuntu-latest
|
|
45
|
+
environment: release
|
|
46
|
+
|
|
47
|
+
permissions:
|
|
48
|
+
contents: read
|
|
49
|
+
id-token: write
|
|
50
|
+
|
|
51
|
+
steps:
|
|
52
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
53
|
+
with:
|
|
54
|
+
# Full history and tags: the version is derived from the tag.
|
|
55
|
+
fetch-depth: 0
|
|
56
|
+
fetch-tags: true
|
|
57
|
+
persist-credentials: false
|
|
58
|
+
- name: Install uv
|
|
59
|
+
uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4 # v10.1.0
|
|
60
|
+
- name: Build sdist and wheel
|
|
61
|
+
run: uv build
|
|
62
|
+
- name: Check metadata
|
|
63
|
+
run: uvx twine check --strict dist/*
|
|
64
|
+
- name: Confirm the ruleset and schema ship in the distribution
|
|
65
|
+
run: |
|
|
66
|
+
set -euo pipefail
|
|
67
|
+
python3 -m zipfile -l dist/*.whl | grep -q 'data/ruleset.toml'
|
|
68
|
+
python3 -m zipfile -l dist/*.whl | grep -q 'data/schema.json'
|
|
69
|
+
- name: Publish to PyPI
|
|
70
|
+
if: startsWith(github.ref, 'refs/tags')
|
|
71
|
+
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
wheel-crypto-scan
|
|
2
|
+
Copyright 2026 Red Hat, Inc.
|
|
3
|
+
|
|
4
|
+
This product includes software developed at Red Hat, Inc.
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: wheel-crypto-scan
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Deterministic FIPS-risk evidence inspector for Python wheels
|
|
5
|
+
Author-email: Emilien Macchi <emacchi@redhat.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
License-File: NOTICE
|
|
9
|
+
Keywords: crypto,fips,sbom,supply-chain,wheel
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: Security :: Cryptography
|
|
15
|
+
Requires-Python: >=3.11
|
|
16
|
+
Requires-Dist: packaging>=23.2
|
|
17
|
+
Requires-Dist: pyelftools>=0.31
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# wheel-crypto-scan
|
|
21
|
+
|
|
22
|
+
Reports crypto-relevant **evidence** found inside Python wheels, so the teams consuming a
|
|
23
|
+
package index can see per-wheel FIPS risk before they ship it.
|
|
24
|
+
|
|
25
|
+
It gathers evidence. It does not decide compliance.
|
|
26
|
+
|
|
27
|
+
## What it answers
|
|
28
|
+
|
|
29
|
+
The question it exists for: **does this wheel use the system OpenSSL, or does it carry its
|
|
30
|
+
own?** A wheel that resolves `libcrypto.so.3` from the host inherits the host's FIPS
|
|
31
|
+
provider and crypto policy. A wheel that ships or statically links its own copy does not,
|
|
32
|
+
and no amount of host configuration changes that.
|
|
33
|
+
|
|
34
|
+
There are three ways a wheel can carry its own OpenSSL, and all three are caught:
|
|
35
|
+
|
|
36
|
+
| Evidence | `openssl_linkage` |
|
|
37
|
+
|---|---|
|
|
38
|
+
| Plain `DT_NEEDED libcrypto.so.3`, OpenSSL symbols imported | `system` |
|
|
39
|
+
| A library under `*.libs/` or `.dylibs/`, or a dependency on a hash-renamed `libcrypto-3a1f2b4c.so.3` | `bundled` |
|
|
40
|
+
| No dependency and no vendor directory, but OpenSSL symbols defined or its version banner in read-only data | `static` |
|
|
41
|
+
|
|
42
|
+
The third case is the one that matters most and the one a vendor-directory check alone
|
|
43
|
+
misses. Run against three real builds of `cryptography`:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
Fedora RPM build DT_NEEDED libcrypto.so.3, libssl.so.3 64 symbols imported -> system
|
|
47
|
+
PyPI 42.0.5 empty cryptography.libs/, no DT_NEEDED, 0 symbols exported -> static
|
|
48
|
+
PyPI 3.4.8 no DT_NEEDED, no vendor directory, 0 symbols exported -> static
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
For PyPI 42.0.5 the *only* evidence is the `OpenSSL 3.2.1` banner in `.rodata`: the vendor
|
|
52
|
+
directory is empty, nothing is declared, and the symbols are hidden by a version script.
|
|
53
|
+
|
|
54
|
+
## What it explicitly does not do
|
|
55
|
+
|
|
56
|
+
- **It never says "FIPS compliant."** The verdict taxonomy has no passing class and cannot
|
|
57
|
+
acquire one. A human makes that call.
|
|
58
|
+
- **No LLM at runtime.** Pure static analysis. The JSON is what gets fed to a model later,
|
|
59
|
+
as a separate step.
|
|
60
|
+
- **No dataflow or reachability analysis.** It records the call site; it does not try to
|
|
61
|
+
prove the call runs.
|
|
62
|
+
- **No container images, no RPMs, no sdists.** Wheels only.
|
|
63
|
+
- **No network**, except an explicitly requested `--index-url` download of the wheels.
|
|
64
|
+
|
|
65
|
+
## Install and run
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
uv tool install . # or: uv run wheel-crypto-scan
|
|
69
|
+
wheel-crypto-scan scan /path/to/wheels -o index.jsonl --jobs 8
|
|
70
|
+
wheel-crypto-scan scan one.whl --format md
|
|
71
|
+
wheel-crypto-scan rules # the rule table, for review
|
|
72
|
+
wheel-crypto-scan schema # the JSON Schema for the output
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Useful flags: `--jobs N`, `--cache-dir DIR` / `--no-cache`, `--resume`, `--evidence-level
|
|
76
|
+
minimal|standard`, `--ruleset PATH`, `--from-file LIST`, `--index-url URL --download-dir DIR`.
|
|
77
|
+
|
|
78
|
+
Triage the output with `jq`:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
jq -r 'select(.verdict.conditions.openssl_linkage == "bundled") | .wheel.filename' index.jsonl
|
|
82
|
+
jq -r 'select(.verdict.class == "FIPS_BREAKING") | "\(.wheel.name) \(.verdict.reasons[0])"' index.jsonl
|
|
83
|
+
jq -r 'select(.verdict.class == "OPAQUE") | .wheel.filename' index.jsonl # could not be read
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Output
|
|
87
|
+
|
|
88
|
+
JSONL, one record per wheel. `SCHEMA.md` documents every field and the versioning rules;
|
|
89
|
+
`wheel-crypto-scan schema` prints the machine-readable JSON Schema.
|
|
90
|
+
|
|
91
|
+
| Verdict class | Meaning |
|
|
92
|
+
|---|---|
|
|
93
|
+
| `NON_APPROVED_CRYPTO` | Implements or bundles a non-FIPS-approved primitive |
|
|
94
|
+
| `CONDITIONAL` | Approved only under a stated condition; `verdict.conditions` says which holds |
|
|
95
|
+
| `FIPS_BREAKING` | Will raise at runtime under FIPS-enforcing mode |
|
|
96
|
+
| `CONTEXT_DEPENDENT` | Non-approved primitive that may be a non-security use |
|
|
97
|
+
| `NO_CRYPTO_DETECTED` | Nothing found. Absence of evidence, not evidence of absence |
|
|
98
|
+
| `OPAQUE` | Stripped, unreadable or source-free. Cannot determine |
|
|
99
|
+
|
|
100
|
+
A wheel that could not be read is `OPAQUE`, never `NO_CRYPTO_DETECTED`. That distinction is
|
|
101
|
+
enforced by a test asserting every recordable failure has a rule.
|
|
102
|
+
|
|
103
|
+
## The ruleset
|
|
104
|
+
|
|
105
|
+
All policy lives in [`src/wheel_crypto_scan/data/ruleset.toml`](src/wheel_crypto_scan/data/ruleset.toml).
|
|
106
|
+
Every package name, symbol, string, crate, library and verdict is data, each with a `why`
|
|
107
|
+
explaining in plain language what it is and why it is flagged. A crypto engineer can review
|
|
108
|
+
and edit it without reading any Python. `wheel-crypto-scan rules` renders it for review.
|
|
109
|
+
|
|
110
|
+
Bump `ruleset_version` after editing: it is part of the scan cache key, so bumping it is
|
|
111
|
+
what makes previously scanned wheels get re-evaluated.
|
|
112
|
+
|
|
113
|
+
## Determinism
|
|
114
|
+
|
|
115
|
+
Same wheel in, byte-identical JSONL out. Verified on a 100-wheel corpus to be identical
|
|
116
|
+
across repeat runs, `--jobs 1` vs `--jobs 8`, cold vs warm cache, and Python 3.11, 3.12,
|
|
117
|
+
3.13 and 3.14. Output is sorted, ASCII-only, float-free, and contains no host paths,
|
|
118
|
+
timestamps or hostnames.
|
|
119
|
+
|
|
120
|
+
One caveat worth knowing: `ast.parse` follows the grammar of the interpreter running it,
|
|
121
|
+
so a wheel using syntax newer than the scanner's interpreter will not parse. **Pin the
|
|
122
|
+
interpreter** if you need output comparable across hosts. That difference is never
|
|
123
|
+
silently favourable: unparsed files are counted in `artifacts.py_files_unparsed`, and a
|
|
124
|
+
wheel whose every source file failed reports `source_available: false` and comes out
|
|
125
|
+
`OPAQUE`, not clean.
|
|
126
|
+
|
|
127
|
+
## Performance
|
|
128
|
+
|
|
129
|
+
Measured on 100 synthetic wheels averaging 3.3 MiB uncompressed, on 16 cores:
|
|
130
|
+
|
|
131
|
+
| Mode | wheels/s | per wheel |
|
|
132
|
+
|---|---|---|
|
|
133
|
+
| `--jobs 1`, cold | 3.1 | 320 ms |
|
|
134
|
+
| `--jobs 4`, cold | 11.8 | 85 ms |
|
|
135
|
+
| `--jobs 8`, cold | 20.4 | 49 ms |
|
|
136
|
+
| `--jobs 8`, warm cache | 674 | 1.5 ms |
|
|
137
|
+
|
|
138
|
+
Wheels are read from the zip in memory and never extracted to disk. Members above the
|
|
139
|
+
in-memory threshold stream through a seekable zip reader that retains a bounded window of
|
|
140
|
+
what it has already decompressed, so a multi-gigabyte extension costs a bounded number of
|
|
141
|
+
passes rather than a gigabyte of resident memory. Reading the real 5.5 MiB
|
|
142
|
+
`libcrypto.so.3` through that path takes 0.19 s with one decompression; without the
|
|
143
|
+
window it took 17 s and 3,161.
|
|
144
|
+
|
|
145
|
+
## Development
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
uvx --with tox-uv tox # tests across py311-py314, plus ruff lint and format
|
|
149
|
+
uvx --with tox-uv tox -e lint
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Test fixtures are synthesised, including the ELF objects: the suite needs no compiler, no
|
|
153
|
+
network and no committed binaries, and runs byte-identically anywhere. Tests against real
|
|
154
|
+
downloaded wheels are behind the `real` marker; tests that read host system libraries are
|
|
155
|
+
behind `hostbin`.
|
|
156
|
+
|
|
157
|
+
Dependencies are `pyelftools` and `packaging`, and nothing else without asking.
|
|
158
|
+
|
|
159
|
+
### Releasing
|
|
160
|
+
|
|
161
|
+
Publishing is triggered by a bare semver tag and nothing else. There is no version to
|
|
162
|
+
bump: it is derived from the tag at build time by `uv-dynamic-versioning`, so the
|
|
163
|
+
version in a record is always the version that produced it.
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
git tag -a 0.1.0 -m "0.1.0" && git push origin 0.1.0
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
No `v` prefix. The workflow re-runs the full matrix, builds, checks that the ruleset and
|
|
170
|
+
schema are actually inside the distribution, and uploads through PyPI Trusted
|
|
171
|
+
Publishing, so there is no token to store.
|
|
172
|
+
|
|
173
|
+
An untagged build reports its commit, for example `0.0.0.post14.dev0+1105fe9`, which
|
|
174
|
+
makes it obvious when a record came from something other than a release.
|
|
175
|
+
|
|
176
|
+
## Licence
|
|
177
|
+
|
|
178
|
+
Apache 2.0. See [LICENSE](LICENSE).
|