forked from connect-boiz/soroban-security-scanner
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate_fixed.ps1
More file actions
182 lines (156 loc) · 7.04 KB
/
validate_fixed.ps1
File metadata and controls
182 lines (156 loc) · 7.04 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# Kubernetes Isolated Scanner - Validation Script (PowerShell)
# This script validates the implementation without requiring compilation
Write-Host "🚀 Validating Kubernetes Isolated Scanner Implementation" -ForegroundColor Cyan
Write-Host "======================================================" -ForegroundColor Cyan
# Check if we have the required files
Write-Host "📁 Checking file structure..." -ForegroundColor Yellow
$requiredFiles = @(
"src/kubernetes.rs",
"src/lib.rs",
"src/main.rs",
"Cargo.toml",
"k8s/00-namespace-rbac.yaml",
"k8s/01-security-policies.yaml",
"k8s/02-api-deployment.yaml",
"k8s/03-cleanup-autoscaling.yaml",
"k8s/04-secrets-config.yaml",
"k8s/README.md",
"Dockerfile",
"examples/kubernetes_isolated_scanning.rs",
"KUBERNETES_IMPLEMENTATION.md"
)
$allFilesExist = $true
foreach ($file in $requiredFiles) {
if (Test-Path $file) {
Write-Host " ✅ $file" -ForegroundColor Green
} else {
Write-Host " ❌ $file (missing)" -ForegroundColor Red
$allFilesExist = $false
}
}
if (-not $allFilesExist) {
Write-Host "❌ Validation failed: Missing required files" -ForegroundColor Red
exit 1
}
Write-Host ""
Write-Host "📋 Validating Kubernetes manifests..." -ForegroundColor Yellow
# Check if kubectl is available
$kubectlAvailable = Get-Command kubectl -ErrorAction SilentlyContinue
if ($kubectlAvailable) {
Write-Host " ✅ kubectl found" -ForegroundColor Green
} else {
Write-Host " ⚠️ kubectl not found - skipping manifest validation" -ForegroundColor Yellow
}
Write-Host ""
Write-Host "🔍 Validating Rust code structure..." -ForegroundColor Yellow
# Check if Rust files contain required components
Write-Host " Checking kubernetes.rs..." -ForegroundColor Cyan
if (Select-String -Path "src/kubernetes.rs" -Pattern "K8sScanManager" -Quiet) {
Write-Host " ✅ K8sScanManager struct found" -ForegroundColor Green
} else {
Write-Host " ❌ K8sScanManager struct missing" -ForegroundColor Red
}
if (Select-String -Path "src/kubernetes.rs" -Pattern "ScanPodConfig" -Quiet) {
Write-Host " ✅ ScanPodConfig struct found" -ForegroundColor Green
} else {
Write-Host " ❌ ScanPodConfig struct missing" -ForegroundColor Red
}
if (Select-String -Path "src/kubernetes.rs" -Pattern "execute_scan" -Quiet) {
Write-Host " ✅ execute_scan method found" -ForegroundColor Green
} else {
Write-Host " ❌ execute_scan method missing" -ForegroundColor Red
}
Write-Host " Checking lib.rs..." -ForegroundColor Cyan
if (Select-String -Path "src/lib.rs" -Pattern "pub mod kubernetes" -Quiet) {
Write-Host " ✅ kubernetes module exported" -ForegroundColor Green
} else {
Write-Host " ❌ kubernetes module not exported" -ForegroundColor Red
}
Write-Host " Checking main.rs..." -ForegroundColor Cyan
if (Select-String -Path "src/main.rs" -Pattern "K8sScan" -Quiet) {
Write-Host " ✅ K8sScan command found" -ForegroundColor Green
} else {
Write-Host " ❌ K8sScan command missing" -ForegroundColor Red
}
if (Select-String -Path "src/main.rs" -Pattern "K8sManage" -Quiet) {
Write-Host " ✅ K8sManage command found" -ForegroundColor Green
} else {
Write-Host " ❌ K8sManage command missing" -ForegroundColor Red
}
Write-Host ""
Write-Host "📦 Validating Cargo.toml..." -ForegroundColor Yellow
if (Select-String -Path "Cargo.toml" -Pattern "kube" -Quiet) {
Write-Host " ✅ Kubernetes dependencies found" -ForegroundColor Green
} else {
Write-Host " ❌ Kubernetes dependencies missing" -ForegroundColor Red
}
if (Select-String -Path "Cargo.toml" -Pattern "k8s-openapi" -Quiet) {
Write-Host " ✅ k8s-openapi dependency found" -ForegroundColor Green
} else {
Write-Host " ❌ k8s-openapi dependency missing" -ForegroundColor Red
}
Write-Host ""
Write-Host "🐳 Validating Dockerfile..." -ForegroundColor Yellow
if (Test-Path "Dockerfile") {
if (Select-String -Path "Dockerfile" -Pattern "FROM rust" -Quiet) {
Write-Host " ✅ Multi-stage build structure found" -ForegroundColor Green
} else {
Write-Host " ❌ Multi-stage build structure missing" -ForegroundColor Red
}
if (Select-String -Path "Dockerfile" -Pattern "stellar-scanner" -Quiet) {
Write-Host " ✅ Scanner binary referenced" -ForegroundColor Green
} else {
Write-Host " ❌ Scanner binary not referenced" -ForegroundColor Red
}
}
Write-Host ""
Write-Host "📚 Validating documentation..." -ForegroundColor Yellow
if (Test-Path "k8s/README.md") {
Write-Host " ✅ k8s/README.md exists" -ForegroundColor Green
if (Select-String -Path "k8s/README.md" -Pattern "Security Features" -Quiet) {
Write-Host " ✅ Security documentation included" -ForegroundColor Green
} else {
Write-Host " ⚠️ Security documentation may be incomplete" -ForegroundColor Yellow
}
}
if (Test-Path "KUBERNETES_IMPLEMENTATION.md") {
Write-Host " ✅ Implementation documentation exists" -ForegroundColor Green
} else {
Write-Host " ❌ Implementation documentation missing" -ForegroundColor Red
}
Write-Host ""
Write-Host "🔍 Checking implementation completeness..." -ForegroundColor Yellow
# Count key features implemented
$features = @("ResourceQuota", "NetworkPolicy", "sidecar", "encryption", "auto-scaling", "cleanup", "isolation")
$implemented = 0
foreach ($feature in $features) {
$found = Get-ChildItem -Recurse -Exclude target,.git | Select-String -Pattern $feature -Quiet
if ($found) {
Write-Host " ✅ $feature implemented" -ForegroundColor Green
$implemented++
} else {
Write-Host " ❌ $feature not found" -ForegroundColor Red
}
}
Write-Host ""
Write-Host "📊 Implementation Summary:" -ForegroundColor Cyan
Write-Host " Features implemented: $implemented/$($features.Count)" -ForegroundColor White
$fileCount = (Get-ChildItem -Recurse -Include *.rs,*.yaml,*.md,Dockerfile | Where-Object { $_.FullName -notlike "*target*" -and $_.FullName -notlike "*\.git*" }).Count
Write-Host " Files created: $fileCount" -ForegroundColor White
$docCount = (Get-ChildItem -Recurse -Include *.md | Where-Object { $_.FullName -notlike "*target*" -and $_.FullName -notlike "*\.git*" }).Count
Write-Host " Documentation files: $docCount" -ForegroundColor White
Write-Host ""
if ($implemented -eq $features.Count) {
Write-Host "🎉 All required features implemented!" -ForegroundColor Green
Write-Host "✅ Implementation validation PASSED" -ForegroundColor Green
} else {
Write-Host "⚠️ Some features may be missing" -ForegroundColor Yellow
Write-Host "❌ Implementation validation FAILED" -ForegroundColor Red
exit 1
}
Write-Host ""
Write-Host "🚀 Next steps:" -ForegroundColor Cyan
Write-Host " 1. Install Visual Studio Build Tools for Windows compilation" -ForegroundColor White
Write-Host " 2. Run: cargo build to verify compilation" -ForegroundColor White
Write-Host " 3. Deploy to Kubernetes: kubectl apply -f k8s/" -ForegroundColor White
Write-Host " 4. Test with: stellar-scanner k8s-scan --help" -ForegroundColor White