MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / compute_confidence

Function compute_confidence

crates/openshell-sandbox/src/mechanistic_mapper.rs:261–282  ·  view source on GitHub ↗

Compute a confidence score (0.0 to 1.0) for a proposed rule.

(total_count: u32, port: u16, is_ssrf: bool)

Source from the content-addressed store, hash-verified

259
260/// Compute a confidence score (0.0 to 1.0) for a proposed rule.
261fn 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.
285fn generate_security_notes(host: &str, port: u16, is_ssrf: bool) -> String {

Callers 2

generate_proposalsFunction · 0.85
test_compute_confidenceFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_compute_confidenceFunction · 0.68