-
Notifications
You must be signed in to change notification settings - Fork 49
Run CI dependency installs behind Socket Firewall (SFW) #1814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
39ab8d1
PoC: Socket Firewall (SFW) in audit mode on the ci workflow
nebasuke b09f7f0
PoC: use SFW firewall mode (Free has no audit mode)
nebasuke b9b0ea1
PoC: drop SFW CA discovery — rely on sfw's zero-config trust
nebasuke 39c41cd
TEMP: skip dependencies cache restore to force cold fetch through SFW
nebasuke 7e8c418
PoC: trust SFW CA system-wide for hermit's raw curl
nebasuke 8754c25
PoC: discover SFW CA via NODE_EXTRA_CA_CERTS, not a filename guess
nebasuke 091476e
PoC: merge SFW + system CA roots inside the wrap (option A)
nebasuke a20342e
Route dependency fetches through SFW across all CI workflows
nebasuke 813e12b
Trim SFW comments — mark only the deliberately-unwrapped calls
nebasuke e388a3f
Drop dead non-Linux handling from setup-sfw action
nebasuke 7b4533f
Drop the setup-sfw 'mode' input
nebasuke 54e9210
Drop inline 'not SFW-wrapped' markers
nebasuke ae6f9a0
Revert "TEMP: skip dependencies cache restore to force cold fetch thr…
nebasuke 05f965b
Drop the firewall-mode comment from setup-sfw
nebasuke 8eb19eb
Drop the Setup SFW route comment from ci.yml
nebasuke 01fbb9f
Drop the SFW_PREFIX explainer comment from ci.yml
nebasuke 11b7933
Strengthen setup-sfw: REQUESTS_CA_BUNDLE + document SFW_PREFIX contract
nebasuke 994ba5d
Rename Setup SFW steps; hard-fail SFW before publish
nebasuke 1c7d6fd
Soft-fail SFW; hard-fail only on the release path
nebasuke 25e4c7a
Require SFW by default; jobs opt out via the optional input
nebasuke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| name: "Setup Socket Firewall (SFW)" | ||
| description: > | ||
| Installs Socket Firewall Free and exports SFW_PREFIX, a wrapper that callers | ||
| prefix onto dependency commands to run installs behind the firewall (it also | ||
| fixes sfw's CA handling — see the wrapper step). | ||
| Fails the job if SFW can't be installed, so dependency installs never silently | ||
| run unprotected. Jobs where SFW is best-effort (a socket.dev outage must not | ||
| fail them) opt out with optional, which warns and leaves SFW_PREFIX unset | ||
| instead — callers then run unwrapped. | ||
|
|
||
| inputs: | ||
| optional: | ||
| description: > | ||
| When "true", a failed SFW install warns and leaves SFW_PREFIX unset | ||
| (callers run unprotected) instead of failing the job. | ||
| required: false | ||
| default: "false" | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: "Install SFW" | ||
| # Failures are decided by the wrapper step below, which knows the | ||
| # optional input — keep this step itself from failing the job. | ||
| continue-on-error: true | ||
| uses: "socketdev/action@937f824ec476dfd164d4a4d9995751427b0be143" # v1 | ||
| with: | ||
| mode: "firewall" | ||
|
|
||
| # sfw has no persistent CA file and overrides the CA env vars inside every | ||
| # wrap, so the union bundle must be built *inside* the wrap. Write a wrapper | ||
| # that does exactly that, then run it as `sfw <wrapper> <command>`: sfw injects | ||
| # its temp-CA env into the wrapper, which merges that root with the system | ||
| # bundle, re-points the CA vars at the union, and exec's the real command. | ||
| - name: "Create SFW CA-merge wrapper" | ||
| shell: "bash" | ||
| env: | ||
| SFW_OPTIONAL: "${{ inputs.optional }}" | ||
| run: | | ||
| if ! command -v sfw &>/dev/null; then | ||
| if [ "${SFW_OPTIONAL}" = "true" ]; then | ||
| echo "::warning::sfw not found after install — dependency installs will run UNPROTECTED." | ||
| exit 0 | ||
| fi | ||
| echo "::error::sfw not found after install — refusing to run dependency installs unprotected. Pass optional: \"true\" if this job may run without SFW." | ||
| exit 1 | ||
| fi | ||
| wrapper="${RUNNER_TEMP}/sfw-wrap" | ||
| cat > "${wrapper}" <<'EOF' | ||
| #!/usr/bin/env bash | ||
| # Invoked as: sfw sfw-wrap <command...>. sfw has injected SSL_CERT_FILE | ||
| # (and friends) pointing at a temp bundle that holds only its MITM root. | ||
| # Merge that root with the system roots so TLS works for both the hosts | ||
| # sfw MITMs (registries) and the ones it passes through (github.com etc.). | ||
| set -euo pipefail | ||
| if [ -n "${SSL_CERT_FILE:-}" ] && [ -f "${SSL_CERT_FILE}" ]; then | ||
| merged="$(mktemp)" | ||
| cat /etc/ssl/certs/ca-certificates.crt "${SSL_CERT_FILE}" > "${merged}" | ||
| # REQUESTS_CA_BUNDLE: pip/requests can ignore CURL_CA_BUNDLE inside a venv (pipenv) — psf/requests#6660. | ||
| export SSL_CERT_FILE="${merged}" CURL_CA_BUNDLE="${merged}" \ | ||
| CARGO_HTTP_CAINFO="${merged}" GIT_SSL_CAINFO="${merged}" \ | ||
| NODE_EXTRA_CA_CERTS="${merged}" REQUESTS_CA_BUNDLE="${merged}" | ||
| unset SSL_CERT_DIR | ||
| fi | ||
| exec "$@" | ||
| EOF | ||
| chmod +x "${wrapper}" | ||
| # Consumed UNQUOTED by callers (`${SFW_PREFIX:-} <cmd>`) so the shell splits | ||
| # it into two argv entries — `sfw` and the wrapper path. Quoting it breaks that; | ||
| # when unset (optional + failed install) it expands to nothing and <cmd> runs unwrapped. | ||
| echo "SFW_PREFIX=sfw ${wrapper}" >> "$GITHUB_ENV" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.