diff --git a/scan/action.yml b/scan/action.yml index 6bf3300..9480e6e 100644 --- a/scan/action.yml +++ b/scan/action.yml @@ -161,16 +161,17 @@ runs: set -euo pipefail url=${PANEL_URL:-${DTRACK_URL%/}/panel-ci/report} images=$(printf '%s' "$IMAGES" | tr ',' '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | { grep -v '^$' || true; } | jq -R . | jq -s .) # no images is fine - tomls='[]' + # Files go through disk, never argv (a big VEX file blows the limit). + : > tomls.ndjson while IFS= read -r f; do - tomls=$(jq --arg p "$f" --rawfile c "$f" '. + [{path: $p, content: $c}]' <<<"$tomls") + jq -n --arg p "$f" --rawfile c "$f" '{path: $p, content: $c}' >> tomls.ndjson done < <(find "$SCAN_PATH" -name osv-scanner.toml -not -path '*/node_modules/*' -not -path '*/.git/*' | head -20) - vex='[]' + : > vex.ndjson while IFS= read -r f; do - vex=$(jq --arg p "$f" --rawfile c "$f" '. + [{path: $p, content: $c}]' <<<"$vex") + jq -n --arg p "$f" --rawfile c "$f" '{path: $p, content: $c}' >> vex.ndjson done < <(find "$SCAN_PATH" -path '*/.vex/*' -name '*.json' -not -path '*/node_modules/*' -not -path '*/.git/*' | sort | head -200) jq -n --arg repo "$REPO" --arg commit "$COMMIT" --arg project "$PROJECT" \ - --argjson images "$images" --argjson tomls "$tomls" --argjson vex "$vex" \ + --argjson images "$images" --slurpfile tomls tomls.ndjson --slurpfile vex vex.ndjson \ '{repo: $repo, commit: $commit, project: $project, images: $images, osvScannerToml: $tomls, vexFiles: $vex}' > report.json echo "Reporting $(jq '.images | length' report.json) image(s), $(jq '.osvScannerToml | length' report.json) osv-scanner.toml file(s), $(jq '.vexFiles | length' report.json) VEX file(s) to ${url}" curl -fsS -X POST "$url" -H "X-Api-Key: ${DTRACK_API_KEY}" -H "Content-Type: application/json" \ diff --git a/vex/action.yml b/vex/action.yml index 059d990..a500dda 100644 --- a/vex/action.yml +++ b/vex/action.yml @@ -45,11 +45,13 @@ runs: run: | set -euo pipefail url=${PANEL_URL:-${DTRACK_URL%/}/panel-ci/vex} - files='[]' + # One JSON object per file on disk (never as an argument: a big VEX + # file blows the argv limit), slurped into the report. + : > vex-files.ndjson while IFS= read -r f; do - files=$(jq --arg p "$f" --rawfile c "$f" '. + [{path: $p, content: $c}]' <<<"$files") + jq -n --arg p "$f" --rawfile c "$f" '{path: $p, content: $c}' >> vex-files.ndjson done < <(find "$VEX_PATH" -name '*.json' -not -path '*/.git/*' | sort | head -500) - jq -n --arg repo "$REPO" --arg commit "$COMMIT" --argjson files "$files" \ + jq -n --arg repo "$REPO" --arg commit "$COMMIT" --slurpfile files vex-files.ndjson \ '{repo: $repo, commit: $commit, files: $files}' > vex-report.json echo "Posting $(jq '.files | length' vex-report.json) VEX file(s) to ${url}" # -f: a rejected file (bad JSON, no justification) fails the job.