Skip to content

Commit 906781f

Browse files
fix(ci): scan-and-report — dispatch payload via file, not argv (#155)
## Summary Consumers of the reusable `scan-and-report.yml` with large scan output see their Security Scan job die at the dispatch step with `/usr/bin/curl: Argument list too long` (exit 126) — e.g. echidna main run 28736074871 — because the whole scan JSON is inlined into curl's `-d` argument. - Build the dispatch payload with `jq` into a file and send it with `--data @dispatch-payload.json` (fixes the argv overflow and the hand-rolled JSON escaping). - GitHub caps `repository_dispatch` `client_payload` at ~64KB — the same repos that overflow argv would then 422. Oversized reports now fall back to a counts-only summary (`statistics`, `weak_point_count`, severity histogram, `truncated: true`). ## Verification - Both jq payload builders exercised against a synthetic AssailReport — valid JSON, severity histogram correct. - `actionlint` clean on the workflow. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 5f45330 commit 906781f

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

.github/workflows/scan-and-report.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,35 @@ jobs:
4747
DISPATCH_TOKEN: ${{ secrets.VERISIMDB_PAT || secrets.GITHUB_TOKEN }}
4848
run: |
4949
REPO_NAME=$(basename $(pwd))
50-
SCAN_DATA=$(cat scan-result.json)
50+
51+
# Build the payload in a file: inlining the scan JSON on argv
52+
# overflows the kernel arg-length limit on large repos (curl
53+
# exits 126 "Argument list too long").
54+
jq -c --arg repo_name "$REPO_NAME" \
55+
'{event_type: "scan_result", client_payload: {repo_name: $repo_name, scan_data: .}}' \
56+
scan-result.json > dispatch-payload.json
57+
58+
# repository_dispatch caps client_payload at ~64KB. When the full
59+
# report is too big, dispatch a counts-only summary instead of
60+
# letting the API reject the whole run with a 422.
61+
if [ "$(wc -c < dispatch-payload.json)" -gt 60000 ]; then
62+
echo "Full report $(wc -c < scan-result.json) bytes exceeds dispatch cap; sending summary"
63+
jq -c --arg repo_name "$REPO_NAME" \
64+
'{event_type: "scan_result", client_payload: {repo_name: $repo_name, scan_data: {
65+
schema_version: .schema_version,
66+
program_path: .program_path,
67+
language: .language,
68+
statistics: .statistics,
69+
suppressed_count: (.suppressed_count // 0),
70+
weak_point_count: (.weak_points | length),
71+
weak_points_by_severity: (.weak_points | map(.severity | tostring) | group_by(.) | map({key: .[0], value: length}) | from_entries),
72+
truncated: true
73+
}}}' scan-result.json > dispatch-payload.json
74+
fi
5175
5276
curl -sf -X POST \
5377
-H "Authorization: Bearer ${DISPATCH_TOKEN}" \
5478
-H "Accept: application/vnd.github+json" \
5579
"https://api.github.com/repos/hyperpolymath/verisimdb-data/dispatches" \
56-
-d "{\"event_type\":\"scan_result\",\"client_payload\":{\"repo_name\":\"$REPO_NAME\",\"scan_data\":$SCAN_DATA}}"
80+
--data @dispatch-payload.json
5781
echo "Dispatched scan results for ${REPO_NAME} to verisimdb-data"

0 commit comments

Comments
 (0)