@tritard/waterbrother 0.16.1 → 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/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
|