@tritard/waterbrother 0.16.0 → 0.16.2
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/package.json +1 -1
- package/src/security.js +9 -2
- package/src/tools.js +7 -0
package/package.json
CHANGED
package/src/security.js
CHANGED
|
@@ -60,9 +60,16 @@ function checkFilePath(filePath, cwd) {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
// Home directory protection
|
|
63
|
+
// Home directory protection — only block writes to home dir root itself
|
|
64
|
+
// Allow writes to subdirectories (Desktop/my-project, Documents/app, etc.)
|
|
64
65
|
if (HOME_DIR && cwdNorm === HOME_DIR) {
|
|
65
|
-
|
|
66
|
+
const targetNorm = normalized.startsWith("/") || /^[a-zA-Z]:/.test(normalized)
|
|
67
|
+
? normalized
|
|
68
|
+
: `${cwdNorm}/${normalized}`;
|
|
69
|
+
const isInSubdir = targetNorm.startsWith(HOME_DIR + "/") && targetNorm.split("/").length > HOME_DIR.split("/").length + 1;
|
|
70
|
+
if (!isInSubdir) {
|
|
71
|
+
reasons.push({ rule: "home-dir-write", message: "Writing files in home directory — use a project directory instead" });
|
|
72
|
+
}
|
|
66
73
|
}
|
|
67
74
|
|
|
68
75
|
// Self-modification
|
package/src/tools.js
CHANGED
|
@@ -1340,6 +1340,13 @@ ${clipped}`;
|
|
|
1340
1340
|
const { classifyToolCall } = await import("./security.js");
|
|
1341
1341
|
const classification = classifyToolCall(toolName, args, { cwd });
|
|
1342
1342
|
if (!classification.allowed) {
|
|
1343
|
+
// Visible warning to user — don't fail silently
|
|
1344
|
+
const reason = classification.reasons[0];
|
|
1345
|
+
if (reason?.rule === "home-dir-write") {
|
|
1346
|
+
output.write(`\n⚠ Can't write files here — you're in your home directory.\n Create a project folder first: mkdir my-project && cd my-project\n\n`);
|
|
1347
|
+
} else {
|
|
1348
|
+
output.write(`\n⚠ Blocked: ${classification.message}\n\n`);
|
|
1349
|
+
}
|
|
1343
1350
|
return { approved: false, note: `Security: ${classification.message}`, policyBlocked: true };
|
|
1344
1351
|
}
|
|
1345
1352
|
} catch {}
|