Skip to content

Commit 5578b27

Browse files
authored
Merge branch 'master' into security-updates
2 parents 0f191b2 + d7ad3a4 commit 5578b27

13 files changed

Lines changed: 171 additions & 91 deletions

File tree

‎.github/workflows/codeql.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
5858
steps:
5959
- name: Checkout repository
60-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
60+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
6161
with:
6262
persist-credentials: false
6363

@@ -69,7 +69,7 @@ jobs:
6969

7070
# Initializes the CodeQL tools for scanning.
7171
- name: Initialize CodeQL
72-
uses: github/codeql-action/init@38697555549f1db7851b81482ff19f1fa5c4fedc
72+
uses: github/codeql-action/init@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee
7373
with:
7474
languages: ${{ matrix.language }}
7575
build-mode: ${{ matrix.build-mode }}
@@ -98,6 +98,6 @@ jobs:
9898
exit 1
9999
100100
- name: Perform CodeQL Analysis
101-
uses: github/codeql-action/analyze@38697555549f1db7851b81482ff19f1fa5c4fedc
101+
uses: github/codeql-action/analyze@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee
102102
with:
103103
category: "/language:${{matrix.language}}"

‎.github/workflows/docker_security.yml‎

Lines changed: 93 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,53 +17,122 @@ concurrency:
1717
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.merge_group.head_sha || github.ref }}
1818
cancel-in-progress: true
1919

20+
env:
21+
# Grype is installed from a pinned release tarball verified against a
22+
# hardcoded SHA256 instead of through a third-party action or install
23+
# script, so a hijacked tag or release cannot change what runs here.
24+
# To upgrade: pick a release that has been out for at least a week or two,
25+
# verify the Sigstore signature on grype_<version>_checksums.txt, then copy
26+
# the linux_amd64.tar.gz checksum from that file.
27+
GRYPE_VERSION: "0.120.1"
28+
GRYPE_SHA256: "0a9ee97ef5ae2ee953b0a80098105052e846cdbe319a57d808b519c33cd1343d"
29+
GRYPE_CHECK_FOR_APP_UPDATE: "false"
30+
2031
jobs:
21-
buildx:
32+
scan:
2233
permissions:
2334
contents: read
2435
actions: read # Required for upload-sarif to get workflow run info
2536
security-events: write # Required for uploading SARIF results
2637
pull-requests: write # Required for PR comments summarizing vulnerabilities
27-
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
2838
runs-on: ubuntu-latest
39+
env:
40+
# Fork PRs get a read-only token, so they are scanned but cannot upload
41+
# SARIF results or comment on the PR.
42+
CAN_WRITE: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
2943
steps:
44+
# The image is large and gets written to disk twice (archive + Grype's
45+
# unpacked layers), so reclaim space from preinstalled toolchains.
46+
- name: Free disk space
47+
run: |
48+
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
49+
df -h /
50+
3051
- name: Checkout
31-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
52+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
3253
with:
3354
persist-credentials: false
3455

3556
- name: Set up Docker Buildx
36-
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd
57+
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069
3758

59+
# Export straight to a tarball rather than loading into the Docker
60+
# daemon, so the scanner reads the archive without another docker save.
3861
- name: Build image
39-
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294
62+
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc
4063
with:
4164
context: .
4265
file: runscripts/container/Dockerfile
43-
load: true
4466
tags: vecoli:latest
67+
outputs: type=docker,dest=${{ runner.temp }}/vecoli.tar
4568
cache-from: type=gha
4669
cache-to: type=gha,mode=max
4770

48-
- name: Login to Docker Hub
49-
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2
50-
with:
51-
username: ${{ vars.DOCKERHUB_USERNAME }}
52-
password: ${{ secrets.DOCKERHUB_TOKEN }}
71+
- name: Install Grype
72+
run: |
73+
tarball="$RUNNER_TEMP/grype.tar.gz"
74+
curl -fsSL --proto '=https' --tlsv1.2 -o "$tarball" \
75+
"https://github.com/anchore/grype/releases/download/v${GRYPE_VERSION}/grype_${GRYPE_VERSION}_linux_amd64.tar.gz"
76+
echo "${GRYPE_SHA256} ${tarball}" | sha256sum --check --strict
77+
mkdir -p "$RUNNER_TEMP/grype-bin"
78+
tar -xzf "$tarball" -C "$RUNNER_TEMP/grype-bin" grype
79+
echo "$RUNNER_TEMP/grype-bin" >> "$GITHUB_PATH"
5380
54-
- name: Analyze for critical and high CVEs
55-
id: docker-scout-cves
56-
uses: docker/scout-action@8910519cee8ac046f3ee99686b0dc6654d5ba1a7
57-
with:
58-
command: cves,recommendations
59-
image: vecoli:latest
60-
sarif-file: sarif.output.json
61-
summary: true
62-
only-severities: critical,high,medium
63-
only-fixed: true
81+
- name: Scan image for vulnerabilities
82+
run: |
83+
grype "docker-archive:$RUNNER_TEMP/vecoli.tar" \
84+
--name vecoli:latest \
85+
--only-fixed \
86+
-o table \
87+
-o json=grype.json \
88+
-o sarif=grype-all.sarif
89+
rm -f "$RUNNER_TEMP/vecoli.tar"
90+
# Keep critical/high (error) and medium (warning); drop low/negligible (note)
91+
jq '.runs[].results |= map(select(.level != "note"))' grype-all.sarif > grype.sarif
92+
93+
- name: Write job summary
94+
env:
95+
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
96+
run: |
97+
jq -r '
98+
[.matches[] | select(.vulnerability.severity | IN("Critical","High","Medium"))]
99+
| sort_by({"Critical":0,"High":1,"Medium":2}[.vulnerability.severity], .artifact.name)
100+
| if length == 0 then "No fixable critical, high, or medium vulnerabilities found."
101+
else
102+
"| Severity | Vulnerability | Package | Installed | Fixed in |",
103+
"|---|---|---|---|---|",
104+
(.[] | "| \(.vulnerability.severity) | [\(.vulnerability.id)](\(.vulnerability.dataSource)) | \(.artifact.name) (\(.artifact.type)) | \(.artifact.version) | \(.vulnerability.fix.versions | join(", ")) |")
105+
end' grype.json > table.md
106+
{
107+
echo "## Grype vulnerability scan (fixable only)"
108+
echo
109+
# PR comments are capped at 65536 characters
110+
head -c 60000 table.md
111+
echo
112+
echo "[Full scan output]($RUN_URL)"
113+
} > summary.md
114+
cat summary.md >> "$GITHUB_STEP_SUMMARY"
115+
116+
- name: Comment on PR
117+
if: github.event_name == 'pull_request' && env.CAN_WRITE == 'true'
118+
env:
119+
GH_TOKEN: ${{ github.token }}
120+
PR_NUMBER: ${{ github.event.pull_request.number }}
121+
run: |
122+
marker='<!-- grype-image-scan -->'
123+
printf '%s\n' "$marker" | cat - summary.md > comment.md
124+
comment_id=$(gh api --paginate "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" \
125+
--jq ".[] | select(.user.login == \"github-actions[bot]\" and (.body | startswith(\"$marker\"))) | .id" | head -n 1)
126+
if [ -n "$comment_id" ]; then
127+
gh api -X PATCH "repos/$GITHUB_REPOSITORY/issues/comments/$comment_id" -F body=@comment.md > /dev/null
128+
else
129+
gh api -X POST "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" -F body=@comment.md > /dev/null
130+
fi
64131
132+
# Merge queue refs are ephemeral; master results come from push/schedule
65133
- name: Upload SARIF result
66-
id: upload-sarif
67-
uses: github/codeql-action/upload-sarif@7434149006143a4d75b82a2f411ef15b03ccc2d7
134+
if: github.event_name != 'merge_group' && env.CAN_WRITE == 'true'
135+
uses: github/codeql-action/upload-sarif@38697555549f1db7851b81482ff19f1fa5c4fedc
68136
with:
69-
sarif_file: sarif.output.json
137+
sarif_file: grype.sarif
138+
category: grype-image-scan

‎.github/workflows/docs_deploy.yml‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ jobs:
1212
name: Build documentation
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
15+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
1616
with:
1717
persist-credentials: false
1818
- name: Install uv
19-
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b
19+
uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884
2020
with:
2121
enable-cache: true
22-
version: "0.11.14"
22+
version: "0.13.1"
2323
- name: Install Pandoc
2424
run: sudo apt-get install pandoc
2525
- name: Install model
@@ -29,7 +29,7 @@ jobs:
2929
cd doc
3030
uv run make html
3131
- name: Upload pages artifact
32-
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b
32+
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9
3333
with:
3434
path: doc/_build/html
3535

@@ -46,4 +46,4 @@ jobs:
4646
steps:
4747
- name: Deploy to GitHub Pages
4848
id: deployment
49-
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128
49+
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346

‎.github/workflows/docs_test.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ jobs:
1818
test-docs:
1919
runs-on: ubuntu-latest
2020
steps:
21-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
21+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
2222
with:
2323
persist-credentials: false
2424
- name: Install uv
25-
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b
25+
uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884
2626
with:
2727
enable-cache: true
28-
version: "0.11.14"
28+
version: "0.13.1"
2929
- name: Install Pandoc
3030
run: sudo apt-get install pandoc
3131
- name: Install model

‎.github/workflows/pip_audit.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ jobs:
2020
pull-requests: write
2121
runs-on: ubuntu-latest
2222
steps:
23-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
23+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
2424
with:
2525
persist-credentials: false
2626

2727
- name: Set up uv
28-
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b
28+
uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884
2929
with:
3030
enable-cache: true
31-
version: "0.11.14"
31+
version: "0.13.1"
3232

3333
- name: Install pip-audit and packaging
3434
run: |

‎.github/workflows/pr_tests.yml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ jobs:
3434
echo "Error: Add the 'long ci' label to this PR once it is ready for review."
3535
exit 1
3636
fi
37-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
37+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
3838
with:
3939
persist-credentials: false
4040
- name: Install uv
41-
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b
41+
uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884
4242
with:
4343
enable-cache: true
44-
version: "0.11.14"
44+
version: "0.13.1"
4545
- name: Install model
4646
run: USE_CYTHON=1 uv sync --frozen
4747
- name: Test ParCa reproducibility
@@ -82,14 +82,14 @@ jobs:
8282
echo "Error: Add the 'long ci' label to this PR once it is ready for review."
8383
exit 1
8484
fi
85-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
85+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
8686
with:
8787
persist-credentials: false
8888
- name: Install uv
89-
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b
89+
uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884
9090
with:
9191
enable-cache: true
92-
version: "0.11.14"
92+
version: "0.13.1"
9393
- name: Install model
9494
run: USE_CYTHON=1 uv sync --frozen
9595
- name: Install nextflow edge

‎.github/workflows/pytest.yml‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ jobs:
2020
Pytest:
2121
runs-on: ubuntu-latest
2222
steps:
23-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
23+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
2424
with:
2525
persist-credentials: false
2626
- name: Install uv
27-
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b
27+
uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884
2828
with:
2929
enable-cache: true
30-
version: "0.11.14"
30+
version: "0.13.1"
3131
- name: Install model
3232
run: USE_CYTHON=1 uv sync --frozen --extra dev
3333
- name: Cache ParCa simulation data
3434
id: cache-parca
35-
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7
35+
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9
3636
with:
3737
path: out/kb/*.cPickle
3838
key: parca-${{ hashFiles('reconstruction/ecoli/**/*.py', 'reconstruction/ecoli/**/*.tsv') }}
@@ -51,14 +51,14 @@ jobs:
5151
Mypy:
5252
runs-on: ubuntu-latest
5353
steps:
54-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
54+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
5555
with:
5656
persist-credentials: false
5757
- name: Install uv
58-
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b
58+
uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884
5959
with:
6060
enable-cache: true
61-
version: "0.11.14"
61+
version: "0.13.1"
6262
- name: Install model
6363
run: USE_CYTHON=1 uv sync --frozen --extra dev
6464
- name: Mypy
@@ -67,14 +67,14 @@ jobs:
6767
Lint:
6868
runs-on: ubuntu-latest
6969
steps:
70-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
70+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
7171
with:
7272
persist-credentials: false
7373
- name: Install uv
74-
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b
74+
uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884
7575
with:
7676
enable-cache: true
77-
version: "0.11.14"
77+
version: "0.13.1"
7878
- name: Install model
7979
run: USE_CYTHON=1 uv sync --frozen --extra dev
8080
- name: Ruff

‎.pre-commit-config.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
33
# Ruff version.
4-
rev: v0.15.4
4+
rev: v0.17.1
55
hooks:
66
# Run the linter.
77
- id: ruff

‎doc/ci.rst‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,31 @@ Container Vulnerability Scanning
8989
================================
9090

9191
The ``.github/workflows/docker_security.yml`` workflow builds a Docker image using
92-
``runscripts/container/Dockerfile`` and scans it for vulnerabilities using Docker Scout.
93-
This workflow is scheduled to run daily, and also runs on PRs and changes to ``master``.
92+
``runscripts/container/Dockerfile`` and scans it for vulnerabilities using
93+
`Grype <https://github.com/anchore/grype>`_. This workflow is scheduled to run daily, and also
94+
runs on PRs and changes to ``master``. Only vulnerabilities with available fixes are reported.
9495

95-
When run on PRs from branches in the main vEcoli repository, a comment will be added to the
96-
PR with a summary of the vulnerabilities found, including the severity and CVE identifiers as well
97-
as available fixes. We strongly recommend that you review this information and update the base
98-
container image (see below) if any vulnerabilities are found with available fixes.
96+
When run on PRs from branches in the main vEcoli repository, a comment will be added (and updated
97+
on later pushes) with a summary of the critical, high, and medium severity vulnerabilities found,
98+
including their identifiers and fixed versions. We strongly recommend that you review this
99+
information and update the base container image (see below) if any vulnerabilities are found with
100+
available fixes.
99101

100102
The daily runs on the ``master`` branch will generate a report that can be viewed by clicking on the
101103
"Actions" tab, "Docker Build and Security Scan" in the left sidebar, then a particular workflow run.
102104
Alternatively, members of the lab can view all detected vulnerabilities by clicking on the "Security
103105
and quality" tab, then "Code scanning" in the left sidebar.
104106

105-
.. warning::
106-
PRs from forks will not be able to run the Docker build and security scan workflow because it requires
107-
access to repository secrets (DockerHub credentials) not accessible to forks. Therefore, it is especially
108-
important to be wary of Docker image changes or dependency changes in PRs from forks, and to check the
109-
results of the daily runs on master for any vulnerabilities with available fixes.
107+
.. note::
108+
PRs from forks are also scanned, but because they only receive a read-only token, the results
109+
are only shown in the workflow run summary (no PR comment or code scanning upload). Be wary of
110+
Docker image or dependency changes in PRs from forks and check the run summary before merging.
111+
112+
Grype is installed from a pinned release whose SHA256 checksum is hardcoded in the workflow,
113+
rather than through a third-party action. To upgrade it, choose a release that has been public
114+
for at least a week or two, verify the Sigstore signature of ``grype_<version>_checksums.txt``
115+
(signed by ``https://github.com/anchore/grype/.github/workflows/release.yaml@refs/heads/main``),
116+
then update ``GRYPE_VERSION`` and ``GRYPE_SHA256`` with the ``linux_amd64.tar.gz`` checksum.
110117

111118
Update Container Base Image
112119
============================

‎pyproject.toml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,7 @@ packages = [
9393
"validation",
9494
"wholecell"
9595
]
96+
97+
[tool.ruff.lint]
98+
# Ruff 0.16 expanded the default rule set; keep the pre-0.16 defaults.
99+
select = ["E4", "E7", "E9", "F"]

0 commit comments

Comments
 (0)