Skip to content

Commit b67401a

Browse files
committed
ci(dry-run): scan the archive artifacts with VirusTotal as the final step
Preparation for the next dry-run cycle. The release gate scans every shipped artifact with VirusTotal and blocks on any detection; the dry run did not, so the one question most likely to stop a release was the one a dry run could not answer. v0.9.1-rc found that out the expensive way. The scan mirrors the release job. The only difference is where the archives come from: the release pulls them off a published release, a dry run has none, so they come from the build job's artifacts — the same files, produced by the same canonical package-release.sh, extracted the same way and scanned as the same bytes a user would download and run. Same zero-tolerance gate (scripts/ci/check-virustotal.sh), so a dry run now fails where the release would. It runs LAST, after smoke and soak. It is the slowest job — polling can take two hours — and its verdict does not depend on our code at all: the same unchanged bytes can come back clean one day and flagged the next. That must not delay the feedback that IS about our code. Two independent skips, because they answer different questions: skip_builds no artifacts at all "do lint and tests pass?" skip_virustotal build + smoke + soak, no scan "do the archives pass CI?" The second is the one asked for: during a debug cycle, when the question is whether the archives survive smoke and soak, a two-hour scan burning API quota is pure noise. skip_builds implies no scan, since there is nothing to scan. Extraction lives in scripts/ci/extract-release-archives.sh rather than inline in the YAML because the venue-parity contract requires it — a venue may provision, plumb artifacts, or call a canonical leg script, and this is leg logic. The contract caught the inline version. Two defects found by testing the script instead of trusting it: * The empty-input guard did not guard. It counted files in the output directory, but the install scripts are copied in unconditionally, so the count was never zero and an input with no archives reported success — a clean VirusTotal run over nothing, the exact false green the check exists to prevent. It now counts binaries recovered from archives, and exits 1 on zero. * The script was committed 100644 while the workflow invokes it directly as a command, which is the "Permission denied" failure test_script_exec_bit_contract.sh was written for. That contract scans scripts/ but not .github/workflows/, so it did not catch it here. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 17c2a51 commit b67401a

2 files changed

Lines changed: 136 additions & 3 deletions

File tree

‎.github/workflows/dry-run.yml‎

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
# Manual trigger: test everything before pushing a release.
22
# Each step can be skipped for faster iteration.
33
#
4-
# Pipeline: lint → test → build → smoke/soak (sequential chain)
5-
# Security: security-static + codeql-gate (independent island)
4+
# Pipeline: lint → test → build → smoke/soak → virustotal (sequential chain)
5+
# Security: security-static + codeql-gate (independent island)
66
#
77
# Security does NOT block lint/test/build/smoke/soak. All jobs must pass
88
# for the overall workflow to be green.
9+
#
10+
# VirusTotal runs LAST and scans the same artifacts the release scans, so a
11+
# detection surfaces here instead of mid-release. It is the one dry-run job
12+
# whose verdict does not depend on our code: the same unchanged bytes can come
13+
# back clean one day and flagged the next, which is precisely why finding out
14+
# during a dry run is worth the wait.
15+
#
16+
# Two independent skips, because they answer different questions:
17+
# skip_builds no artifacts at all — "do lint and tests pass?"
18+
# skip_virustotal build + smoke + soak, no scan — "do the archives pass CI?"
19+
# The second exists because the scan costs API quota and polls for up to two
20+
# hours, which is pure noise while iterating on a build or smoke failure.
921
name: Dry Run
1022

1123
on:
@@ -20,7 +32,11 @@ on:
2032
type: boolean
2133
default: false
2234
skip_builds:
23-
description: 'Skip build + smoke'
35+
description: 'Skip build + smoke (also skips VirusTotal — nothing to scan)'
36+
type: boolean
37+
default: false
38+
skip_virustotal:
39+
description: 'Skip VirusTotal scan (still builds + smokes the archives)'
2440
type: boolean
2541
default: false
2642
soak_level:
@@ -84,3 +100,55 @@ jobs:
84100
with:
85101
duration_minutes: 10
86102
run_asan: ${{ inputs.soak_level == 'full' }}
103+
104+
# ── VirusTotal (final step) ────────────────────────────────────
105+
# Mirrors the release workflow's scan so a dry run answers the question the
106+
# release will ask, before we tag anything. The only difference is where the
107+
# archives come from: the release pulls them off a published release, a dry
108+
# run has none, so they come from the build job's artifacts — the SAME files,
109+
# produced by the same canonical package-release.sh.
110+
#
111+
# Runs after smoke and soak deliberately. It is the slowest job (polling can
112+
# take up to two hours) and the one most likely to be waiting on someone
113+
# else's queue, so it must not delay the feedback that is actually about our
114+
# code.
115+
virustotal:
116+
if: ${{ inputs.skip_builds != true && inputs.skip_virustotal != true && !cancelled() && needs.build.result == 'success' && needs.smoke.result != 'failure' && needs.soak.result != 'failure' }}
117+
needs: [build, smoke, soak]
118+
runs-on: ubuntu-latest
119+
permissions:
120+
contents: read
121+
steps:
122+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
123+
with:
124+
persist-credentials: false
125+
126+
- name: Download build artifacts
127+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
128+
with:
129+
pattern: binaries-*
130+
merge-multiple: true
131+
path: assets
132+
133+
# Same extraction the release verify job performs, so the bytes handed to
134+
# VirusTotal here are the bytes a user would download and run.
135+
- name: Extract archive artifacts
136+
run: scripts/ci/extract-release-archives.sh assets binaries
137+
138+
- name: VirusTotal scan
139+
uses: crazy-max/ghaction-virustotal@936d8c5c00afe97d3d9a1af26d017cfdf26800a2 # v5.0.0
140+
id: virustotal
141+
with:
142+
vt_api_key: ${{ secrets.VIRUS_TOTAL_SCANNER_API_KEY }}
143+
files: binaries/*
144+
145+
# Same ZERO-tolerance gate as the release. A detection here is a real
146+
# finding even when it is a false positive: it is what the release gate
147+
# will do, so the dry run should say so now. Resolve it upstream (vendor
148+
# false-positive submission for the exact hashes, then re-run) — never by
149+
# loosening this gate.
150+
- name: Wait for VirusTotal results
151+
env:
152+
VT_API_KEY: ${{ secrets.VIRUS_TOTAL_SCANNER_API_KEY }}
153+
VT_ANALYSIS: ${{ steps.virustotal.outputs.analysis }}
154+
run: scripts/ci/check-virustotal.sh
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env bash
2+
# Extract the release archives into a flat directory of scannable files.
3+
#
4+
# Turns the per-platform artifacts (codebase-memory-mcp-<goos>-<goarch>.tar.gz /
5+
# .zip, produced by the canonical package-release.sh) into one directory holding
6+
# the actual executables, each renamed to its platform so a scan report names
7+
# something a human can act on. The install scripts are copied in beside them:
8+
# they ship in the release too, and a compromised installer matters as much as a
9+
# compromised binary.
10+
#
11+
# Usage: extract-release-archives.sh <archive-dir> <output-dir>
12+
#
13+
# Lives in scripts/ rather than inline in the workflow because the venue-parity
14+
# contract requires it: a venue may provision, plumb artifacts, or call a
15+
# canonical leg script, and this is leg logic. It also means the dry run and the
16+
# release can extract identically instead of drifting apart in two YAML copies.
17+
set -euo pipefail
18+
19+
ARCHIVE_DIR="${1:?extract-release-archives: missing <archive-dir>}"
20+
OUT_DIR="${2:?extract-release-archives: missing <output-dir>}"
21+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
22+
23+
mkdir -p "$OUT_DIR"
24+
shopt -s nullglob
25+
26+
# Counts BINARIES recovered from archives, deliberately not "files in OUT_DIR".
27+
# The install scripts below are copied in unconditionally, so a whole-directory
28+
# count is never zero and would have reported success on an empty input — a
29+
# clean VirusTotal run over nothing, which is the precise false green this
30+
# script exists to prevent. Caught by running it against an empty directory.
31+
extracted=0
32+
33+
for archive in "$ARCHIVE_DIR"/*.tar.gz; do
34+
name="$(basename "$archive" .tar.gz)"
35+
tar -xzf "$archive" -C "$OUT_DIR" 2>/dev/null || true
36+
if [ -f "$OUT_DIR/codebase-memory-mcp" ]; then
37+
mv "$OUT_DIR/codebase-memory-mcp" "$OUT_DIR/${name}"
38+
extracted=$((extracted + 1))
39+
fi
40+
done
41+
42+
for archive in "$ARCHIVE_DIR"/*.zip; do
43+
name="$(basename "$archive" .zip)"
44+
unzip -o "$archive" -d "$OUT_DIR" >/dev/null 2>&1 || true
45+
if [ -f "$OUT_DIR/codebase-memory-mcp.exe" ]; then
46+
mv "$OUT_DIR/codebase-memory-mcp.exe" "$OUT_DIR/${name}.exe"
47+
extracted=$((extracted + 1))
48+
fi
49+
done
50+
51+
if [ "$extracted" -eq 0 ]; then
52+
echo "FAIL: no binaries extracted from '$ARCHIVE_DIR' — a scan here would have"
53+
echo " reported clean without examining a single byte"
54+
ls -la "$ARCHIVE_DIR" 2>/dev/null || true
55+
exit 1
56+
fi
57+
58+
# Shipped alongside the binaries, so scanned alongside them: a compromised
59+
# installer matters as much as a compromised executable.
60+
cp "$ROOT/install.sh" "$OUT_DIR/" 2>/dev/null || true
61+
cp "$ROOT/install.ps1" "$OUT_DIR/" 2>/dev/null || true
62+
63+
ls -la "$OUT_DIR"
64+
total="$(find "$OUT_DIR" -maxdepth 1 -type f | wc -l | tr -d ' ')"
65+
echo "extracted $extracted binarie(s); $total file(s) queued for scanning"

0 commit comments

Comments
 (0)