mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-17 21:10:48 +00:00
fix(plugins): align package path contract validation
This commit is contained in:
1 parent
2a8dba4818
commit
ce3bde5ee4
7 files changed
+52
-12
No files matched your search
@@ -46,9 +46,23 @@ async function createPlugin(root: string): Promise<string> {
|
||||
}
|
||||
|
||||
test("path validation rejects traversal, platform aliases, and duplicates", () => {
|
||||
for (const unsafe of ["../escape", "/absolute", "C:/drive", "a\\b", "a/../b", "CON", "a//b"]) {
|
||||
for (const unsafe of [
|
||||
"../escape",
|
||||
"/absolute",
|
||||
"C:/drive",
|
||||
"a\\b",
|
||||
"a/../b",
|
||||
"CON",
|
||||
"assets/PRN.txt",
|
||||
"file.",
|
||||
"folder/file ",
|
||||
"folder/file?.js",
|
||||
"a//b",
|
||||
"😀".repeat(129),
|
||||
]) {
|
||||
assert.throws(() => assertSafePackagePath(unsafe));
|
||||
}
|
||||
assert.equal(assertSafePackagePath("😀".repeat(128)), "😀".repeat(128));
|
||||
const registry = new PackagePathRegistry();
|
||||
registry.add("dist/Plugin.js");
|
||||
assert.throws(() => registry.add("dist/plugin.js"), /case-colliding/);
|
||||
|
||||
Reference in new issue
Block a user