mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 07:31:24 +00:00
test(skills): split installer security coverage
This commit is contained in:
16
src/infra/path-safety.test.ts
Normal file
16
src/infra/path-safety.test.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { isWithinDir, resolveSafeBaseDir } from "./path-safety.js";
|
||||
|
||||
describe("path-safety", () => {
|
||||
it("resolves safe base dir with trailing separator", () => {
|
||||
const base = resolveSafeBaseDir("/tmp/demo");
|
||||
expect(base.endsWith(path.sep)).toBe(true);
|
||||
});
|
||||
|
||||
it("checks directory containment", () => {
|
||||
expect(isWithinDir("/tmp/demo", "/tmp/demo")).toBe(true);
|
||||
expect(isWithinDir("/tmp/demo", "/tmp/demo/sub/file.txt")).toBe(true);
|
||||
expect(isWithinDir("/tmp/demo", "/tmp/demo/../escape.txt")).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user