great-cto 2.5.0 → 2.5.1
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/agentshield/scanner.js +38 -13
- package/package.json +1 -1
|
@@ -54,21 +54,46 @@ function* walk(root, exclude) {
|
|
|
54
54
|
function fileMatchesGlobs(file, globs) {
|
|
55
55
|
if (!globs || globs.length === 0)
|
|
56
56
|
return true;
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
// 2. Escape remaining regex metachars.
|
|
60
|
-
// 3. Replace placeholders with their regex equivalents.
|
|
57
|
+
// Normalize path separators for cross-platform matching
|
|
58
|
+
const normalized = file.replace(/\\/g, '/');
|
|
61
59
|
return globs.some((g) => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
60
|
+
// Token-based glob → regex conversion. Walks character-by-character to
|
|
61
|
+
// avoid the substitution-order pitfalls of multiple replace passes.
|
|
62
|
+
// Treats `**/` as "zero or more path segments" — so `**/*.ts` matches
|
|
63
|
+
// both `foo.ts` (root) and `src/lib/foo.ts` (nested).
|
|
64
|
+
let re = '';
|
|
65
|
+
for (let i = 0; i < g.length; i++) {
|
|
66
|
+
const c = g[i];
|
|
67
|
+
if (c === '*' && g[i + 1] === '*') {
|
|
68
|
+
// ** consumes the trailing /, so `**/x` becomes `(?:.*\/)?x` not `.*\/x`
|
|
69
|
+
if (g[i + 2] === '/') {
|
|
70
|
+
re += '(?:.*\\/)?';
|
|
71
|
+
i += 2;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
re += '.*';
|
|
75
|
+
i++;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else if (c === '*') {
|
|
79
|
+
re += '[^/]*';
|
|
80
|
+
}
|
|
81
|
+
else if (c === '?') {
|
|
82
|
+
re += '.';
|
|
83
|
+
}
|
|
84
|
+
else if ('.+^${}()|[]\\'.includes(c)) {
|
|
85
|
+
re += '\\' + c;
|
|
86
|
+
}
|
|
87
|
+
else if (c === '/') {
|
|
88
|
+
re += '/';
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
re += c;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
70
94
|
try {
|
|
71
|
-
|
|
95
|
+
// Match suffix — `src/foo.ts` matches `**/*.ts` regardless of cwd
|
|
96
|
+
return new RegExp('(?:^|/)' + re + '$').test(normalized);
|
|
72
97
|
}
|
|
73
98
|
catch {
|
|
74
99
|
return false;
|
package/package.json
CHANGED