Repository navigation
Expand file tree
/
Copy pathsetup.ps1
More file actions
64 lines (52 loc) · 2.16 KB
/
Copy pathsetup.ps1
File metadata and controls
64 lines (52 loc) · 2.16 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
# One-shot check that the artifact catalog landed intact and is ready to commit.
# Safe to re-run. Changes nothing except regenerating the export feeds.
#
# .\setup.ps1
#
# If PowerShell blocks it:
# powershell -ExecutionPolicy Bypass -File .\setup.ps1
$ErrorActionPreference = "Stop"
Set-Location -Path $PSScriptRoot
function Fail($msg) { Write-Host $msg -ForegroundColor Red; exit 1 }
Write-Host "==> Checking layout"
foreach ($d in @("artifacts\catalog", "artifacts\scripts", "artifacts\schema",
"skills\agent-artifact-catalog")) {
if (-not (Test-Path $d)) { Fail "MISSING: $d" }
}
Write-Host " ok"
Write-Host "==> Locating Python"
$py = $null
foreach ($candidate in @("python", "py", "python3")) {
try {
$version = & $candidate --version 2>&1
if ($LASTEXITCODE -eq 0) { $py = $candidate; break }
} catch { }
}
if (-not $py) { Fail "Python not found on PATH. Install Python 3.11+ from python.org and reopen your terminal." }
Write-Host " using '$py' ($version)"
Write-Host "==> Python dependencies"
& $py -m pip install -q -r artifacts\requirements.txt
if ($LASTEXITCODE -ne 0) { Fail "pip install failed" }
Write-Host " ok"
Push-Location artifacts
Write-Host "==> Validating catalog and detections"
& $py scripts\validate.py
if ($LASTEXITCODE -ne 0) { Pop-Location; Fail "Validation failed. Fix before committing - this is the gate CI runs." }
Write-Host "==> Checking for vocabulary drift"
& $py scripts\normalize.py
if ($LASTEXITCODE -ne 0) { Pop-Location; Fail "normalize.py failed" }
Write-Host "==> Regenerating export feeds"
& $py scripts\export.py
if ($LASTEXITCODE -ne 0) { Pop-Location; Fail "export.py failed" }
& $py scripts\export_forensicartifacts.py
if ($LASTEXITCODE -ne 0) { Pop-Location; Fail "export_forensicartifacts.py failed" }
$entries = (Get-ChildItem catalog\*.yml).Count
$sigma = (Get-ChildItem detections\sigma\*.yml).Count
Pop-Location
Write-Host ""
Write-Host "==> Ready." -ForegroundColor Green
Write-Host " Entries: $entries"
Write-Host " Sigma: $sigma"
Write-Host ""
Write-Host " Next: see CONTRIBUTING.md to add an entry, or"
Write-Host " artifacts/BACKLOG.md for open work"