Skip to content

Commit 1d378ba

Browse files
committed
fix(scan): match renamed compromised packages header
The upstream Cobenian/shai-hulud-detect compromised-packages.txt header was renamed from "Shai-Hulud NPM Supply Chain Attack" to "Shai-Hulud Supply Chain Attack - Compromised Packages List", causing `vtk scan repo` to fail validation with a false MITM/corrupted-file warning. Switch the expected-header check to a regex (`Shai-Hulud.*Supply Chain Attack`) so both the old and new wordings validate while still being specific enough to catch a tampered or unrelated file. Reported by Catalina Espinoza.
1 parent c9f57eb commit 1d378ba

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

scripts/shai-hulud-repo-check.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ $CacheDir = Join-Path $env:LOCALAPPDATA "vtk"
9191
$CacheFile = Join-Path $CacheDir "compromised-packages.txt"
9292
$CacheTTL = 86400 # 24 hours in seconds
9393
$MinExpectedPackages = 500
94-
$ExpectedHeader = "Shai-Hulud NPM Supply Chain Attack"
94+
$ExpectedHeader = "Shai-Hulud.*Supply Chain Attack"
9595
$PlaybookUrl = "https://department-of-veterans-affairs.github.io/eert/shai-hulud-dev-machine-cleanup-playbook"
9696

9797
# Resolve path
@@ -151,7 +151,7 @@ function Test-PackageListValid {
151151
param([string]$Content)
152152

153153
# Check for expected header
154-
if ($Content -notmatch [regex]::Escape($ExpectedHeader)) {
154+
if ($Content -notmatch $ExpectedHeader) {
155155
Write-Warning "Downloaded file missing expected header - possible MITM or corrupted file"
156156
return $false
157157
}

scripts/shai-hulud-repo-check.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/vtk"
5050
CACHE_FILE="$CACHE_DIR/compromised-packages.txt"
5151
CACHE_TTL=86400 # 24 hours
5252
MIN_EXPECTED_PACKAGES=500
53-
EXPECTED_HEADER="Shai-Hulud NPM Supply Chain Attack"
53+
EXPECTED_HEADER="Shai-Hulud.*Supply Chain Attack"
5454
PLAYBOOK_URL="https://department-of-veterans-affairs.github.io/eert/shai-hulud-dev-machine-cleanup-playbook"
5555

5656
# Parse arguments
@@ -172,7 +172,7 @@ validate_package_list() {
172172
local content="$1"
173173

174174
# Check for expected header
175-
if ! echo "$content" | grep -q "$EXPECTED_HEADER"; then
175+
if ! echo "$content" | grep -Eq "$EXPECTED_HEADER"; then
176176
echo "Downloaded file missing expected header - possible MITM or corrupted file" >&2
177177
return 1
178178
fi

0 commit comments

Comments
 (0)