|
7 | 7 |
|
8 | 8 | module.exports = obfuscate
|
9 | 9 |
|
10 |
| -// eslint-disable-next-line sonarjs/slow-regex |
| 10 | +// All eslint rules in this file that have a comment description of |
| 11 | +// "¶¶¶" have been determined safe enough for our use cases. These lint rules |
| 12 | +// are complaining about catastrophic backtracking being possible. While this |
| 13 | +// may be true, our only other alternative is to write a character by character |
| 14 | +// analyzer, like the .NET Agent uses, in order to obfuscate SQL statements. |
| 15 | +// We have opted against that for the follow reasons: |
| 16 | +// |
| 17 | +// 1. We have not encountered a case where these expressions have led to |
| 18 | +// the possible backtracking failure. |
| 19 | +// 2. Any character-by-character parser is very likely going to be much slower. |
| 20 | +// 3. If we did use a character-by-character parser, we would need to be sure |
| 21 | +// to handle multibyte characters, e.g. |
| 22 | +// `insert into foo (col1) values('sensitive 🍍')` |
| 23 | +// That statement has ASCII that would be well-supported in a naive |
| 24 | +// implementation, along with a UTF-8 character that could be mishandled if |
| 25 | +// not accounted for. |
| 26 | + |
| 27 | +// eslint-disable-next-line sonarjs/slow-regex -- ¶¶¶ |
11 | 28 | const singleQuote = /'(?:''|[^'])*?(?:\\'.*|'(?!'))/
|
12 |
| -// eslint-disable-next-line sonarjs/slow-regex |
| 29 | +// eslint-disable-next-line sonarjs/slow-regex -- ¶¶¶ |
13 | 30 | const doubleQuote = /"(?:[^"]|"")*?(?:\\".*|"(?!"))/
|
14 | 31 | const dollarQuote = /(\$(?!\d)[^$]*?\$).*?(?:\1|$)/
|
15 | 32 | const oracleQuote = /q'\[.*?(?:\]'|$)|q'\{.*?(?:\}'|$)|q'<.*?(?:>'|$)|q'\(.*?(?:\)'|$)/
|
16 |
| -// eslint-disable-next-line sonarjs/slow-regex |
| 33 | +// eslint-disable-next-line sonarjs/slow-regex -- ¶¶¶ |
17 | 34 | const comment = /(?:#|--).*?(?=\r|\n|$)/
|
18 | 35 | const multilineComment = /\/\*(?:[^/]|\/[^*])*?(?:\*\/|\/\*.*)/
|
19 | 36 | const uuid = /\{?(?:[0-9a-f]-*){32}\}?/
|
|
0 commit comments