fix(ci): address AI review findings (credentials, supply chain)
PR Check / Security scan (Snyk) (pull_request) Skipped
PR Check / ESLint (pull_request) Successful in 33s
PR Check / Typecheck (pull_request) Successful in 38s
PR Check / Secret scan (gitleaks) (pull_request) Successful in 5s
PR Check / Dependency audit (pull_request) Failing after 9s
PR Check / Dockerfile lint (droast) (pull_request) Failing after 4s
PR Check / AI code review (opencode) (pull_request) Failing after 3m9s

- [BLOCKER] remove opencode.json from the checkout: it held the API
  key in plaintext, readable by the review agent, and a malicious PR
  diff could prompt-inject the agent into quoting it in the publicly
  visible review comment. Env-only auth (verified headless). The
  permission config moves to $HOME/.config/opencode - outside the
  checkout and secret-free.
- [WARN] verify the droast binary against the publisher's
  sha256sums.txt of the same pinned release
- [WARN] pin the opencode v2 installer to 2.0.32

Findings validated with the validate-pr-review skill; findings 4/5
are moot with the blocker fix.
This commit is contained in:
Noel Sabia committed 2026-10-18 17:54:06 +02:00
1 parent f8d128705f
commit 85f488a94d
1 file changed
+21 -17
+21 -17
View File
@@ -132,8 +132,11 @@ jobs:
esac esac
curl -fsSL -o /usr/local/bin/droast \ curl -fsSL -o /usr/local/bin/droast \
"https://github.com/immanuwell/dockerfile-roast/releases/download/1.7.0/${DROAST_ASSET}" "https://github.com/immanuwell/dockerfile-roast/releases/download/1.7.0/${DROAST_ASSET}"
chmod +x /usr/local/bin/droast # verify against the publisher's checksum file of the same pinned
droast --version # release (upstream sha256sums.txt matches our own verification)
curl -fsSL -o /tmp/droast-sha256sums.txt \
"https://github.com/immanuwell/dockerfile-roast/releases/download/1.7.0/sha256sums.txt"
echo "$(grep "${DROAST_ASSET}\$" /tmp/droast-sha256sums.txt)" | (cd /usr/local/bin && sha256sum -c -)
- name: Discover Dockerfiles - name: Discover Dockerfiles
id: discover id: discover
@@ -215,10 +218,12 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- name: Install opencode CLI - name: Install opencode CLI
run: curl -fsSL https://opencode.ai/v2/install | bash run: curl -fsSL https://opencode.ai/v2/install | bash -s -- -v 2.0.32
# v2 installer is required: the classic /install URL ships only # v2 installer is required: the classic /install URL ships only
# OpenCode 1.x (resolved to v1.19.3 on arm64), which cannot resolve # OpenCode 1.x (resolved to v1.19.3 on arm64), which cannot resolve
# model variants like "#max" and failed with ProviderModelNotFoundError # model variants like "#max" and failed with ProviderModelNotFoundError.
# Version pinned (-v 2.0.32) so a breaking v2 release cannot fail
# the job mid-PR; bump deliberately, not automatically.
- name: Get PR diff - name: Get PR diff
run: | run: |
@@ -242,28 +247,27 @@ jobs:
# "opencode-go", NOT "opencode" (Zen is a different, pay-per-call # "opencode-go", NOT "opencode" (Zen is a different, pay-per-call
# provider and fails with 'Insufficient account funds'). # provider and fails with 'Insufficient account funds').
# #
# Belt and suspenders on auth: OPENCODE_API_KEY is exported for # Auth is env-only: the CLI picks up OPENCODE_API_KEY from the
# env-based pickup, AND an opencode.json is generated that binds # environment (verified headless). Deliberately NO opencode.json:
# the key to the opencode-go provider explicitly - so headless CI # a config file in the checkout would hold the API key in
# never depends on env-var mapping behavior. # plaintext, readable by the agent - a malicious PR diff could
# prompt-inject the agent into quoting the key in the review
# comment (publicly visible). Env vars are invisible to file reads.
# Permissions live in a global config OUTSIDE the checkout (no
# secrets in it, so nothing can leak): denying edit/bash/webfetch
# means no headless permission prompts can hang or kill the run,
# and the reviewer physically cannot modify the repo.
mkdir -p "$HOME/.config/opencode"
printf '{ printf '{
"$schema": "https://opencode.ai/config.json", "$schema": "https://opencode.ai/config.json",
"provider": {
"opencode-go": {
"options": { "apiKey": "%s" }
}
},
"permission": { "permission": {
"edit": "deny", "edit": "deny",
"bash": "deny", "bash": "deny",
"webfetch": "deny" "webfetch": "deny"
} }
}' "$OPENCODE_API_KEY" > opencode.json }' > "$HOME/.config/opencode/opencode.json"
# --print-logs: surface auth/provider errors in the CI log instead # --print-logs: surface auth/provider errors in the CI log instead
# of failing with an opaque exit code # of failing with an opaque exit code
# Read-only agent: denying edit/bash/webfetch means no headless
# permission prompts can hang or kill the run, and the reviewer
# physically cannot modify the repo.
EXIT_CODE=0 EXIT_CODE=0
opencode run \ opencode run \
--print-logs \ --print-logs \