fix(staging): wire OFFSEC-010 CP config + CWE-78 rows.Err fixes #1078

Merged
devops-engineer merged 5 commits from fix/staging-offsec010-cp-wiring into staging 2026-05-15 00:05:54 +00:00

5 Commits

Author SHA1 Message Date
e9693e12ff fix(handlers): add rows.Err() checks across approvals, tokens, instructions
Some checks failed
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 21s
CI / Detect changes (pull_request) Successful in 52s
Harness Replays / detect-changes (pull_request) Successful in 19s
E2E API Smoke Test / detect-changes (pull_request) Successful in 53s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 21s
gate-check-v3 / gate-check (pull_request) Successful in 23s
qa-review / approved (pull_request) Successful in 25s
security-review / approved (pull_request) Successful in 22s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 59s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 55s
sop-tier-check / tier-check (pull_request) Successful in 25s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m27s
CI / Canvas (Next.js) (pull_request) Successful in 12s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 7s
CI / Python Lint & Test (pull_request) Successful in 7s
Harness Replays / Harness Replays (pull_request) Successful in 7s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 8s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 2m17s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 5m39s
sop-checklist / all-items-acked (pull_request) [info tier:low] acked: 2/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +2 — body-unfilled: comprehensive-testing, l
CI / Platform (Go) (pull_request) Failing after 8m46s
CI / all-required (pull_request) Successful in 9s
audit-force-merge / audit (pull_request) Successful in 24s
Standard CWE-78 pattern (same class as CWE-78-rows-err hotfix #1071):
iterating over sql.Rows without checking rows.Err() after the loop silently
ignores connection errors. Add the deferred Err() check to:

- approvals.go: ListPendingApprovals (GET /approvals)
- approvals.go: List (GET /workspaces/:id/approvals)
- tokens.go: List (GET /workspaces/:id/tokens)
- instructions.go: Resolve handler (GET /workspaces/:id/instructions/resolve)
- instructions.go: scanInstructions helper (used by List handler)

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-05-14 23:22:18 +00:00
bcca139caa fix(handlers): add rows.Err() checks to loadWorkspaceSecrets
Some checks failed
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 13s
Harness Replays / detect-changes (pull_request) Successful in 10s
CI / Detect changes (pull_request) Successful in 15s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 14s
E2E API Smoke Test / detect-changes (pull_request) Successful in 16s
gate-check-v3 / gate-check (pull_request) Successful in 15s
security-review / approved (pull_request) Successful in 15s
qa-review / approved (pull_request) Successful in 15s
sop-checklist / all-items-acked (pull_request) Successful in 17s
sop-tier-check / tier-check (pull_request) Successful in 18s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 20s
Harness Replays / Harness Replays (pull_request) Successful in 5s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 21s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 4s
CI / Python Lint & Test (pull_request) Successful in 3s
CI / Canvas (Next.js) (pull_request) Successful in 4s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 3s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m11s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 1m47s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 4m28s
CI / Platform (Go) (pull_request) Failing after 9m12s
CI / all-required (pull_request) Successful in 6s
loadWorkspaceSecrets() iterates over global_secrets and
workspace_secrets rows without checking rows.Err() after the loop.
If the connection is interrupted mid-iteration, the error is silently
ignored. Add the standard deferred Err() check (pattern from
secrets.go, org_helpers.go) to both loops.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-05-14 23:18:12 +00:00
6cf6e608d8 fix(staging): add isCPTemplateConfigFile filter to collectCPConfigFiles
Cherry-picks the filter from main commit 8fced202: only transport
config.yaml and files under prompts/ from the template directory to the
control plane. Arbitrary template files (adapter.py, Dockerfile, etc.)
are now excluded regardless of size, reducing the transport surface.

Also adds a test case verifying adapter.py is excluded even when within
the size limit.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-05-14 23:18:12 +00:00
6947774e1b fix(staging): wire collectCPConfigFiles into CPProvisioner.Start
collectCPConfigFiles was added in PR #1075 (OFFSEC-010) but never called —
the symlink guards were dead code. This patch wires the function into
CPProvisioner.Start so the guards actually protect the CP request path.

Changes:
1. cpProvisionRequest gains ConfigFiles map[string]string field
   (base64-encoded, same shape as Docker provisioner's WriteFilesToContainer)
2. Start calls collectCPConfigFiles(cfg) before building the request;
   errors propagate as hard failures (a workspace without its config files
   is not usable)
3. Two new tests:
   - TestStart_CollectsConfigFiles: verifies TemplatePath files AND
     ConfigFiles map appear in the CP request body, base64-encoded
   - TestStart_SymlinkTemplatePathError: verifies a symlink TemplatePath
     causes Start to fail, exercising the OFFSEC-010 root-symlink guard

Without this wiring, a malicious operator could bypass the WalkDir symlink
guards by passing TemplatePath as a symlink to the CP.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 23:18:12 +00:00
9afecfdfc7 Resolve conflict: keep OFFSEC-010 collectCPConfigFiles with ce542cb26 nil-return fix 2026-05-14 23:18:12 +00:00