feat(http_request): support wildcard "*" in allowed_domains
Allow ["*"] in http_request.allowed_domains to permit all public domains without listing each one individually. Private/localhost hosts remain blocked regardless. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
0027b4d746
commit
6a69b47b8a
1 changed files with 4 additions and 2 deletions
|
|
@ -46,17 +46,19 @@ impl HttpRequestTool {
|
|||
|
||||
if self.allowed_domains.is_empty() {
|
||||
anyhow::bail!(
|
||||
"HTTP request tool is enabled but no allowed_domains are configured. Add [http_request].allowed_domains in config.toml"
|
||||
"HTTP request tool is enabled but no allowed_domains are configured. Add [http_request].allowed_domains in config.toml or use [\"*\"] to allow all domains"
|
||||
);
|
||||
}
|
||||
|
||||
let allow_all = self.allowed_domains.iter().any(|d| d == "*");
|
||||
|
||||
let host = extract_host(url)?;
|
||||
|
||||
if is_private_or_local_host(&host) {
|
||||
anyhow::bail!("Blocked local/private host: {host}");
|
||||
}
|
||||
|
||||
if !host_matches_allowlist(&host, &self.allowed_domains) {
|
||||
if !allow_all && !host_matches_allowlist(&host, &self.allowed_domains) {
|
||||
anyhow::bail!("Host '{host}' is not in http_request.allowed_domains");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue