Skip to content

Commit c8ef4d1

Browse files
committed
fix(review): require host-owned secret scanning
Provision pinned TruffleHog in the shared worker bootstrap and require complete native review-input scans before model calls or cached success. Preserve fail-closed scanning, read-only workers, and existing proxy authentication; cover raw before/after/index content, normalization, deadlines, and redacted refusal paths. The ClawSweeper limitation on Crabbox's UUID inspection repair exposed the missing dependency: openclaw/crabbox#1590 (comment) . No Crabbox implementation changes are included.
1 parent b1d6b85 commit c8ef4d1

39 files changed

Lines changed: 2217 additions & 319 deletions

‎.github/actions/setup-codex/action.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ inputs:
2222
runs:
2323
using: composite
2424
steps:
25+
- name: Install trusted review scanner
26+
shell: bash
27+
run: bash "${{ github.action_path }}/../setup-review-tools/install.sh"
28+
2529
- name: Cache Codex CLI and npm downloads
2630
uses: actions/cache@v6
2731
with:

‎.github/actions/setup-openclaw/action.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ inputs:
1313
runs:
1414
using: composite
1515
steps:
16+
- name: Install trusted review scanner
17+
if: ${{ env.CLAWSWEEPER_RUNNER == 'openclaw' }}
18+
shell: bash
19+
run: bash "${{ github.action_path }}/../setup-review-tools/install.sh"
20+
1621
- name: Cache OpenClaw CLI and npm downloads
1722
if: ${{ env.CLAWSWEEPER_RUNNER == 'openclaw' }}
1823
uses: actions/cache@v6
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Only this official platform archive has been pinned and verified.
5+
if [[ "$(uname -s)" != Linux || "$(uname -m)" != x86_64 ]]; then
6+
echo "Trusted review scanner bootstrap supports Linux amd64 only." >&2
7+
exit 1
8+
fi
9+
10+
review_tools_root="$(mktemp -d "${RUNNER_TEMP:?}/clawsweeper-review-tools.XXXXXX")"
11+
case "$review_tools_root/" in
12+
"${GITHUB_WORKSPACE:?}/"*) echo "Review tools must be outside the checkout." >&2; exit 1 ;;
13+
esac
14+
chmod 700 "$review_tools_root"
15+
mkdir -m 700 "$review_tools_root/bin" "$review_tools_root/smoke"
16+
review_tools_ready=0
17+
cleanup() {
18+
rm -rf "$review_tools_root/smoke" "$review_tools_root/archive.tar.gz" "$review_tools_root/stdout" "$review_tools_root/stderr"
19+
if [[ "$review_tools_ready" != 1 ]]; then rm -rf "$review_tools_root"; fi
20+
}
21+
trap cleanup EXIT
22+
23+
curl --fail --show-error --silent --location \
24+
"https://github.com/trufflesecurity/trufflehog/releases/download/v3.97.1/trufflehog_3.97.1_linux_amd64.tar.gz" \
25+
--output "$review_tools_root/archive.tar.gz"
26+
printf '%s %s\n' \
27+
"f863ea3a8d786f7d097870496c977944cce7372a2fe1e56707d965016e543ece" \
28+
"$review_tools_root/archive.tar.gz" | sha256sum --check -
29+
tar -xzf "$review_tools_root/archive.tar.gz" -C "$review_tools_root/bin" trufflehog
30+
chmod 700 "$review_tools_root/bin/trufflehog"
31+
export PATH="$review_tools_root/bin:$PATH"
32+
version="$(env -i HOME="$review_tools_root" "$review_tools_root/bin/trufflehog" --version 2>&1)"
33+
[[ "$version" == "trufflehog 3.97.1" ]]
34+
printf 'A harmless review scanner installation check.\n' > "$review_tools_root/smoke/clean.txt"
35+
chmod 600 "$review_tools_root/smoke/clean.txt"
36+
if ! env -i HOME="$review_tools_root" TMPDIR="$review_tools_root" \
37+
"$review_tools_root/bin/trufflehog" filesystem "$review_tools_root/smoke" \
38+
--results=verified,unknown --fail --fail-on-scan-errors --no-update --json --no-color \
39+
> "$review_tools_root/stdout" 2> "$review_tools_root/stderr"; then
40+
echo "Trusted review scanner smoke failed; diagnostics withheld." >&2
41+
exit 1
42+
fi
43+
if [[ -s "$review_tools_root/stdout" ]]; then
44+
echo "Trusted review scanner smoke emitted unexpected output; diagnostics withheld." >&2
45+
exit 1
46+
fi
47+
echo "$review_tools_root/bin" >> "$GITHUB_PATH"
48+
review_tools_ready=1
49+
echo "Trusted TruffleHog 3.97.1 scanner installed and benign scan passed."

‎.github/workflows/ci.yml‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,30 @@ concurrency:
2121
cancel-in-progress: true
2222

2323
jobs:
24+
hosted-review-scan:
25+
name: Hosted native review scan smoke
26+
if: github.event_name == 'workflow_dispatch'
27+
runs-on: ubuntu-24.04
28+
timeout-minutes: 10
29+
steps:
30+
- uses: actions/checkout@v7
31+
with:
32+
persist-credentials: false
33+
- uses: ./.github/actions/setup-pnpm
34+
with:
35+
build-script: build
36+
- uses: ./.github/actions/setup-codex
37+
env:
38+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
39+
CLAWSWEEPER_INTERNAL_MODEL: ${{ secrets.CLAWSWEEPER_MODEL }}
40+
- name: Prove refusal then clean structured review
41+
run: node scripts/hosted-review-scan-smoke.mjs "$RUNNER_TEMP/hosted-review-scan-proof.json"
42+
- uses: actions/upload-artifact@v7
43+
with:
44+
name: hosted-review-scan-proof
45+
path: ${{ runner.temp }}/hosted-review-scan-proof.json
46+
if-no-files-found: error
47+
2448
check:
2549
name: pnpm check
2650
runs-on: ubuntu-latest

‎README.md‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,37 @@ its final month). The local, GitHub-isolated review engine survives as
540540

541541
### Safety Model
542542

543+
Native reviews require host-owned TruffleHog admission before any model-backed
544+
checkout inspection or review. The host scans the explicit initial prompt and
545+
schema plus complete raw before/after blobs and the full introduced diff. Scan
546+
coverage is independent of the 80-path/24K-character display evidence limits.
547+
Repair reviews scan the committed, staged, unstaged, and applicable untracked
548+
bytes of the validated checkout. Clean text-converted checkouts retain both
549+
canonical Git and raw working bytes in scan coverage. The host never starts a target-bundled autoreview helper or second reviewer.
550+
551+
Hosted Codex and OpenClaw setup share the checksum-pinned TruffleHog 3.97.1
552+
installer in `.github/actions/setup-review-tools/install.sh`. It supports Linux
553+
amd64 and fails on unsupported platforms. Local operators must install a trusted
554+
TruffleHog executable on the host `PATH`, outside both checkouts; workers never
555+
install dependencies themselves. Missing tools, findings, scan errors, source
556+
drift, incomplete ancestry/objects, changed gitlinks, and LFS pointers refuse the
557+
review. The scan stages at most 256 MiB in private external temporary files and
558+
uses the remaining review deadline; it never silently truncates or bypasses.
559+
Diagnostics omit scanner output and source values. Restore prerequisites or
560+
remove sensitive input before retrying a refusal.
561+
562+
This admission boundary is not universal provider-egress scanning. Automatically
563+
loaded project docs, resumed/steered history, later tool results, and unchanged
564+
repository history are outside its scope. Planning, assist, and close-coverage
565+
calls scan their explicit prompt/schema; they do not attest a source review.
566+
No dashboard projection or observer API changes; OpenClaw Bay is unaffected.
567+
568+
Maintainers can run the dispatch-only `Hosted native review scan smoke` job in
569+
`ci.yml`. It uses the existing `OPENAI_API_KEY` and `CLAWSWEEPER_MODEL` secrets
570+
only during host setup, with no App mutation token. The proof artifact records
571+
zero provider starts on refusal, one clean native structured run, exact fixture
572+
and runner identities, and coverage limits without exposing the configured model.
573+
543574
- Review and repair base fetches use fully qualified branch refspecs so inherited
544575
`fetch.prune` or `remote.origin.prune` settings do not delete the requested
545576
tracking ref. Validation uses the same repair fetch helper; no host Git

‎docs/commit-sweeper.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ review engine in `src/commit-sweeper.ts`, used two ways:
2020

2121
## Usage
2222

23+
Install a trusted TruffleHog executable on the host `PATH`, outside the source
24+
checkout and ClawSweeper checkout, before running either review command. Hosted
25+
setup pins version 3.97.1; local workers do not provision it. The mandatory scan
26+
covers the explicit initial payload and complete introduced before/after source
27+
bytes, independently of prompt truncation. See the [safety model](../README.md#safety-model)
28+
for refused inputs, the 256 MiB staging cap, deadline, and coverage limits.
29+
2330
```text
2431
pnpm run build
2532
pnpm local-review -- --base main

‎docs/repair/README.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ The default workflow is proposal-first. It does not comment or close unless a jo
7979

8080
## State Boundaries
8181

82+
Before internal review, the host scans the explicit prompt/schema and complete
83+
introduced before/after source bytes from the actual validated dirty checkout.
84+
The index and raw worktree snapshots stay alive through admission, including
85+
staged bytes that differ from the working file. Drift, scanner failures, and findings stop the run as infrastructure
86+
refusals; they never enter the review-fix or JSON-repair paths. No target-bundled
87+
autoreview helper or second reviewer is started. See the
88+
[safety model](../../README.md#safety-model) for the trusted scanner prerequisite,
89+
staging/deadline limits, and the distinction from later tool/history scanning.
90+
8291
`jobs/` and `results/` are durable operational state in
8392
`openclaw/clawsweeper-state`, not generated source in this repo. They may
8493
contain historical run text and audit evidence. Active code, prompts, workflows,

‎docs/review-cache.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ proven.
9696

9797
No cache stage can promote a report to close.
9898

99+
Every reused review passes the host-owned scan preflight before checkout
100+
inspection. Structural reuse scans current reuse metadata and the pinned source
101+
delta against the base/head pair from the same fresh structural probe; hydrated
102+
semantic/content reuse also scans current context. Complete raw before/after blobs
103+
are scanned even when the AST digest ignores a comment-only change. Historical
104+
outcomes predating scan admission are rejected by the review policy version.
105+
Scan refusal cannot return a cached success or launch a fallback reviewer.
106+
99107
## Metrics
100108

101109
Each review run writes `review-cache-metrics.json` in its artifact directory.

‎prompts/review-commit.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ queries, advisory searches, and general web lookups are allowed when they can
3636
materially raise confidence within the time budget. Prefer focused checks over
3737
full-suite work unless the commit is small and the full gate is cheap.
3838

39+
The host owns this review and its mandatory scan of the explicit initial payload
40+
and complete introduced before/after source bytes. Do not start target-bundled
41+
autoreview helpers or another reviewer, and do not claim those helpers ran.
42+
Later tool results, automatically loaded project docs, resumed/steered history,
43+
and universal provider egress are outside this admission scan's scope.
44+
3945
Do not return JSON. Return Markdown only. The Markdown must start with YAML-ish
4046
front matter, then a human-readable report.
4147

‎prompts/review-item.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ For PRs, read relevant maintainer review notes before reviewing the diff. If the
6565

6666
This is a read-only review. Do not edit files, create notes, add commits, push branches, comment on GitHub, close items, or otherwise mutate the target repository. Only return the JSON decision.
6767

68+
ClawSweeper owns this structured review and its mandatory TruffleHog admission
69+
scan. The host scans the exact explicit initial prompt and schema, and complete
70+
raw before/after blobs and diff for the introduced PR change, independently of
71+
display truncation and prompt budgets. This is the host-managed equivalent of
72+
the review/scan admission step; do not run target-bundled autoreview helpers or
73+
start another reviewer. Do not claim those helpers ran. This does not scan every
74+
later tool result, automatically loaded project instruction, resumed/steered
75+
conversation, provider request, or all repository history.
76+
6877
The checkout must remain byte-for-byte clean. Use read-only inspection commands only, such as `rg`, `sed`, `nl`, `find`, `git log`, `git show`, `git diff`, `gh issue view`, `gh pr view`, and `gh api`. Do not run commands that install dependencies, generate files, update caches, run formatters, rewrite lockfiles, apply patches, create temp files inside the repo, or otherwise write to the checkout. Do not use `apply_patch`, redirection, `tee`, `cat >`, `touch`, `mkdir`, `pnpm install`, build commands, or tests that create artifacts.
6978

7079
Review deeply before closing. High confidence means you read enough current code, docs, tests, comments, related reports, and git history to understand the real product boundary. Do not decide from the issue title, one exact `rg` hit, or one nearby file. Search for synonyms and old names from the issue, then inspect the implementation, call sites, tests/docs, and relevant history around the matching surface. Prefer several independent checks over a single brittle match. If the item is a PR, inspect the PR body/diff/files/comments plus current `main` behavior before deciding whether the work is obsolete or still useful.

0 commit comments

Comments
 (0)