Compute a confidence score (0.0 to 1.0) for a proposed rule.
(total_count: u32, port: u16, is_ssrf: bool)
| 259 | |
| 260 | /// Compute a confidence score (0.0 to 1.0) for a proposed rule. |
| 261 | fn compute_confidence(total_count: u32, port: u16, is_ssrf: bool) -> f32 { |
| 262 | let mut score: f32 = 0.5; |
| 263 | |
| 264 | // Higher count → higher confidence (the denial is repeatable). |
| 265 | if total_count >= 10 { |
| 266 | score += 0.2; |
| 267 | } else if total_count >= 3 { |
| 268 | score += 0.1; |
| 269 | } |
| 270 | |
| 271 | // Well-known port → higher confidence. |
| 272 | if WELL_KNOWN_PORTS.iter().any(|(p, _)| *p == port) { |
| 273 | score += 0.15; |
| 274 | } |
| 275 | |
| 276 | // SSRF denials are lower confidence (may be legitimate blocking). |
| 277 | if is_ssrf { |
| 278 | score -= 0.2; |
| 279 | } |
| 280 | |
| 281 | score.clamp(0.1, 0.95) |
| 282 | } |
| 283 | |
| 284 | /// Generate security notes for a proposed rule. |
| 285 | fn generate_security_notes(host: &str, port: u16, is_ssrf: bool) -> String { |
no outgoing calls