mirror of
https://github.com/aaif-goose/goose.git
synced 2026-07-03 14:10:03 +02:00
Fix: Minor logging uplift for debugging of prompt injection mitigation (#7195)
This commit is contained in:
committed by
GitHub
parent
b26d7afe2e
commit
e32720fcfb
@@ -68,6 +68,20 @@ impl SecurityManager {
|
||||
}
|
||||
|
||||
let scanner = self.scanner.get_or_init(|| {
|
||||
let config = Config::global();
|
||||
let command_classifier_enabled = config
|
||||
.get_param::<bool>("SECURITY_COMMAND_CLASSIFIER_ENABLED")
|
||||
.unwrap_or(false);
|
||||
let prompt_classifier_enabled = config
|
||||
.get_param::<bool>("SECURITY_PROMPT_CLASSIFIER_ENABLED")
|
||||
.unwrap_or(false);
|
||||
|
||||
tracing::info!(
|
||||
monotonic_counter.goose.security_command_classifier_enabled = if command_classifier_enabled { 1 } else { 0 },
|
||||
monotonic_counter.goose.security_prompt_classifier_enabled = if prompt_classifier_enabled { 1 } else { 0 },
|
||||
"Security classifier configuration"
|
||||
);
|
||||
|
||||
let ml_enabled = self.is_ml_scanning_enabled();
|
||||
|
||||
let scanner = if ml_enabled {
|
||||
|
||||
@@ -27,6 +27,7 @@ struct DetailedScanResult {
|
||||
confidence: f32,
|
||||
pattern_matches: Vec<PatternMatch>,
|
||||
ml_confidence: Option<f32>,
|
||||
used_pattern_detection: bool,
|
||||
}
|
||||
|
||||
pub struct PromptInjectionScanner {
|
||||
@@ -160,9 +161,9 @@ impl PromptInjectionScanner {
|
||||
tool_confidence = %tool_result.confidence,
|
||||
context_confidence = ?context_result.ml_confidence,
|
||||
final_confidence = %final_confidence,
|
||||
has_command_ml = tool_result.ml_confidence.is_some(),
|
||||
has_prompt_ml = context_result.ml_confidence.is_some(),
|
||||
has_patterns = !tool_result.pattern_matches.is_empty(),
|
||||
used_command_ml = tool_result.ml_confidence.is_some(),
|
||||
used_prompt_ml = context_result.ml_confidence.is_some(),
|
||||
used_pattern_detection = tool_result.used_pattern_detection,
|
||||
threshold = %threshold,
|
||||
malicious = final_confidence >= threshold,
|
||||
"Security analysis complete"
|
||||
@@ -172,6 +173,7 @@ impl PromptInjectionScanner {
|
||||
confidence: final_confidence,
|
||||
pattern_matches: tool_result.pattern_matches,
|
||||
ml_confidence: tool_result.ml_confidence,
|
||||
used_pattern_detection: tool_result.used_pattern_detection,
|
||||
};
|
||||
|
||||
Ok(ScanResult {
|
||||
@@ -191,6 +193,7 @@ impl PromptInjectionScanner {
|
||||
confidence: ml_confidence,
|
||||
pattern_matches: Vec::new(),
|
||||
ml_confidence: Some(ml_confidence),
|
||||
used_pattern_detection: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -200,6 +203,7 @@ impl PromptInjectionScanner {
|
||||
confidence: pattern_confidence,
|
||||
pattern_matches,
|
||||
ml_confidence: None,
|
||||
used_pattern_detection: true,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -211,6 +215,7 @@ impl PromptInjectionScanner {
|
||||
confidence: 0.0,
|
||||
pattern_matches: Vec::new(),
|
||||
ml_confidence: None,
|
||||
used_pattern_detection: false,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -219,6 +224,7 @@ impl PromptInjectionScanner {
|
||||
confidence: 0.0,
|
||||
pattern_matches: Vec::new(),
|
||||
ml_confidence: None,
|
||||
used_pattern_detection: false,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -237,6 +243,7 @@ impl PromptInjectionScanner {
|
||||
confidence: max_confidence,
|
||||
pattern_matches: Vec::new(),
|
||||
ml_confidence: Some(max_confidence),
|
||||
used_pattern_detection: false,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user