Fix: Small update UI settings prompt injection (#6830)
This commit is contained in:
committed by
GitHub
parent
2c16e34158
commit
a3be331fe6
@@ -43,9 +43,15 @@ impl SecurityManager {
|
||||
fn is_ml_scanning_enabled(&self) -> bool {
|
||||
let config = Config::global();
|
||||
|
||||
config
|
||||
let prompt_enabled = config
|
||||
.get_param::<bool>("SECURITY_PROMPT_CLASSIFIER_ENABLED")
|
||||
.unwrap_or(false)
|
||||
.unwrap_or(false);
|
||||
|
||||
let command_enabled = config
|
||||
.get_param::<bool>("SECURITY_COMMAND_CLASSIFIER_ENABLED")
|
||||
.unwrap_or(false);
|
||||
|
||||
prompt_enabled || command_enabled
|
||||
}
|
||||
|
||||
pub async fn analyze_tool_requests(
|
||||
|
||||
@@ -149,18 +149,19 @@ impl PromptInjectionScanner {
|
||||
tracing::info!(
|
||||
"Classifier Results - Command: {:.3}, Prompt: {:.3}, Threshold: {:.3}",
|
||||
tool_result.confidence,
|
||||
context_result.confidence,
|
||||
context_result.ml_confidence.unwrap_or(0.0),
|
||||
threshold
|
||||
);
|
||||
|
||||
let final_confidence =
|
||||
self.combine_confidences(tool_result.confidence, context_result.confidence);
|
||||
self.combine_confidences(tool_result.confidence, context_result.ml_confidence);
|
||||
|
||||
tracing::info!(
|
||||
tool_confidence = %tool_result.confidence,
|
||||
context_confidence = %context_result.confidence,
|
||||
context_confidence = ?context_result.ml_confidence,
|
||||
final_confidence = %final_confidence,
|
||||
has_ml = tool_result.ml_confidence.is_some(),
|
||||
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(),
|
||||
threshold = %threshold,
|
||||
malicious = final_confidence >= threshold,
|
||||
@@ -239,7 +240,11 @@ impl PromptInjectionScanner {
|
||||
})
|
||||
}
|
||||
|
||||
fn combine_confidences(&self, tool_confidence: f32, context_confidence: f32) -> f32 {
|
||||
fn combine_confidences(&self, tool_confidence: f32, context_confidence: Option<f32>) -> f32 {
|
||||
let Some(context_confidence) = context_confidence else {
|
||||
return tool_confidence;
|
||||
};
|
||||
|
||||
// If tool is safe, context is not taken into account
|
||||
if tool_confidence < 0.3 {
|
||||
return tool_confidence;
|
||||
|
||||
Reference in New Issue
Block a user