Files
reverse-engineering-anything/scripts/verify/limit-class-guard.mjs
T
morluto 6eb0e3dac6 refactor(native): report bounded string reads that stop at their allowance as decode limits (#11174)
* refactor(native): report bounded string reads that stop at their allowance as decode limits

* fix(verify): count generic and multi-line plain-Error limit classes
2026-11-15 22:02:20 +08:00

11 lines
525 B
JavaScript

// Counts local limit classes declared on plain Error: a class whose name has
// Limit, Budget, Exhausted or Exceeded and that extends Error directly. Type
// parameters and line breaks between tokens are allowed, as a formatter or a
// generic declaration may write them.
const localLimitClass =
/\bclass\s+\w*(?:Limit|Budget|Exhausted|Exceeded)\w*\s*(?:<[^{]*?>)?\s*extends\s+Error\b/gu;
/** @param {string} content */
export const localLimitErrorClassCount = (content) =>
content.match(localLimitClass)?.length ?? 0;