Update prompt injection detection metrics (due to errors exporting to datadog) (#5692)
This commit is contained in:
committed by
GitHub
parent
f7a18783ae
commit
387d76c5ff
@@ -87,9 +87,8 @@ impl Agent {
|
|||||||
tracing::info!(
|
tracing::info!(
|
||||||
counter.goose.prompt_injection_user_decisions = 1,
|
counter.goose.prompt_injection_user_decisions = 1,
|
||||||
decision = ?confirmation.permission,
|
decision = ?confirmation.permission,
|
||||||
"🔒 User security decision: {:?} for finding ID: {}",
|
finding_id = %finding_id,
|
||||||
confirmation.permission,
|
"User security decision"
|
||||||
finding_id
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,16 +48,16 @@ impl SecurityManager {
|
|||||||
) -> Result<Vec<SecurityResult>> {
|
) -> Result<Vec<SecurityResult>> {
|
||||||
if !self.is_prompt_injection_detection_enabled() {
|
if !self.is_prompt_injection_detection_enabled() {
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
gauge.goose.prompt_injection_scanner_enabled = 0,
|
counter.goose.prompt_injection_scanner_disabled = 1,
|
||||||
"🔓 Security scanning disabled"
|
"Security scanning disabled"
|
||||||
);
|
);
|
||||||
return Ok(vec![]);
|
return Ok(vec![]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let scanner = self.scanner.get_or_init(|| {
|
let scanner = self.scanner.get_or_init(|| {
|
||||||
tracing::info!(
|
tracing::info!(
|
||||||
gauge.goose.prompt_injection_scanner_enabled = 1,
|
counter.goose.prompt_injection_scanner_enabled = 1,
|
||||||
"🔓 Security scanner initialized and enabled"
|
"Security scanner initialized and enabled"
|
||||||
);
|
);
|
||||||
PromptInjectionScanner::new()
|
PromptInjectionScanner::new()
|
||||||
});
|
});
|
||||||
@@ -79,6 +79,7 @@ impl SecurityManager {
|
|||||||
|
|
||||||
// Get threshold from config - only flag things above threshold
|
// Get threshold from config - only flag things above threshold
|
||||||
let config_threshold = scanner.get_threshold_from_config();
|
let config_threshold = scanner.get_threshold_from_config();
|
||||||
|
let sanitized_explanation = analysis_result.explanation.replace('\n', " | ");
|
||||||
|
|
||||||
if analysis_result.is_malicious {
|
if analysis_result.is_malicious {
|
||||||
let above_threshold = analysis_result.confidence > config_threshold;
|
let above_threshold = analysis_result.confidence > config_threshold;
|
||||||
@@ -86,19 +87,18 @@ impl SecurityManager {
|
|||||||
|
|
||||||
tracing::warn!(
|
tracing::warn!(
|
||||||
counter.goose.prompt_injection_finding = 1,
|
counter.goose.prompt_injection_finding = 1,
|
||||||
gauge.goose.prompt_injection_confidence_score = analysis_result.confidence,
|
|
||||||
above_threshold = above_threshold,
|
above_threshold = above_threshold,
|
||||||
tool_name = %tool_call.name,
|
tool_name = %tool_call.name,
|
||||||
tool_request_id = %tool_request.id,
|
tool_request_id = %tool_request.id,
|
||||||
confidence = analysis_result.confidence,
|
confidence = analysis_result.confidence,
|
||||||
explanation = %analysis_result.explanation,
|
explanation = %sanitized_explanation,
|
||||||
finding_id = %finding_id,
|
finding_id = %finding_id,
|
||||||
threshold = config_threshold,
|
threshold = config_threshold,
|
||||||
"{}",
|
"{}",
|
||||||
if above_threshold {
|
if above_threshold {
|
||||||
"🔒 Current tool call flagged as malicious after security analysis (above threshold)"
|
"Current tool call flagged as malicious after security analysis (above threshold)"
|
||||||
} else {
|
} else {
|
||||||
"🔒 Security finding below threshold - logged but not blocking execution"
|
"Security finding below threshold - logged but not blocking execution"
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if above_threshold {
|
if above_threshold {
|
||||||
@@ -116,7 +116,7 @@ impl SecurityManager {
|
|||||||
tool_name = %tool_call.name,
|
tool_name = %tool_call.name,
|
||||||
tool_request_id = %tool_request.id,
|
tool_request_id = %tool_request.id,
|
||||||
confidence = analysis_result.confidence,
|
confidence = analysis_result.confidence,
|
||||||
explanation = %analysis_result.explanation,
|
explanation = %sanitized_explanation,
|
||||||
"✅ Current tool call passed security analysis"
|
"✅ Current tool call passed security analysis"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -125,8 +125,8 @@ impl SecurityManager {
|
|||||||
|
|
||||||
tracing::info!(
|
tracing::info!(
|
||||||
counter.goose.prompt_injection_analysis_performed = 1,
|
counter.goose.prompt_injection_analysis_performed = 1,
|
||||||
"🔍 Security analysis complete - found {} security issues in current tool requests",
|
security_issues_found = results.len(),
|
||||||
results.len()
|
"Security analysis complete"
|
||||||
);
|
);
|
||||||
Ok(results)
|
Ok(results)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user