Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function isProbablySafe(pRegExAST, pOptions) {
const lRepLimit = pOptions.limit || DEFAULT_REPETITION_LIMIT;
let currentStarHeight = 0;
let maxObservedStarHeight = 0;
let repetitionCount = 0;
regexpTree.traverse(pRegExAST, {
Repetition: {
pre() {
repetitionCount += 1;
currentStarHeight += 1;
if (maxObservedStarHeight < currentStarHeight) {
maxObservedStarHeight = currentStarHeight;
}
},
post() {
currentStarHeight -= 1;
}
}
});