Skip to content

Commit 785bad3

Browse files
committed
Merge remote-tracking branch 'origin/main' into prodRelease092625
2 parents c4c80bb + a8a815a commit 785bad3

32 files changed

+3024
-172
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ authors = ["Amazon Q CLI Team (q-cli@amazon.com)", "Chay Nabors (nabochay@amazon
88
edition = "2024"
99
homepage = "https://aws.amazon.com/q/"
1010
publish = false
11-
version = "1.16.2"
11+
version = "1.16.3"
1212
license = "MIT OR Apache-2.0"
1313

1414
[workspace.dependencies]

crates/chat-cli/src/auth/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ pub use builder_id::{
1414
pub use consts::START_URL;
1515
use thiserror::Error;
1616

17+
use crate::aws_common::SdkErrorDisplay;
18+
1719
#[derive(Debug, Error)]
1820
pub enum AuthError {
1921
#[error(transparent)]
2022
Ssooidc(Box<aws_sdk_ssooidc::Error>),
21-
#[error(transparent)]
23+
#[error("{}", SdkErrorDisplay(.0))]
2224
SdkRegisterClient(Box<SdkError<RegisterClientError>>),
23-
#[error(transparent)]
25+
#[error("{}", SdkErrorDisplay(.0))]
2426
SdkCreateToken(Box<SdkError<CreateTokenError>>),
25-
#[error(transparent)]
27+
#[error("{}", SdkErrorDisplay(.0))]
2628
SdkStartDeviceAuthorization(Box<SdkError<StartDeviceAuthorizationError>>),
2729
#[error(transparent)]
2830
Io(#[from] std::io::Error),

crates/chat-cli/src/cli/agent/mod.rs

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -776,32 +776,14 @@ impl Agents {
776776

777777
/// Returns a label to describe the permission status for a given tool.
778778
pub fn display_label(&self, tool_name: &str, origin: &ToolOrigin) -> String {
779-
use crate::util::pattern_matching::matches_any_pattern;
779+
use crate::util::tool_permission_checker::is_tool_in_allowlist;
780780

781781
let tool_trusted = self.get_active().is_some_and(|a| {
782-
if matches!(origin, &ToolOrigin::Native) {
783-
return matches_any_pattern(&a.allowed_tools, tool_name);
784-
}
785-
786-
a.allowed_tools.iter().any(|name| {
787-
name.strip_prefix("@").is_some_and(|remainder| {
788-
remainder
789-
.split_once(MCP_SERVER_TOOL_DELIMITER)
790-
.is_some_and(|(_left, right)| right == tool_name)
791-
|| remainder == <ToolOrigin as Borrow<str>>::borrow(origin)
792-
}) || {
793-
if let Some(server_name) = name.strip_prefix("@").and_then(|s| s.split('/').next()) {
794-
if server_name == <ToolOrigin as Borrow<str>>::borrow(origin) {
795-
let tool_pattern = format!("@{}/{}", server_name, tool_name);
796-
matches_any_pattern(&a.allowed_tools, &tool_pattern)
797-
} else {
798-
false
799-
}
800-
} else {
801-
false
802-
}
803-
}
804-
})
782+
let server_name = match origin {
783+
ToolOrigin::Native => None,
784+
ToolOrigin::McpServer(_) => Some(<ToolOrigin as Borrow<str>>::borrow(origin)),
785+
};
786+
is_tool_in_allowlist(&a.allowed_tools, tool_name, server_name)
805787
});
806788

807789
if tool_trusted || self.trust_all_tools {
@@ -818,9 +800,9 @@ impl Agents {
818800
"fs_read" => "trust working directory".dark_grey(),
819801
"fs_write" => "not trusted".dark_grey(),
820802
#[cfg(not(windows))]
821-
"execute_bash" => "trust read-only commands".dark_grey(),
803+
"execute_bash" => "not trusted".dark_grey(),
822804
#[cfg(windows)]
823-
"execute_cmd" => "trust read-only commands".dark_grey(),
805+
"execute_cmd" => "not trusted".dark_grey(),
824806
"use_aws" => "trust read-only commands".dark_grey(),
825807
"report_issue" => "trusted".dark_green().bold(),
826808
"introspect" => "trusted".dark_green().bold(),
@@ -1189,8 +1171,8 @@ mod tests {
11891171
let execute_name = if cfg!(windows) { "execute_cmd" } else { "execute_bash" };
11901172
let execute_bash_label = agents.display_label(execute_name, &ToolOrigin::Native);
11911173
assert!(
1192-
execute_bash_label.contains("read-only"),
1193-
"execute_bash should show read-only by default, instead found: {}",
1174+
execute_bash_label.contains("not trusted"),
1175+
"execute_bash should not be trusted by default, instead found: {}",
11941176
execute_bash_label
11951177
);
11961178
}

0 commit comments

Comments
 (0)