-
Notifications
You must be signed in to change notification settings - Fork 13
ci: add Socket Firewall to Emulate workflows #103
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
Open
peakematt
wants to merge
7
commits into
main
Choose a base branch
from
sfw/emulate-protection
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+322
−19
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8420584
Add Socket Firewall to Emulate workflows
peakematt c7b598b
Cover Bun cross-compile downloads
peakematt 9a58f38
Protect Docker Bun installs with BuildKit SFW config
peakematt 391f94f
Add pre-publication Docker image secret scans
peakematt 0631dd6
Fix SFW image scan needle extraction
peakematt 878d21f
Remove recurring image scan gates
peakematt bfaab74
pi: address PR review feedback (#103)
peakematt 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,10 @@ | ||
| # syntax=docker/dockerfile:1 | ||
|
|
||
| # CI/release callers pass Bun's Socket Firewall config as a BuildKit secret and | ||
| # set SFW_REQUIRED=true. Local Docker builds omit both and keep using Bun's | ||
| # normal public-registry configuration. | ||
| ARG SFW_REQUIRED=false | ||
|
|
||
| # Build stage: compile TypeScript to dist/ from the bun lockfile. | ||
| # bun.lock pins tree-sitter-kotlin (a transitive devDep via @workos/openapi-spec | ||
| # -> @workos/oagen) to a git+ssh URL that can't clone inside the image without | ||
|
|
@@ -9,9 +14,19 @@ | |
| # other dependency — including typescript@5.9.3 — stays at its locked version, | ||
| # keeping the build reproducible. | ||
| FROM oven/bun:1.3.14 AS builder | ||
| ARG SFW_REQUIRED | ||
| WORKDIR /app | ||
| COPY package.json bun.lock ./ | ||
| RUN sed -i \ | ||
| RUN --mount=type=secret,id=sfw_bunfig,target=/run/secrets/.bunfig.toml \ | ||
| set -eu; \ | ||
| if [ "${SFW_REQUIRED:-false}" = "true" ] && [ ! -s /run/secrets/.bunfig.toml ]; then \ | ||
| echo "Socket Firewall Bun config secret is required for Docker dependency installs." >&2; \ | ||
| exit 1; \ | ||
| fi; \ | ||
| if [ -s /run/secrets/.bunfig.toml ]; then \ | ||
| export XDG_CONFIG_HOME=/run/secrets; \ | ||
| fi; \ | ||
| sed -i \ | ||
| -e 's|git+ssh://git@github.com/fwcd/tree-sitter-kotlin.git#|github:fwcd/tree-sitter-kotlin#|g' \ | ||
| -e 's/"sha512-onbog[^"]*"/""/g' \ | ||
| bun.lock \ | ||
|
Comment on lines
+29
to
32
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
@@ -24,9 +39,19 @@ RUN bun run build | |
| # This stage only needs production deps (no git+ssh transitive devDeps), so | ||
| # the bun lockfile works correctly. | ||
| FROM oven/bun:1.3.14 AS deps | ||
| ARG SFW_REQUIRED | ||
| WORKDIR /app | ||
| COPY package.json bun.lock ./ | ||
| RUN bun install --frozen-lockfile --production --ignore-scripts | ||
| RUN --mount=type=secret,id=sfw_bunfig,target=/run/secrets/.bunfig.toml \ | ||
| set -eu; \ | ||
| if [ "${SFW_REQUIRED:-false}" = "true" ] && [ ! -s /run/secrets/.bunfig.toml ]; then \ | ||
| echo "Socket Firewall Bun config secret is required for Docker dependency installs." >&2; \ | ||
| exit 1; \ | ||
| fi; \ | ||
| if [ -s /run/secrets/.bunfig.toml ]; then \ | ||
| export XDG_CONFIG_HOME=/run/secrets; \ | ||
| fi; \ | ||
| bun install --frozen-lockfile --production --ignore-scripts | ||
|
|
||
| # Runtime stage: minimal Node image with only what the emulator needs. | ||
| FROM node:22-alpine | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The release job now pushes the authenticated multi-platform image directly after removing the pre-publication scan of its layers and metadata. If BuildKit or a future Dockerfile change embeds the Socket Firewall token or configuration in an image layer, the workflow will publish that secret to GHCR without detecting it. Removing the runner configuration afterward cannot remove material already stored in the published image.
How this was verified: The workflow passes the private Bun configuration into the Docker build and pushes its output before performing any inspection capable of detecting the credential in image layers or metadata.
Prompt To Fix With AI