fix: treat tools.alsoAllow as implicit allow-all when no allowlist
This commit is contained in:
committed by
Pocket Clawd
parent
2ad3508a33
commit
d62b7c0d1e
@@ -103,7 +103,11 @@ type ToolPolicyConfig = {
|
||||
|
||||
function unionAllow(base?: string[], extra?: string[]) {
|
||||
if (!Array.isArray(extra) || extra.length === 0) return base;
|
||||
if (!Array.isArray(base) || base.length === 0) return base;
|
||||
// If the user is using alsoAllow without an allowlist, treat it as additive on top of
|
||||
// an implicit allow-all policy.
|
||||
if (!Array.isArray(base) || base.length === 0) {
|
||||
return Array.from(new Set(["*", ...extra]));
|
||||
}
|
||||
return Array.from(new Set([...base, ...extra]));
|
||||
}
|
||||
|
||||
@@ -111,7 +115,9 @@ function pickToolPolicy(config?: ToolPolicyConfig): SandboxToolPolicy | undefine
|
||||
if (!config) return undefined;
|
||||
const allow = Array.isArray(config.allow)
|
||||
? unionAllow(config.allow, config.alsoAllow)
|
||||
: undefined;
|
||||
: Array.isArray(config.alsoAllow) && config.alsoAllow.length > 0
|
||||
? unionAllow(undefined, config.alsoAllow)
|
||||
: undefined;
|
||||
const deny = Array.isArray(config.deny) ? config.deny : undefined;
|
||||
if (!allow && !deny) return undefined;
|
||||
return { allow, deny };
|
||||
|
||||
Reference in New Issue
Block a user