@bitbonsai/mcpvault 0.11.3 → 0.11.4
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/dist/src/pathfilter.d.ts
CHANGED
|
@@ -4,6 +4,14 @@ export declare class PathFilter {
|
|
|
4
4
|
private allowedExtensions;
|
|
5
5
|
constructor(config?: Partial<PathFilterConfig>);
|
|
6
6
|
private simpleGlobMatch;
|
|
7
|
+
/**
|
|
8
|
+
* Canonicalize a path for restricted-directory matching. On Windows the
|
|
9
|
+
* filesystem strips trailing dots and spaces from each path segment, so
|
|
10
|
+
* ".git." and ".git " both resolve to ".git". Fold those away (and collapse
|
|
11
|
+
* "./" / duplicate separators) before matching the deny-list, otherwise the
|
|
12
|
+
* restriction can be bypassed with an equivalent name.
|
|
13
|
+
*/
|
|
14
|
+
private canonicalizeForMatch;
|
|
7
15
|
isAllowed(path: string): boolean;
|
|
8
16
|
isAllowedForListing(path: string): boolean;
|
|
9
17
|
private isIgnoredPath;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathfilter.d.ts","sourceRoot":"","sources":["../../src/pathfilter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,qBAAa,UAAU;IACrB,OAAO,CAAC,eAAe,CAAW;IAClC,OAAO,CAAC,iBAAiB,CAAW;gBAExB,MAAM,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC;IAuB9C,OAAO,CAAC,eAAe;
|
|
1
|
+
{"version":3,"file":"pathfilter.d.ts","sourceRoot":"","sources":["../../src/pathfilter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,qBAAa,UAAU;IACrB,OAAO,CAAC,eAAe,CAAW;IAClC,OAAO,CAAC,iBAAiB,CAAW;gBAExB,MAAM,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC;IAuB9C,OAAO,CAAC,eAAe;IAoBvB;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB;IAQ5B,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAyBhC,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAY1C,OAAO,CAAC,aAAa;IAmBrB,OAAO,CAAC,MAAM;IA0Bd,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;CAGvC"}
|
package/dist/src/pathfilter.js
CHANGED
|
@@ -33,9 +33,25 @@ export class PathFilter {
|
|
|
33
33
|
.replace(/\\\?/g, '[^/]'); // ? matches single character except / (unescape)
|
|
34
34
|
// Ensure we match the full path
|
|
35
35
|
regexPattern = '^' + regexPattern + '$';
|
|
36
|
-
|
|
36
|
+
// Case-insensitive: on case-insensitive filesystems (macOS, Windows) the OS
|
|
37
|
+
// resolves ".Git" to ".git", so the deny-list must match regardless of case.
|
|
38
|
+
const regex = new RegExp(regexPattern, 'i');
|
|
37
39
|
return regex.test(path);
|
|
38
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Canonicalize a path for restricted-directory matching. On Windows the
|
|
43
|
+
* filesystem strips trailing dots and spaces from each path segment, so
|
|
44
|
+
* ".git." and ".git " both resolve to ".git". Fold those away (and collapse
|
|
45
|
+
* "./" / duplicate separators) before matching the deny-list, otherwise the
|
|
46
|
+
* restriction can be bypassed with an equivalent name.
|
|
47
|
+
*/
|
|
48
|
+
canonicalizeForMatch(normalizedPath) {
|
|
49
|
+
return normalizedPath
|
|
50
|
+
.split('/')
|
|
51
|
+
.filter(seg => seg !== '' && seg !== '.')
|
|
52
|
+
.map(seg => seg.replace(/[. ]+$/, ''))
|
|
53
|
+
.join('/');
|
|
54
|
+
}
|
|
39
55
|
isAllowed(path) {
|
|
40
56
|
if (typeof path !== "string") {
|
|
41
57
|
throw new Error("path is required and must be a string");
|
|
@@ -64,9 +80,14 @@ export class PathFilter {
|
|
|
64
80
|
return !this.isIgnoredPath(normalizedPath);
|
|
65
81
|
}
|
|
66
82
|
isIgnoredPath(normalizedPath) {
|
|
83
|
+
// Match against the canonical form so case- and trailing dot/space-variants
|
|
84
|
+
// (".Git/config", ".git./config", ".git /config") cannot bypass the deny-list
|
|
85
|
+
// on case-insensitive / Windows filesystems.
|
|
86
|
+
const canonicalPath = this.canonicalizeForMatch(normalizedPath);
|
|
67
87
|
// Check if path matches any ignored pattern
|
|
68
88
|
for (const pattern of this.ignoredPatterns) {
|
|
69
|
-
if (this.simpleGlobMatch(pattern, normalizedPath)
|
|
89
|
+
if (this.simpleGlobMatch(pattern, normalizedPath) ||
|
|
90
|
+
this.simpleGlobMatch(pattern, canonicalPath)) {
|
|
70
91
|
return true;
|
|
71
92
|
}
|
|
72
93
|
}
|
package/package.json
CHANGED