- Introduced `sink-detect.js` with various security sink detection patterns categorized by type (e.g., command injection, SQL injection, file operations). - Implemented functions to build a lookup map for fast sink detection and to match sink calls against known patterns. - Added `package-lock.json` for dependency management.
114 lines
3.7 KiB
PowerShell
114 lines
3.7 KiB
PowerShell
# VexHub Tool Compatibility Test Script (PowerShell)
|
|
# Usage: .\test-tool-compat.ps1 [-VexHubUrl "http://localhost:5200"]
|
|
|
|
param(
|
|
[string]$VexHubUrl = "http://localhost:5200"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$failures = 0
|
|
|
|
Write-Host "=== VexHub Tool Compatibility Tests ===" -ForegroundColor Cyan
|
|
Write-Host "VexHub URL: $VexHubUrl"
|
|
Write-Host ""
|
|
|
|
function Test-Endpoint {
|
|
param(
|
|
[string]$Name,
|
|
[scriptblock]$Test
|
|
)
|
|
|
|
Write-Host -NoNewline "$Name... "
|
|
try {
|
|
$result = & $Test
|
|
if ($result) {
|
|
Write-Host "PASS" -ForegroundColor Green
|
|
return $true
|
|
} else {
|
|
Write-Host "FAIL" -ForegroundColor Red
|
|
return $false
|
|
}
|
|
} catch {
|
|
Write-Host "FAIL ($_)" -ForegroundColor Red
|
|
return $false
|
|
}
|
|
}
|
|
|
|
# Test 1: Health check
|
|
if (-not (Test-Endpoint "Health check" {
|
|
$response = Invoke-RestMethod -Uri "$VexHubUrl/health" -Method Get
|
|
$response.status -eq "Healthy"
|
|
})) { $failures++ }
|
|
|
|
# Test 2: Index manifest
|
|
if (-not (Test-Endpoint "Index manifest" {
|
|
$response = Invoke-RestMethod -Uri "$VexHubUrl/api/v1/vex/index" -Method Get
|
|
$null -ne $response.version
|
|
})) { $failures++ }
|
|
|
|
# Test 3: Export endpoint (OpenVEX format)
|
|
if (-not (Test-Endpoint "Export endpoint" {
|
|
$headers = @{ "Accept" = "application/vnd.openvex+json" }
|
|
$response = Invoke-RestMethod -Uri "$VexHubUrl/api/v1/vex/export" -Method Get -Headers $headers
|
|
$response.'@context' -like "*openvex*"
|
|
})) { $failures++ }
|
|
|
|
# Test 4: Rate limit headers
|
|
if (-not (Test-Endpoint "Rate limit headers" {
|
|
$response = Invoke-WebRequest -Uri "$VexHubUrl/api/v1/vex/export" -Method Get
|
|
$response.Headers.ContainsKey("X-RateLimit-Limit")
|
|
})) { $failures++ }
|
|
|
|
# Test 5: CVE query endpoint
|
|
if (-not (Test-Endpoint "CVE query endpoint" {
|
|
try {
|
|
$response = Invoke-RestMethod -Uri "$VexHubUrl/api/v1/vex/cve/CVE-2024-0001" -Method Get
|
|
$true # Endpoint exists (may return empty results)
|
|
} catch {
|
|
if ($_.Exception.Response.StatusCode -eq 404) {
|
|
$true # 404 is OK - means endpoint works, no data
|
|
} else {
|
|
$false
|
|
}
|
|
}
|
|
})) { $failures++ }
|
|
|
|
# Test 6: Trivy integration (if available)
|
|
$trivyPath = Get-Command trivy -ErrorAction SilentlyContinue
|
|
if ($trivyPath) {
|
|
if (-not (Test-Endpoint "Trivy VEX integration" {
|
|
$headers = @{ "Accept" = "application/vnd.openvex+json" }
|
|
$vexContent = Invoke-RestMethod -Uri "$VexHubUrl/api/v1/vex/export" -Method Get -Headers $headers
|
|
$vexPath = Join-Path $env:TEMP "vexhub.openvex.json"
|
|
$vexContent | ConvertTo-Json -Depth 10 | Set-Content $vexPath
|
|
$trivyResult = & trivy image --vex $vexPath alpine:3.18 --quiet 2>&1
|
|
$LASTEXITCODE -eq 0
|
|
})) { $failures++ }
|
|
} else {
|
|
Write-Host "Trivy integration... SKIP (trivy not installed)" -ForegroundColor Yellow
|
|
}
|
|
|
|
# Test 7: Grype integration (if available)
|
|
$grypePath = Get-Command grype -ErrorAction SilentlyContinue
|
|
if ($grypePath) {
|
|
if (-not (Test-Endpoint "Grype VEX integration" {
|
|
$headers = @{ "Accept" = "application/vnd.openvex+json" }
|
|
$vexContent = Invoke-RestMethod -Uri "$VexHubUrl/api/v1/vex/export" -Method Get -Headers $headers
|
|
$vexPath = Join-Path $env:TEMP "vexhub.openvex.json"
|
|
$vexContent | ConvertTo-Json -Depth 10 | Set-Content $vexPath
|
|
$grypeResult = & grype alpine:3.18 --vex $vexPath --quiet 2>&1
|
|
$LASTEXITCODE -eq 0
|
|
})) { $failures++ }
|
|
} else {
|
|
Write-Host "Grype integration... SKIP (grype not installed)" -ForegroundColor Yellow
|
|
}
|
|
|
|
Write-Host ""
|
|
if ($failures -eq 0) {
|
|
Write-Host "All tests passed!" -ForegroundColor Green
|
|
exit 0
|
|
} else {
|
|
Write-Host "$failures test(s) failed" -ForegroundColor Red
|
|
exit 1
|
|
}
|