Prompt injection detection (simplified - only pattern matching) (#4237)
Signed-off-by: Dorien Koelemeijer <dkoelemeijer@squareup.com> merging as looks good, lets keep an eye on it.
This commit is contained in:
committed by
GitHub
parent
9bb1bb530c
commit
916ba902dc
@@ -256,11 +256,6 @@ pub async fn build_session(session_config: SessionBuilderConfig) -> Session {
|
||||
process::exit(1);
|
||||
});
|
||||
|
||||
// Configure tool monitoring if max_tool_repetitions is set
|
||||
if let Some(max_repetitions) = session_config.max_tool_repetitions {
|
||||
agent.configure_tool_monitor(Some(max_repetitions)).await;
|
||||
}
|
||||
|
||||
// Handle session file resolution and resuming
|
||||
let session_file: Option<std::path::PathBuf> = if session_config.no_session {
|
||||
None
|
||||
|
||||
@@ -942,16 +942,31 @@ impl Session {
|
||||
if let Some(MessageContent::ToolConfirmationRequest(confirmation)) = message.content.first() {
|
||||
output::hide_thinking();
|
||||
|
||||
// Format the confirmation prompt
|
||||
let prompt = "Goose would like to call the above tool, do you allow?".to_string();
|
||||
// Format the confirmation prompt - use security message if present, otherwise use generic message
|
||||
let prompt = if let Some(security_message) = &confirmation.prompt {
|
||||
println!("\n{}", security_message);
|
||||
"Do you allow this tool call?".to_string()
|
||||
} else {
|
||||
"Goose would like to call the above tool, do you allow?".to_string()
|
||||
};
|
||||
|
||||
// Get confirmation from user
|
||||
let permission_result = cliclack::select(prompt)
|
||||
.item(Permission::AllowOnce, "Allow", "Allow the tool call once")
|
||||
.item(Permission::AlwaysAllow, "Always Allow", "Always allow the tool call")
|
||||
.item(Permission::DenyOnce, "Deny", "Deny the tool call")
|
||||
.item(Permission::Cancel, "Cancel", "Cancel the AI response and tool call")
|
||||
.interact();
|
||||
let permission_result = if confirmation.prompt.is_none() {
|
||||
// No security message - show all options including "Always Allow"
|
||||
cliclack::select(prompt)
|
||||
.item(Permission::AllowOnce, "Allow", "Allow the tool call once")
|
||||
.item(Permission::AlwaysAllow, "Always Allow", "Always allow the tool call")
|
||||
.item(Permission::DenyOnce, "Deny", "Deny the tool call")
|
||||
.item(Permission::Cancel, "Cancel", "Cancel the AI response and tool call")
|
||||
.interact()
|
||||
} else {
|
||||
// Security message present - don't show "Always Allow"
|
||||
cliclack::select(prompt)
|
||||
.item(Permission::AllowOnce, "Allow", "Allow the tool call once")
|
||||
.item(Permission::DenyOnce, "Deny", "Deny the tool call")
|
||||
.item(Permission::Cancel, "Cancel", "Cancel the AI response and tool call")
|
||||
.interact()
|
||||
};
|
||||
|
||||
let permission = match permission_result {
|
||||
Ok(p) => p, // If Ok, use the selected permission
|
||||
|
||||
Reference in New Issue
Block a user