Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions crates/goose/src/agents/tool_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ impl Agent {
tracing::info!(
counter.goose.prompt_injection_user_decisions = 1,
decision = ?confirmation.permission,
"🔒 User security decision: {:?} for finding ID: {}",
confirmation.permission,
finding_id
finding_id = %finding_id,
"User security decision"
);
}

Expand Down
22 changes: 11 additions & 11 deletions crates/goose/src/security/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ impl SecurityManager {
) -> Result<Vec<SecurityResult>> {
if !self.is_prompt_injection_detection_enabled() {
tracing::debug!(
gauge.goose.prompt_injection_scanner_enabled = 0,
"🔓 Security scanning disabled"
counter.goose.prompt_injection_scanner_disabled = 1,
"Security scanning disabled"
);
return Ok(vec![]);
}

let scanner = self.scanner.get_or_init(|| {
tracing::info!(
gauge.goose.prompt_injection_scanner_enabled = 1,
"🔓 Security scanner initialized and enabled"
counter.goose.prompt_injection_scanner_enabled = 1,
"Security scanner initialized and enabled"
);
PromptInjectionScanner::new()
});
Expand All @@ -79,26 +79,26 @@ impl SecurityManager {

// Get threshold from config - only flag things above threshold
let config_threshold = scanner.get_threshold_from_config();
let sanitized_explanation = analysis_result.explanation.replace('\n', " | ");

if analysis_result.is_malicious {
let above_threshold = analysis_result.confidence > config_threshold;
let finding_id = format!("SEC-{}", Uuid::new_v4().simple());

tracing::warn!(
counter.goose.prompt_injection_finding = 1,
gauge.goose.prompt_injection_confidence_score = analysis_result.confidence,
above_threshold = above_threshold,
tool_name = %tool_call.name,
tool_request_id = %tool_request.id,
confidence = analysis_result.confidence,
explanation = %analysis_result.explanation,
explanation = %sanitized_explanation,
finding_id = %finding_id,
threshold = config_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 {
"🔒 Security finding below threshold - logged but not blocking execution"
"Security finding below threshold - logged but not blocking execution"
}
);
if above_threshold {
Expand All @@ -116,7 +116,7 @@ impl SecurityManager {
tool_name = %tool_call.name,
tool_request_id = %tool_request.id,
confidence = analysis_result.confidence,
explanation = %analysis_result.explanation,
explanation = %sanitized_explanation,
"✅ Current tool call passed security analysis"
);
}
Expand All @@ -125,8 +125,8 @@ impl SecurityManager {

tracing::info!(
counter.goose.prompt_injection_analysis_performed = 1,
"🔍 Security analysis complete - found {} security issues in current tool requests",
results.len()
security_issues_found = results.len(),
"Security analysis complete"
);
Ok(results)
}
Expand Down
Loading