Skip to content

Dependabot hardening and workflow pipeline cleanup#217

Open
lelia wants to merge 11 commits into
mainfrom
lelia/fix-dependabot-checks
Open

Dependabot hardening and workflow pipeline cleanup#217
lelia wants to merge 11 commits into
mainfrom
lelia/fix-dependabot-checks

Conversation

@lelia
Copy link
Copy Markdown
Contributor

@lelia lelia commented May 29, 2026

Summary

Follow-up to #207. Once the Dependabot review hardening ran on real Dependabot PRs (#212, #213, #215, #216), a few CI issues surfaced. This PR fixes those checks and also folds in the workflow pipeline cleanup from #218 so there is one PR to review and merge.

Dependabot PR behavior

  • Skip PR Preview on Dependabot PRs because dependency bumps do not carry a package version bump and should not need publish secrets.
  • Skip Version Check on Dependabot PRs because uv.lock / pyproject.toml bumps do not require an app-version increment.
  • Keep those jobs fully active for maintainer-authored PRs.
  • Keep dependabot-review.yml as the unprivileged pull_request guardrail for Dependabot-authored dependency changes.
  • Treat .github/actions/** changes as workflow-sensitive in the Dependabot review notice, alongside .github/workflows/** and .github/dependabot.yml.

Socket Firewall smoke checks

  • Use the official socketdev/action setup in firewall-free mode instead of npm install -g sfw.
  • Centralize Socket Firewall setup in .github/actions/setup-sfw.
  • Run sfw uv sync --locked --extra test --extra dev so the Python smoke check verifies the checked-in uv.lock set instead of silently re-resolving.
  • Keep npm fixture checks on Node 20 and Python fixture checks on Python 3.12.

Workflow pipeline cleanup

  • Add local composite actions for repeated setup:
    • .github/actions/setup-sfw
    • .github/actions/setup-docker-publish
    • .github/actions/setup-hatch
  • Add PR Preview concurrency so superseded preview runs are cancelled when a PR is pushed again.
  • Keep Docker build-push layer caching on preview, release, and stable image builds.
  • Make PR Preview publish/build only linux/amd64; release and stable Docker publishing still build linux/amd64,linux/arm64.

Dependabot composite-action coverage

The github-actions Dependabot entry now uses directories instead of a single directory:

directories:
  - "/"
  - "/.github/actions/*"

Per GitHub's Dependabot options reference, / scans /.github/workflows plus root action metadata, and directories can list additional locations with wildcard support. That lets Dependabot scan action pins inside our local composite actions too.

Test plan

  • actionlint -shellcheck= .github/workflows/*.yml
  • actionlint .github/workflows/dependabot-review.yml
  • YAML parse for .github/dependabot.yml and local composite action.yml files
  • git diff --check
  • Next Dependabot PR: preview + check_version show skipped; relevant dependabot-review smoke job runs
  • Next GitHub Actions Dependabot run: workflow and .github/actions/* action pins are considered for updates
  • Human PR: preview + check_version still run as before

Both workflows failed on every Dependabot PR for reasons that don't apply to
dependency bumps:

- PR Preview publishes a dev build to Test PyPI + Docker Hub. On a dependency
  bump there's no version change, so the publish 400s ("File already exists")
  -- and it needs publish secrets a Dependabot PR shouldn't carry anyway.
- Version Check requires an incremented app version, but Dependabot PRs touch
  uv.lock / pyproject.toml without bumping socketsecurity's version, so the
  check always fails.

Add a job-level `if` to skip each on `dependabot[bot]`-authored PRs (same
pattern already used for e2e-test.yml). Job-level skips report as "skipped"
rather than blocking, and these stay required for human-authored PRs.

Follow-up to #207 (the Dependabot review hardening), addressing fallout
observed once that config went live on real Dependabot PRs.

Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
@lelia lelia requested a review from a team as a code owner May 29, 2026 22:51
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 29, 2026

🚀 Preview package published!

Install with:

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple socketsecurity==2.3.0.dev19

Docker image: socketdev/cli:pr-217

@lelia lelia changed the title Skip PR Preview and Version Check on Dependabot PRs Dependabot review workflow fixes May 29, 2026
lelia added 2 commits May 29, 2026 19:06
`sfw uv sync` is the intended way to route uv through Socket Firewall (per
Socket's own uv-wrapper guidance), so the python-sfw-smoke job was already
exercising the firewall -- uv's integration is just quieter than npm/pip
(no "N packages fetched" footer), which made it look like a no-op.

Add `--locked` so the check verifies the exact uv.lock set and fails on
lockfile drift instead of silently re-resolving to newer versions than the
PR locked. This makes the firewall inspect precisely what would be installed
and aligns with the deterministic-verification guidance for uv-based repos.

Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
Replace the hand-rolled `npm install -g sfw` in all three sfw smoke jobs with
the official setup action (socketdev/action@v1.3.2, mode: firewall-free).

Why:
- It's the documented GitHub Actions integration for Socket Firewall Free and
  wires up sfw routing correctly, rather than relying on an ad-hoc global npm
  install. This is the right mitigation for the class of Wrapper-Mode routing
  gaps where sfw can fail to proxy fetches from files.pythonhosted.org
  (tracked upstream as ENG-4871) -- exactly the "no interception" symptom that
  made the python job look like a no-op.
- The Python jobs no longer need actions/setup-node at all (the action
  provides sfw directly), so those steps are dropped; the npm fixture job keeps
  setup-node since `npm install` needs it.

Setup mode is firewall-free (anonymous, no API token) -- unchanged, and the
reason this is safe to run on Dependabot/untrusted PRs.

Our setup is Wrapper Mode + free edition + no CodeArtifact, so the Registry
Mode + CodeArtifact `uv sync`/`uv lock` issue (CE-171) does not apply.

Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
@lelia lelia changed the title Dependabot review workflow fixes Harden Dependabot CI: skip Preview/Version Check, adopt official Socket Firewall action May 29, 2026
@lelia lelia changed the title Harden Dependabot CI: skip Preview/Version Check, adopt official Socket Firewall action Dependabot hardening: Fix CI checks, adopt sfw-action May 29, 2026
The three sfw smoke jobs (python / npm-fixture / pypi-fixture) repeated the
same setup: toolchain bootstrap + socketdev/action install. GitHub Actions
doesn't support YAML anchors, so extract the shared setup into a local
composite action instead.

- New .github/actions/setup-sfw: optional Python/Node/uv toolchain inputs +
  the socketdev/action (firewall-free) install.
- Each job now just declares the toolchain it needs (`uv`, `node`, or
  `python`) and runs its own distinct sfw command.

Net effect: the pinned socketdev/action SHA now lives in ONE place (future
bumps touch a single line), the per-job setup-python/setup-node duplication
is gone, and each job body is reduced to its actual firewall check. No
behavior change.

Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
@lelia lelia added enhancement New feature or request dependencies Pull requests that update a dependency file labels May 31, 2026
Performance (PR preview, the iterative-feedback path):
- Add a concurrency group with cancel-in-progress so pushing a PR again
  cancels the superseded (slow) preview run instead of letting it churn.
- Build preview images amd64-only. arm64 under QEMU emulation was the
  slowest part of the job, and preview images are for quick testing;
  release/stable keep multi-arch.
- Enable GitHub Actions Docker layer cache (type=gha) on all image builds
  so unchanged layers are reused across runs.

De-duplication (GitHub Actions has no YAML anchors, so use composite actions):
- New .github/actions/setup-docker-publish: the QEMU + Buildx + Docker Hub
  login trio, shared by release.yml, pr-preview.yml, and docker-stable.yml.
  These had drifted to three different pinned SHA sets; now there is one.
  (Docker Hub creds are passed as inputs since composite actions can't read
  secrets directly.)
- New .github/actions/setup-hatch: the pinned virtualenv/hatchling/hatch
  install shared by release.yml and pr-preview.yml.

No behavior change to what gets published; only how the pipelines are
assembled and how fast/parallel they run.

Stacked on #217 (lelia/fix-dependabot-checks) to avoid a pr-preview.yml
conflict with that PR's Dependabot skip; rebase onto main once #217 lands.

Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
@lelia lelia mentioned this pull request May 31, 2026
5 tasks
Bump every third-party action to its latest git-tagged release, pinned to
the resolved commit SHA with a trailing '# vX.Y.Z' comment for readability:

  actions/checkout              -> v6.0.2
  actions/setup-python          -> v6.2.0
  actions/setup-node            -> v6.4.0
  actions/github-script         -> v9.0.0
  pypa/gh-action-pypi-publish   -> v1.14.0
  docker/setup-qemu-action      -> v4.1.0
  docker/setup-buildx-action    -> v4.1.0
  docker/login-action           -> v4.2.0
  docker/build-push-action      -> v7.2.0
  socketdev/action              -> v1.3.2 (comment only)

Applied across the setup-sfw composite action and all workflows, including
docker-stable.yml which previously used floating major-version comments.

Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
@socket-security-staging
Copy link
Copy Markdown

socket-security-staging Bot commented May 31, 2026

@socket-security-staging
Copy link
Copy Markdown

socket-security-staging Bot commented May 31, 2026

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

Ignoring alerts on:

  • github/actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd

View full report

lelia added 2 commits May 31, 2026 00:36
…' into lelia/fix-dependabot-checks

# Conflicts:
#	.github/workflows/docker-stable.yml
#	.github/workflows/pr-preview.yml
#	.github/workflows/release.yml
@lelia lelia changed the title Dependabot hardening: Fix CI checks, adopt sfw-action Dependabot hardening and workflow pipeline cleanup May 31, 2026
@lelia
Copy link
Copy Markdown
Contributor Author

lelia commented May 31, 2026

@SocketSecurity-Staging ignore github/actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant