Skip to content

Commit bc8ad5b

Browse files
SeanMeyerclaude
andcommitted
[Security] Add pip cooldown (2-day age gate) to CI workflows
Every CI job now computes a 2-day-old cutoff timestamp and passes --uploaded-prior-to to all pip install commands. This refuses any PyPI package published less than 2 days ago, blocking freshly- published malicious versions from entering CI builds. Workflows updated: - reusable-python-test.yml (unit tests) - reusable-integration-test.yml (integration tests) - reusable-examples.yml (example checks) - reusable-pre-commit.yml (pre-commit hooks) - docs.yml (documentation build) - publish.yml (release publishing) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e69bd3c commit bc8ad5b

File tree

6 files changed

+27
-13
lines changed

6 files changed

+27
-13
lines changed

.github/workflows/docs.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@ jobs:
2727
python-version: "3.11"
2828
cache: "pip"
2929

30+
- name: Set pip cooldown (2 days)
31+
run: echo "PIP_UPLOADED_PRIOR_TO=$(date -u -d '2 days ago' +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_ENV
32+
3033
- name: Upgrade Python packaging tools
31-
run: pip install --disable-pip-version-check --upgrade pip setuptools wheel
34+
run: pip install --disable-pip-version-check --uploaded-prior-to "$PIP_UPLOADED_PRIOR_TO" --upgrade pip setuptools wheel
3235

3336
- name: Install tox
34-
run: pip install tox
37+
run: pip install --uploaded-prior-to "$PIP_UPLOADED_PRIOR_TO" tox
3538

3639
- name: set SPHINX_VERSION
3740
run: |

.github/workflows/publish.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ jobs:
2828
python-version: "3.11"
2929
cache: "pip"
3030

31+
- name: Set pip cooldown (2 days)
32+
run: echo "PIP_UPLOADED_PRIOR_TO=$(date -u -d '2 days ago' +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_ENV
33+
3134
- name: Releasing tag ${{ github.event.release.tag_name }}
3235
run: |
3336
# Get tag name from event
@@ -38,7 +41,7 @@ jobs:
3841
fi
3942
4043
# Install pypa/build
41-
python -m pip install build --user
44+
python -m pip install --uploaded-prior-to "$PIP_UPLOADED_PRIOR_TO" build --user
4245
4346
# Build a binary wheel and a source tarball
4447
python -m build --sdist --wheel --outdir dist/ .

.github/workflows/reusable-examples.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ jobs:
3232
with:
3333
python-version: ${{ inputs.python-version }}
3434
cache: "pip"
35+
- name: Set pip cooldown (2 days)
36+
run: echo "PIP_UPLOADED_PRIOR_TO=$(date -u -d '2 days ago' +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_ENV
3537
- name: Upgrade pip
3638
run: |
37-
python -m pip install --upgrade pip
38-
pip install --upgrade wheel setuptools build
39+
python -m pip install --uploaded-prior-to "$PIP_UPLOADED_PRIOR_TO" --upgrade pip
40+
pip install --uploaded-prior-to "$PIP_UPLOADED_PRIOR_TO" --upgrade wheel setuptools build
3941
- name: Install
40-
run: pip install --disable-pip-version-check pyflakes
42+
run: pip install --disable-pip-version-check --uploaded-prior-to "$PIP_UPLOADED_PRIOR_TO" pyflakes
4143
- name: Check examples
4244
run: ${{ inputs.examples-script }}
4345
shell: bash

.github/workflows/reusable-integration-test.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,14 @@ jobs:
108108
with:
109109
python-version: "3.12"
110110
cache: "pip"
111+
- name: Set pip cooldown (2 days)
112+
run: echo "PIP_UPLOADED_PRIOR_TO=$(date -u -d '2 days ago' +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_ENV
111113
- name: Upgrade pip
112114
run: |
113-
python -m pip install --upgrade pip
114-
pip install --upgrade wheel setuptools build
115+
python -m pip install --uploaded-prior-to "$PIP_UPLOADED_PRIOR_TO" --upgrade pip
116+
pip install --uploaded-prior-to "$PIP_UPLOADED_PRIOR_TO" --upgrade wheel setuptools build
115117
- name: Install
116-
run: pip install --disable-pip-version-check -e .[apm,tests]
118+
run: pip install --disable-pip-version-check --uploaded-prior-to "$PIP_UPLOADED_PRIOR_TO" -e .[apm,tests]
117119
- name: Test
118120
run: ./run-tests.sh
119121
shell: bash

.github/workflows/reusable-pre-commit.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ jobs:
4343
- uses: actions/setup-python@v4
4444
with:
4545
python-version: '3.11'
46+
- name: Set pip cooldown (2 days)
47+
run: echo "PIP_UPLOADED_PRIOR_TO=$(date -u -d '2 days ago' +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_ENV
4648
- name: Install pre-commit
47-
run: python -m pip install pre-commit
49+
run: python -m pip install --uploaded-prior-to "$PIP_UPLOADED_PRIOR_TO" pre-commit
4850
- name: set PY
4951
run: echo "PY=$(python -c 'import platform;print(platform.python_version())')" >> $GITHUB_ENV
5052
- uses: actions/cache@v3

.github/workflows/reusable-python-test.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@ jobs:
4848
with:
4949
python-version: ${{ matrix.python-version }}
5050
cache: "pip"
51+
- name: Set pip cooldown (2 days)
52+
run: echo "PIP_UPLOADED_PRIOR_TO=$(date -u -d '2 days ago' +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_ENV
5153
- name: Upgrade pip
5254
run: |
53-
python -m pip install --upgrade pip
54-
pip install --upgrade wheel setuptools build
55+
python -m pip install --uploaded-prior-to "$PIP_UPLOADED_PRIOR_TO" --upgrade pip
56+
pip install --uploaded-prior-to "$PIP_UPLOADED_PRIOR_TO" --upgrade wheel setuptools build
5557
- name: Install
56-
run: pip install --disable-pip-version-check -e .[tests]
58+
run: pip install --disable-pip-version-check --uploaded-prior-to "$PIP_UPLOADED_PRIOR_TO" -e .[tests]
5759
- name: Test
5860
run: ./run-tests.sh
5961
shell: bash

0 commit comments

Comments
 (0)