You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Doc says nothing about the acceptable format of the section strings. However, the check in the code has some silent restrictions/prerequisites:
User input is not escaped, so if it contains unintentional RegExp special characters, things become unpredictable.
Doc states the delimiters to be commas, but the code checks borders via \b symbol (word boundary) and this can make a mess: a section with non-[a-z0-9_] symbols at the beginning or the end becomes always unmatched, while a multiword section may trigger some unintended matchings.
This is prone to false positive/false negative effects and crashes. For example:
constutil=require('util');constdebuglogMustCall_1=util.debuglog('###');constdebuglogMustCall_2=util.debuglog('f$oo');constdebuglogMustNotCall_1=util.debuglog('f.oo');constdebuglogMustNotCall_2=util.debuglog('bar');debuglogMustCall_1('this should be logged');debuglogMustCall_2('this should be logged too');debuglogMustNotCall_1('this should not be logged');debuglogMustNotCall_2('this should not be logged too');
> SET NODE_DEBUG=###,f$oo,no-bar-at-all
> node test.jsF.OO 5604: this should not be loggedBAR 5604: this should not be logged too
> SET NODE_DEBUG=hi:)
> node test.jsutil.js:147 if (new RegExp(`\\b${set}\\b`, 'i').test(debugEnviron)) { ^SyntaxError: Invalid regular expression: /\bHI:)\b/: Unmatched ')'
What possibly could be done:
Document this weird situation (like 'only one word [a-z0-9_] strings are allowed' or something).
Or change the code: split the NODE_DEBUG value by commas and check via sections.map(toUpperCase).includes(set.toUpperCase()). This may be semver-major unfortunately.
The text was updated successfully, but these errors were encountered:
Doc says nothing about the acceptable format of the
section
strings. However, the check in the code has some silent restrictions/prerequisites:RegExp
special characters, things become unpredictable.\b
symbol (word boundary) and this can make a mess: asection
with non-[a-z0-9_]
symbols at the beginning or the end becomes always unmatched, while a multiword section may trigger some unintended matchings.This is prone to false positive/false negative effects and crashes. For example:
What possibly could be done:
[a-z0-9_]
strings are allowed' or something).NODE_DEBUG
value by commas and check viasections.map(toUpperCase).includes(set.toUpperCase())
. This may be semver-major unfortunately.The text was updated successfully, but these errors were encountered: