fix: include context in elevated exec denial
This commit is contained in:
@@ -67,6 +67,7 @@ Docs: https://docs.clawd.bot
|
|||||||
### Fixes
|
### Fixes
|
||||||
- macOS: drain subprocess pipes before waiting to avoid deadlocks. (#1081) — thanks @thesash.
|
- macOS: drain subprocess pipes before waiting to avoid deadlocks. (#1081) — thanks @thesash.
|
||||||
- Verbose: wrap tool summaries/output in markdown only for markdown-capable channels.
|
- Verbose: wrap tool summaries/output in markdown only for markdown-capable channels.
|
||||||
|
- Tools: include provider/session context in elevated exec denial errors.
|
||||||
- Telegram: accept tg/group/telegram prefixes + topic targets for inline button validation. (#1072) — thanks @danielz1z.
|
- Telegram: accept tg/group/telegram prefixes + topic targets for inline button validation. (#1072) — thanks @danielz1z.
|
||||||
- Telegram: split long captions into follow-up messages.
|
- Telegram: split long captions into follow-up messages.
|
||||||
- Config: block startup on invalid config, preserve best-effort doctor config, and keep rolling config backups. (#1083) — thanks @mukhtharcm.
|
- Config: block startup on invalid config, preserve best-effort doctor config, and keep rolling config backups. (#1083) — thanks @mukhtharcm.
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ export type ExecToolDefaults = {
|
|||||||
allowBackground?: boolean;
|
allowBackground?: boolean;
|
||||||
scopeKey?: string;
|
scopeKey?: string;
|
||||||
sessionKey?: string;
|
sessionKey?: string;
|
||||||
|
messageProvider?: string;
|
||||||
notifyOnExit?: boolean;
|
notifyOnExit?: boolean;
|
||||||
cwd?: string;
|
cwd?: string;
|
||||||
};
|
};
|
||||||
@@ -220,6 +221,11 @@ export function createExecTool(
|
|||||||
if (!elevatedDefaults?.enabled || !elevatedDefaults.allowed) {
|
if (!elevatedDefaults?.enabled || !elevatedDefaults.allowed) {
|
||||||
const runtime = defaults?.sandbox ? "sandboxed" : "direct";
|
const runtime = defaults?.sandbox ? "sandboxed" : "direct";
|
||||||
const gates: string[] = [];
|
const gates: string[] = [];
|
||||||
|
const contextParts: string[] = [];
|
||||||
|
const provider = defaults?.messageProvider?.trim();
|
||||||
|
const sessionKey = defaults?.sessionKey?.trim();
|
||||||
|
if (provider) contextParts.push(`provider=${provider}`);
|
||||||
|
if (sessionKey) contextParts.push(`session=${sessionKey}`);
|
||||||
if (!elevatedDefaults?.enabled) {
|
if (!elevatedDefaults?.enabled) {
|
||||||
gates.push("enabled (tools.elevated.enabled / agents.list[].tools.elevated.enabled)");
|
gates.push("enabled (tools.elevated.enabled / agents.list[].tools.elevated.enabled)");
|
||||||
} else {
|
} else {
|
||||||
@@ -231,12 +237,15 @@ export function createExecTool(
|
|||||||
[
|
[
|
||||||
`elevated is not available right now (runtime=${runtime}).`,
|
`elevated is not available right now (runtime=${runtime}).`,
|
||||||
`Failing gates: ${gates.join(", ")}`,
|
`Failing gates: ${gates.join(", ")}`,
|
||||||
|
contextParts.length > 0 ? `Context: ${contextParts.join(" ")}` : undefined,
|
||||||
"Fix-it keys:",
|
"Fix-it keys:",
|
||||||
"- tools.elevated.enabled",
|
"- tools.elevated.enabled",
|
||||||
"- tools.elevated.allowFrom.<provider>",
|
"- tools.elevated.allowFrom.<provider>",
|
||||||
"- agents.list[].tools.elevated.enabled",
|
"- agents.list[].tools.elevated.enabled",
|
||||||
"- agents.list[].tools.elevated.allowFrom.<provider>",
|
"- agents.list[].tools.elevated.allowFrom.<provider>",
|
||||||
].join("\n"),
|
]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join("\n"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
logInfo(
|
logInfo(
|
||||||
|
|||||||
@@ -150,6 +150,8 @@ describe("exec tool backgrounding", () => {
|
|||||||
it("rejects elevated requests when not allowed", async () => {
|
it("rejects elevated requests when not allowed", async () => {
|
||||||
const customBash = createExecTool({
|
const customBash = createExecTool({
|
||||||
elevated: { enabled: true, allowed: false, defaultLevel: "off" },
|
elevated: { enabled: true, allowed: false, defaultLevel: "off" },
|
||||||
|
messageProvider: "telegram",
|
||||||
|
sessionKey: "agent:main:main",
|
||||||
});
|
});
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
@@ -157,7 +159,7 @@ describe("exec tool backgrounding", () => {
|
|||||||
command: "echo hi",
|
command: "echo hi",
|
||||||
elevated: true,
|
elevated: true,
|
||||||
}),
|
}),
|
||||||
).rejects.toThrow("tools.elevated.allowFrom.<provider>");
|
).rejects.toThrow("Context: provider=telegram session=agent:main:main");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not default to elevated when not allowed", async () => {
|
it("does not default to elevated when not allowed", async () => {
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ export function createClawdbotCodingTools(options?: {
|
|||||||
allowBackground,
|
allowBackground,
|
||||||
scopeKey,
|
scopeKey,
|
||||||
sessionKey: options?.sessionKey,
|
sessionKey: options?.sessionKey,
|
||||||
|
messageProvider: options?.messageProvider,
|
||||||
sandbox: sandbox
|
sandbox: sandbox
|
||||||
? {
|
? {
|
||||||
containerName: sandbox.containerName,
|
containerName: sandbox.containerName,
|
||||||
|
|||||||
Reference in New Issue
Block a user