-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecurity-scan.ps1
More file actions
65 lines (57 loc) · 1.81 KB
/
Copy pathsecurity-scan.ps1
File metadata and controls
65 lines (57 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
param(
[switch]$IncludeUntracked,
[switch]$SkipGitleaks,
[switch]$SkipTruffleHog
)
$ErrorActionPreference = "Stop"
$RootDir = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
$GitleaksImage = if ($env:GITLEAKS_IMAGE) { $env:GITLEAKS_IMAGE } else { "ghcr.io/gitleaks/gitleaks:v8.30.1" }
$TruffleHogImage = if ($env:TRUFFLEHOG_IMAGE) { $env:TRUFFLEHOG_IMAGE } else { "ghcr.io/trufflesecurity/trufflehog:3.95.7" }
function Assert-LastExitCode {
param([string]$Label)
if ($LASTEXITCODE -ne 0) {
throw "$Label failed with exit code $LASTEXITCODE"
}
}
Push-Location $RootDir
try {
Write-Host "== Wright public-alpha leak scan =="
if ($IncludeUntracked) {
python scripts/check-public-alpha-leaks.py --include-untracked
} else {
python scripts/check-public-alpha-leaks.py
}
Assert-LastExitCode "Public-alpha leak scan"
if (-not $SkipGitleaks) {
Write-Host ""
Write-Host "== Gitleaks history scan =="
docker run --rm `
-v "${RootDir}:/repo" `
$GitleaksImage `
git /repo `
--config /repo/.gitleaks.toml `
--no-banner `
--redact `
--verbose
Assert-LastExitCode "Gitleaks history scan"
}
if (-not $SkipTruffleHog) {
Write-Host ""
Write-Host "== TruffleHog history scan =="
docker run --rm `
-v "${RootDir}:/repo" `
-w /repo `
$TruffleHogImage `
git file:///repo `
--no-update `
--fail `
--results=verified,unknown `
--no-verification `
--exclude-globs=uv.lock,package-lock.json
Assert-LastExitCode "TruffleHog history scan"
}
Write-Host ""
Write-Host "Security scans passed."
} finally {
Pop-Location
}