More logging for command injection classifier model training (#7779)
This commit is contained in:
committed by
GitHub
parent
55023ca873
commit
6d6c6b3228
@@ -165,13 +165,18 @@ impl SecurityManager {
|
|||||||
tool_request_id: tool_request.id.clone(),
|
tool_request_id: tool_request.id.clone(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else if analysis_result.scanned {
|
||||||
|
let tool_call_json =
|
||||||
|
serde_json::to_string(&tool_call).unwrap_or_else(|_| "{}".to_string());
|
||||||
|
|
||||||
tracing::info!(
|
tracing::info!(
|
||||||
|
monotonic_counter.goose.prompt_injection_tool_call_passed = 1,
|
||||||
tool_name = %tool_call.name,
|
tool_name = %tool_call.name,
|
||||||
tool_request_id = %tool_request.id,
|
tool_request_id = %tool_request.id,
|
||||||
|
tool_call_json = %tool_call_json,
|
||||||
confidence = analysis_result.confidence,
|
confidence = analysis_result.confidence,
|
||||||
explanation = %sanitized_explanation,
|
explanation = %sanitized_explanation,
|
||||||
"✅ Current tool call passed security analysis"
|
"Current tool call passed security analysis"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ pub struct ScanResult {
|
|||||||
pub is_malicious: bool,
|
pub is_malicious: bool,
|
||||||
pub confidence: f32,
|
pub confidence: f32,
|
||||||
pub explanation: String,
|
pub explanation: String,
|
||||||
|
pub scanned: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DetailedScanResult {
|
struct DetailedScanResult {
|
||||||
@@ -127,6 +128,7 @@ impl PromptInjectionScanner {
|
|||||||
is_malicious: false,
|
is_malicious: false,
|
||||||
confidence: 0.0,
|
confidence: 0.0,
|
||||||
explanation: "Tool call skipped: only shell commands are scanned".to_string(),
|
explanation: "Tool call skipped: only shell commands are scanned".to_string(),
|
||||||
|
scanned: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,6 +182,7 @@ impl PromptInjectionScanner {
|
|||||||
is_malicious: final_confidence >= threshold,
|
is_malicious: final_confidence >= threshold,
|
||||||
confidence: final_confidence,
|
confidence: final_confidence,
|
||||||
explanation: self.build_explanation(&final_result, threshold, &tool_content),
|
explanation: self.build_explanation(&final_result, threshold, &tool_content),
|
||||||
|
scanned: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user