fix(security): restrict default safe-bin trusted dirs

This commit is contained in:
Peter Steinberger
2026-02-24 23:12:52 +00:00
parent 2d159e5e87
commit b67e600bff
6 changed files with 32 additions and 10 deletions

View File

@@ -8,6 +8,15 @@ import {
} from "./exec-safe-bin-trust.js";
describe("exec safe bin trust", () => {
it("keeps default trusted dirs limited to immutable system paths", () => {
const dirs = getTrustedSafeBinDirs({ refresh: true });
expect(dirs.has(path.resolve("/bin"))).toBe(true);
expect(dirs.has(path.resolve("/usr/bin"))).toBe(true);
expect(dirs.has(path.resolve("/usr/local/bin"))).toBe(false);
expect(dirs.has(path.resolve("/opt/homebrew/bin"))).toBe(false);
});
it("builds trusted dirs from defaults and explicit extra dirs", () => {
const dirs = buildTrustedSafeBinDirs({
baseDirs: ["/usr/bin"],