website_vulnerability_scanner/
registry.rs1use crate::models::{Category, ScanProfile};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4pub enum OperationKind {
5 PassiveAnalysis,
6 ActiveProbe,
7}
8
9#[derive(Debug, Clone, Copy)]
10pub struct CheckDefinition {
11 pub id: &'static str,
12 pub name: &'static str,
13 pub category: Category,
14 pub operation_kind: OperationKind,
15 pub applicable_web: bool,
16 pub applicable_api: bool,
17 pub remediation_key: &'static str,
18}
19
20impl CheckDefinition {
21 pub fn applies_to(&self, profile: ScanProfile) -> bool {
22 match profile {
23 ScanProfile::Web => self.applicable_web,
24 ScanProfile::Api => self.applicable_api,
25 }
26 }
27}
28
29pub const BUILTIN_CHECKS: &[CheckDefinition] = &[
30 CheckDefinition {
31 id: "tls-inspection",
32 name: "TLS Handshake & Certificate Inspection",
33 category: Category::TransportTls,
34 operation_kind: OperationKind::ActiveProbe,
35 applicable_web: true,
36 applicable_api: true,
37 remediation_key: "tls",
38 },
39 CheckDefinition {
40 id: "http-redirect",
41 name: "HTTP-to-HTTPS Redirect Verification",
42 category: Category::TransportTls,
43 operation_kind: OperationKind::ActiveProbe,
44 applicable_web: true,
45 applicable_api: true,
46 remediation_key: "https_redirect",
47 },
48 CheckDefinition {
49 id: "dns-hygiene",
50 name: "DNS CAA, SPF, and DMARC Records",
51 category: Category::DnsEmail,
52 operation_kind: OperationKind::ActiveProbe,
53 applicable_web: true,
54 applicable_api: true,
55 remediation_key: "dns",
56 },
57 CheckDefinition {
58 id: "security-headers",
59 name: "OWASP Security Headers & Stack Disclosure",
60 category: Category::SecurityHeaders,
61 operation_kind: OperationKind::PassiveAnalysis,
62 applicable_web: true,
63 applicable_api: true,
64 remediation_key: "headers",
65 },
66 CheckDefinition {
67 id: "cookie-attributes",
68 name: "Set-Cookie Security Attributes",
69 category: Category::Cookies,
70 operation_kind: OperationKind::PassiveAnalysis,
71 applicable_web: true,
72 applicable_api: true,
73 remediation_key: "cookies",
74 },
75 CheckDefinition {
76 id: "cache-control",
77 name: "Sensitive Response Cache-Control",
78 category: Category::HttpProtocol,
79 operation_kind: OperationKind::PassiveAnalysis,
80 applicable_web: true,
81 applicable_api: true,
82 remediation_key: "caching",
83 },
84 CheckDefinition {
85 id: "cors-policy",
86 name: "CORS Origin Reflection & Wildcard Policy",
87 category: Category::Cors,
88 operation_kind: OperationKind::ActiveProbe,
89 applicable_web: true,
90 applicable_api: true,
91 remediation_key: "cors",
92 },
93 CheckDefinition {
94 id: "http-methods",
95 name: "HTTP OPTIONS & TRACE Method Probe",
96 category: Category::HttpProtocol,
97 operation_kind: OperationKind::ActiveProbe,
98 applicable_web: true,
99 applicable_api: true,
100 remediation_key: "methods",
101 },
102 CheckDefinition {
103 id: "html-client-hygiene",
104 name: "HTML Mixed Content, SRI, Forms & JS Libraries",
105 category: Category::ClientHtml,
106 operation_kind: OperationKind::PassiveAnalysis,
107 applicable_web: true,
108 applicable_api: false,
109 remediation_key: "html",
110 },
111 CheckDefinition {
112 id: "exposed-artifacts",
113 name: "Exposed Deployment Metadata & Config Paths",
114 category: Category::ExposedFiles,
115 operation_kind: OperationKind::ActiveProbe,
116 applicable_web: true,
117 applicable_api: true,
118 remediation_key: "dotfiles",
119 },
120 CheckDefinition {
121 id: "tls-legacy-versions",
122 name: "Legacy TLS 1.0 / 1.1 Handshake Probe",
123 category: Category::TransportTls,
124 operation_kind: OperationKind::ActiveProbe,
125 applicable_web: true,
126 applicable_api: true,
127 remediation_key: "tls_legacy",
128 },
129 CheckDefinition {
130 id: "response-secrets-leaks",
131 name: "Response Secret, Private Key, JWT & Stacktrace Audit",
132 category: Category::SecretsAndLeaks,
133 operation_kind: OperationKind::PassiveAnalysis,
134 applicable_web: true,
135 applicable_api: true,
136 remediation_key: "secrets",
137 },
138 CheckDefinition {
139 id: "js-bundle-discovery",
140 name: "JS Bundle Advisory, SourceMap & Route Discovery",
141 category: Category::ClientHtml,
142 operation_kind: OperationKind::ActiveProbe,
143 applicable_web: true,
144 applicable_api: false,
145 remediation_key: "js_bundles",
146 },
147 CheckDefinition {
148 id: "openapi-security",
149 name: "OpenAPI / Swagger Spec & Endpoint Hygiene Audit",
150 category: Category::ApiSecurity,
151 operation_kind: OperationKind::ActiveProbe,
152 applicable_web: true,
153 applicable_api: true,
154 remediation_key: "openapi",
155 },
156 CheckDefinition {
157 id: "unauth-route-access",
158 name: "Anonymous vs Authenticated Access Parity Check",
159 category: Category::ApiSecurity,
160 operation_kind: OperationKind::ActiveProbe,
161 applicable_web: true,
162 applicable_api: true,
163 remediation_key: "auth_parity",
164 },
165];
166
167#[cfg(test)]
168mod tests {
169 use super::*;
170
171 #[test]
172 fn registry_has_unique_ids_and_profile_applicability() {
173 let mut seen = std::collections::HashSet::new();
174 for def in BUILTIN_CHECKS {
175 assert!(seen.insert(def.id), "duplicate check id {}", def.id);
176 }
177 let html_def = BUILTIN_CHECKS
178 .iter()
179 .find(|c| c.id == "html-client-hygiene")
180 .unwrap();
181 assert!(html_def.applies_to(ScanProfile::Web));
182 assert!(!html_def.applies_to(ScanProfile::Api));
183 }
184}