@dreb/coding-agent 2.7.0 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +26 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/forbidden-commands.d.ts +25 -0
- package/dist/core/forbidden-commands.d.ts.map +1 -1
- package/dist/core/forbidden-commands.js +175 -3
- package/dist/core/forbidden-commands.js.map +1 -1
- package/package.json +1 -1
|
@@ -24,7 +24,7 @@ import { DEFAULT_THINKING_LEVEL } from "./defaults.js";
|
|
|
24
24
|
import { exportSessionToHtml } from "./export-html/index.js";
|
|
25
25
|
import { createToolHtmlRenderer } from "./export-html/tool-renderer.js";
|
|
26
26
|
import { ExtensionRunner, wrapRegisteredTools, } from "./extensions/index.js";
|
|
27
|
-
import { isForbiddenCommand } from "./forbidden-commands.js";
|
|
27
|
+
import { checkScriptContent, extractScriptPaths, isForbiddenCommand } from "./forbidden-commands.js";
|
|
28
28
|
import { expandPromptTemplate } from "./prompt-templates.js";
|
|
29
29
|
import { CURRENT_SESSION_VERSION, getLatestCompactionEntry } from "./session-manager.js";
|
|
30
30
|
import { createSyntheticSourceInfo } from "./source-info.js";
|
|
@@ -171,6 +171,31 @@ export class AgentSession {
|
|
|
171
171
|
reason: `Command blocked by forbidden-commands guard: "${pattern}" matched "${command}"`,
|
|
172
172
|
};
|
|
173
173
|
}
|
|
174
|
+
// Check script files referenced by the command (e.g., bash script.sh)
|
|
175
|
+
const scriptPaths = extractScriptPaths(command);
|
|
176
|
+
if (scriptPaths.length > 0) {
|
|
177
|
+
const { readFileSync, existsSync } = await import("node:fs");
|
|
178
|
+
const { resolve } = await import("node:path");
|
|
179
|
+
const cwd = this._cwd;
|
|
180
|
+
for (const scriptPath of scriptPaths) {
|
|
181
|
+
const resolved = resolve(cwd, scriptPath);
|
|
182
|
+
if (existsSync(resolved)) {
|
|
183
|
+
try {
|
|
184
|
+
const content = readFileSync(resolved, "utf-8");
|
|
185
|
+
const match = checkScriptContent(content, customPatterns);
|
|
186
|
+
if (match) {
|
|
187
|
+
return {
|
|
188
|
+
block: true,
|
|
189
|
+
reason: `Command blocked by forbidden-commands guard: script "${scriptPath}" contains forbidden command at line ${match.line}: "${match.text}" (matched pattern "${match.pattern}")`,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
// File not readable — skip (could be binary, permission denied, etc.)
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
174
199
|
}
|
|
175
200
|
}
|
|
176
201
|
const runner = this._extensionRunner;
|