Skip to content

Commit b77634d

Browse files
leliaclaude
andcommitted
Harden Dependabot reviews and bundle dependency updates
Mirrors the Dependabot hardening done in socket-python-cli (#207/#217/#218), adapted to this SDK (no Dockerfile, no e2e fixtures, hatch/pip build path). Bundle dependency updates (supersedes 4 open Dependabot PRs): - idna 3.11 -> 3.17 (security: CVE-2026-45409 quadratic-time DoS fix) - cryptography 46.0.5 -> 46.0.7 - pygments 2.19.2 -> 2.20.0 - uv 0.9.21 -> 0.11.17 Verified via uv sync --locked, import smoke, and pytest tests/unit (102 passed). Adds grouped/cooldowned dependabot.yml (uv + github-actions), a dependabot-review workflow running anonymous Socket Firewall smoke jobs, Version Check / PR Preview skips for Dependabot PRs, and setup-sfw / setup-hatch composite actions. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent be87c34 commit b77634d

8 files changed

Lines changed: 345 additions & 94 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: "Set up Hatch build tooling"
2+
description: >-
3+
Install the pinned hatch / hatchling / virtualenv toolchain used to build
4+
and publish the package. Assumes Python is already set up by the caller.
5+
6+
runs:
7+
using: "composite"
8+
steps:
9+
- shell: bash
10+
run: |
11+
python -m pip install --upgrade pip
12+
pip install "virtualenv<20.36"
13+
pip install hatchling==1.27.0 hatch==1.14.0
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: "Set up Socket Firewall (free)"
2+
description: >-
3+
Set up the requested language toolchain and install Socket Firewall (free
4+
edition) so subsequent steps can run package-manager commands wrapped with
5+
`sfw`. Free/anonymous mode -- no API token, safe on untrusted/Dependabot PRs.
6+
7+
inputs:
8+
python:
9+
description: "Set up Python 3.12"
10+
default: "false"
11+
uv:
12+
description: "Install uv (implies Python)"
13+
default: "false"
14+
15+
runs:
16+
using: "composite"
17+
steps:
18+
- if: ${{ inputs.python == 'true' || inputs.uv == 'true' }}
19+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
20+
with:
21+
python-version: "3.12"
22+
23+
# Official Socket setup action. Wires up sfw routing correctly.
24+
- uses: socketdev/action@ba6de6cc0565af1f42295590380973573297e31f # v1.3.2
25+
with:
26+
mode: firewall-free
27+
28+
- if: ${{ inputs.uv == 'true' }}
29+
name: Install uv
30+
shell: bash
31+
run: python -m pip install --upgrade pip uv

.github/dependabot.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Dependabot configuration for socket-sdk-python.
2+
#
3+
# Design notes:
4+
# - Python deps are grouped into a weekly PR (minor/patch), with a
5+
# separate group for majors so breaking bumps stay reviewable.
6+
# - GitHub Actions are grouped similarly into one weekly PR, and Dependabot
7+
# scans both the workflows and the local composite actions.
8+
# - 7-day cooldown enforced across all ecosystems.
9+
# - This repo ships no Dockerfile, so there is no docker ecosystem entry.
10+
11+
version: 2
12+
updates:
13+
14+
# Python deps (uv-tracked via uv.lock)
15+
- package-ecosystem: "uv"
16+
directory: "/"
17+
schedule:
18+
interval: "weekly"
19+
open-pull-requests-limit: 2
20+
groups:
21+
python-minor-patch:
22+
patterns:
23+
- "*"
24+
update-types:
25+
- "minor"
26+
- "patch"
27+
python-major:
28+
patterns:
29+
- "*"
30+
update-types:
31+
- "major"
32+
labels:
33+
- "dependencies"
34+
- "python:uv"
35+
commit-message:
36+
prefix: "chore"
37+
include: "scope"
38+
cooldown:
39+
default-days: 7
40+
41+
# GitHub Actions used in workflows and local composite actions.
42+
- package-ecosystem: "github-actions"
43+
directories:
44+
- "/"
45+
- "/.github/actions/*"
46+
schedule:
47+
interval: "weekly"
48+
open-pull-requests-limit: 2
49+
groups:
50+
github-actions-minor-patch:
51+
patterns:
52+
- "*"
53+
update-types:
54+
- "minor"
55+
- "patch"
56+
labels:
57+
- "dependencies"
58+
- "github-actions"
59+
commit-message:
60+
prefix: "ci"
61+
include: "scope"
62+
cooldown:
63+
default-days: 7
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: dependabot-review
2+
3+
# Dependency-update PR guardrails for Dependabot-authored PRs.
4+
#
5+
# Runs only on PRs opened by dependabot[bot]. Inspects which files
6+
# changed, then conditionally runs a Socket Firewall (sfw) install smoke
7+
# job for the Python dependency set. Because sfw uses the free, anonymous
8+
# Socket public-data path it needs NO API key, so we can run it from the
9+
# unprivileged `pull_request` context without pull_request_target or any
10+
# of its security tradeoffs.
11+
#
12+
# Pattern adapted from SocketDev/socket-python-cli.
13+
14+
on:
15+
pull_request:
16+
types: [opened, synchronize, reopened, ready_for_review]
17+
18+
permissions:
19+
contents: read
20+
21+
concurrency:
22+
group: dependabot-review-${{ github.event.pull_request.number }}
23+
cancel-in-progress: true
24+
25+
jobs:
26+
inspect:
27+
if: github.event.pull_request.user.login == 'dependabot[bot]'
28+
runs-on: ubuntu-latest
29+
timeout-minutes: 5
30+
outputs:
31+
python_deps_changed: ${{ steps.diff.outputs.python_deps_changed }}
32+
workflow_or_action_changed: ${{ steps.diff.outputs.workflow_or_action_changed }}
33+
steps:
34+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
35+
with:
36+
fetch-depth: 0
37+
persist-credentials: false
38+
39+
- name: Inspect changed files
40+
id: diff
41+
env:
42+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
43+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
44+
run: |
45+
CHANGED_FILES="$(git diff --name-only "$BASE_SHA" "$HEAD_SHA")"
46+
47+
{
48+
echo "## Changed files"
49+
echo '```'
50+
printf '%s\n' "$CHANGED_FILES"
51+
echo '```'
52+
} >> "$GITHUB_STEP_SUMMARY"
53+
54+
has_file() {
55+
local pattern="$1"
56+
if printf '%s\n' "$CHANGED_FILES" | grep -Eq "$pattern"; then
57+
echo "true"
58+
else
59+
echo "false"
60+
fi
61+
}
62+
63+
{
64+
echo "python_deps_changed=$(has_file '^(pyproject\.toml|uv\.lock)$')"
65+
echo "workflow_or_action_changed=$(has_file '^\.github/workflows/|^\.github/actions/|^\.github/dependabot\.yml$')"
66+
} >> "$GITHUB_OUTPUT"
67+
68+
- name: Summarize review expectations
69+
env:
70+
PR_URL: ${{ github.event.pull_request.html_url }}
71+
run: |
72+
{
73+
echo "## Dependabot Review Checklist"
74+
echo "- PR: $PR_URL"
75+
echo "- Confirm upstream release notes before merge"
76+
echo "- Do not treat a Dependabot PR as trusted solely because of the actor"
77+
echo "- This workflow runs in pull_request context only; no publish secrets are exposed"
78+
} >> "$GITHUB_STEP_SUMMARY"
79+
80+
python-sfw-smoke:
81+
needs: inspect
82+
if: needs.inspect.outputs.python_deps_changed == 'true'
83+
runs-on: ubuntu-latest
84+
timeout-minutes: 15
85+
steps:
86+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
87+
with:
88+
fetch-depth: 1
89+
persist-credentials: false
90+
91+
- uses: ./.github/actions/setup-sfw
92+
with:
93+
uv: "true"
94+
95+
- name: Sync project through Socket Firewall
96+
# `sfw uv sync` is the intended way to route uv through Socket Firewall
97+
# (per Socket's own uv wrapper guidance). --locked verifies the exact
98+
# uv.lock set and fails on lockfile drift rather than silently
99+
# re-resolving, so the firewall inspects precisely what would install.
100+
# Note: uv's sfw integration is quieter than npm/pip -- it does not
101+
# print the "N packages fetched" footer, but interception is active.
102+
run: sfw uv sync --locked --extra test --extra dev
103+
104+
- name: Import smoke test
105+
run: |
106+
uv run python -c "
107+
import socketdev
108+
from socketdev import socketdev as SocketDevClient
109+
from socketdev.core.api import API
110+
from socketdev.version import __version__
111+
print('import smoke OK', __version__)
112+
"
113+
114+
workflow-notice:
115+
needs: inspect
116+
if: needs.inspect.outputs.workflow_or_action_changed == 'true'
117+
runs-on: ubuntu-latest
118+
timeout-minutes: 2
119+
steps:
120+
- name: Flag workflow-sensitive updates
121+
run: |
122+
{
123+
echo "## Sensitive File Notice"
124+
echo "This Dependabot PR changes workflow or dependabot config files."
125+
echo "Require explicit human review before merge."
126+
} >> "$GITHUB_STEP_SUMMARY"

.github/workflows/pr-preview.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,21 @@ on:
33
pull_request:
44
types: [opened, synchronize, ready_for_review]
55

6+
# Cancel an in-flight preview when the PR is pushed again -- previews publish
7+
# to Test PyPI, so superseded runs shouldn't keep churning.
8+
concurrency:
9+
group: pr-preview-${{ github.event.pull_request.number }}
10+
cancel-in-progress: true
11+
612
jobs:
713
preview:
14+
# Skip on:
15+
# - PRs from forks (no access to publish secrets / OIDC)
16+
# - Dependabot PRs: preview-publishing a dependency bump to Test PyPI is
17+
# pointless (no package version bump) and would fail the version check.
18+
if: >-
19+
github.event.pull_request.head.repo.full_name == github.repository &&
20+
github.event.pull_request.user.login != 'dependabot[bot]'
821
runs-on: ubuntu-latest
922
permissions:
1023
id-token: write
@@ -19,13 +32,8 @@ jobs:
1932
with:
2033
python-version: '3.13'
2134

22-
# Install all dependencies from pyproject.toml
23-
- name: Install dependencies
24-
run: |
25-
python -m pip install --upgrade pip
26-
pip install "virtualenv<20.36"
27-
pip install hatchling==1.27.0
28-
pip install hatch==1.14.0
35+
- name: Install build tooling
36+
uses: ./.github/actions/setup-hatch
2937

3038
- name: Inject full dynamic version
3139
run: python .hooks/sync_version.py --dev

.github/workflows/release.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,9 @@ jobs:
1818
with:
1919
python-version: '3.13'
2020

21-
# Install all dependencies from pyproject.toml
22-
- name: Install dependencies
23-
run: |
24-
python -m pip install --upgrade pip
25-
pip install "virtualenv<20.36"
26-
pip install hatchling==1.27.0
27-
pip install hatch==1.14.0
28-
21+
- name: Install build tooling
22+
uses: ./.github/actions/setup-hatch
23+
2924
- name: Get Version
3025
id: version
3126
env:

.github/workflows/version-check.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ permissions:
1414

1515
jobs:
1616
check_version:
17+
# Skip on Dependabot PRs: they bump dependencies (touching uv.lock /
18+
# pyproject.toml) without bumping the package version, so the increment
19+
# check would always fail. Package-version bumps come from maintainer PRs.
20+
if: github.event.pull_request.user.login != 'dependabot[bot]'
1721
runs-on: ubuntu-latest
1822
steps:
1923
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

0 commit comments

Comments
 (0)