@saptools/cf-inspector 0.9.1 → 0.9.3
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/cli.js +49 -18
- package/dist/cli.js.map +1 -1
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -158,6 +158,22 @@ init_types();
|
|
|
158
158
|
var REGEX_PREFIX = "regex:";
|
|
159
159
|
var REGEX_FLAGS_PATTERN = /^[dgimsuvy]*$/;
|
|
160
160
|
var TS_JS_EXT_PATTERN = /\.(?:ts|js|mts|mjs|cts|cjs)$/i;
|
|
161
|
+
var MAX_REMOTE_ROOT_PATTERN_LENGTH = 200;
|
|
162
|
+
var NESTED_QUANTIFIER_PATTERN = /\([^()]*[+*][^()]*\)[+*]/;
|
|
163
|
+
function assertSafeRemoteRootPattern(pattern) {
|
|
164
|
+
if (pattern.length > MAX_REMOTE_ROOT_PATTERN_LENGTH) {
|
|
165
|
+
throw new CfInspectorError(
|
|
166
|
+
"INVALID_REMOTE_ROOT",
|
|
167
|
+
`--remote-root regex pattern is too long (${pattern.length.toString()} chars, max ${MAX_REMOTE_ROOT_PATTERN_LENGTH.toString()}) \u2014 this bounds worst-case backtracking cost`
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
if (NESTED_QUANTIFIER_PATTERN.test(pattern)) {
|
|
171
|
+
throw new CfInspectorError(
|
|
172
|
+
"INVALID_REMOTE_ROOT",
|
|
173
|
+
`--remote-root regex pattern "${pattern}" contains a nested quantifier (e.g. "(x+)+"), which can cause catastrophic backtracking \u2014 simplify the pattern`
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
161
177
|
function parseBreakpointSpec(input) {
|
|
162
178
|
const idx = input.lastIndexOf(":");
|
|
163
179
|
if (idx <= 0 || idx === input.length - 1) {
|
|
@@ -198,6 +214,7 @@ function parseRemoteRoot(value) {
|
|
|
198
214
|
return { kind: "literal", value: stripTrailingSlash(trimmed) };
|
|
199
215
|
}
|
|
200
216
|
function toRegex(pattern, flags) {
|
|
217
|
+
assertSafeRemoteRootPattern(pattern);
|
|
201
218
|
return { kind: "regex", pattern, flags };
|
|
202
219
|
}
|
|
203
220
|
function parseSlashDelimited(value) {
|