Repository navigation
118 lines (109 loc) · 4.81 KB
/
Copy pathpython.yml
File metadata and controls
118 lines (109 loc) · 4.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Python
on:
workflow_call:
permissions:
contents: read
jobs:
test-python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.12'
- name: Run tests
working-directory: python
run: python -m unittest test_keyorix.py -v
# Carried forward from keyorix-python's uncommitted ssdlc.yml (never
# merged there; adopted here since it's genuinely useful, ADR-072). Each
# job verified locally against this exact command before being wired in
# here, not copied blind — the SBOM job's `--outfile` flag in the
# original didn't exist in the currently-pinned cyclonedx-bom version and
# would have failed on first run; fixed to `-o` below.
#
# All four jobs below install from python/requirements-dev.lock.txt with
# --require-hashes: a hash-pinned lock of pyproject.toml's [dev] extra and
# its full transitive tree (pip-compile --generate-hashes --extra=dev),
# not just top-level `==` pins -- pip refuses to install anything whose
# downloaded artifact doesn't match a pinned hash. Regenerate after
# changing the dev extra:
# pip-compile --extra=dev --generate-hashes \
# --output-file=python/requirements-dev.lock.txt python/pyproject.toml
# None of these jobs need the keyorix package itself installed (bandit and
# detect-secrets read source files directly; pip-audit/cyclonedx-py report
# on the installed dev-tooling environment) so it's deliberately left out
# of the lock file rather than mixing a local/unhashed requirement into a
# --require-hashes install.
sast:
name: SAST (bandit)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.12'
- name: Install dev tooling (locked)
working-directory: python
run: |
pip install --no-cache-dir --only-binary :all: --require-hashes -r requirements-dev.lock.txt
- name: Run bandit
working-directory: python
# continue-on-error: keyorix.py currently has 4 Medium-severity B310
# findings (urllib.request.urlopen without scheme restriction on the
# caller-supplied server_url) -- a real, pre-existing finding, not a
# bandit false positive, but fixing it is an SDK code change and
# explicitly out of scope for ADR-072's consolidation. Surfaced every
# run rather than silently dropped or silently fixed; not blocking
# merges until there's an explicit decision to fix or suppress it.
continue-on-error: true
run: bandit -c pyproject.toml -r keyorix.py
dependency-audit:
name: Dependency audit (pip-audit)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.12'
- name: Install dev tooling (locked)
working-directory: python
run: |
pip install --no-cache-dir --only-binary :all: --require-hashes -r requirements-dev.lock.txt
- name: Run pip-audit
working-directory: python
run: pip-audit
secret-scan:
name: Secret scan (detect-secrets)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.12'
- name: Install dev tooling (locked)
working-directory: python
run: |
pip install --no-cache-dir --only-binary :all: --require-hashes -r requirements-dev.lock.txt
- name: Scan against baseline
working-directory: python
run: detect-secrets scan --baseline .secrets.baseline
sbom:
name: SBOM (CycloneDX)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.12'
- name: Install dev tooling (locked)
working-directory: python
run: |
pip install --no-cache-dir --only-binary :all: --require-hashes -r requirements-dev.lock.txt
- name: Generate SBOM
working-directory: python
run: cyclonedx-py environment --output-format JSON -o sbom.json
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: python-sbom
path: python/sbom.json
retention-days: 30