Skip to content

Commit 1533111

Browse files
authored
chore: Added regex note to sql obfuscator (#2911)
1 parent 0d9f3da commit 1533111

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

lib/util/sql/obfuscate.js

+20-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,30 @@
77

88
module.exports = obfuscate
99

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 -- ¶¶¶
1128
const singleQuote = /'(?:''|[^'])*?(?:\\'.*|'(?!'))/
12-
// eslint-disable-next-line sonarjs/slow-regex
29+
// eslint-disable-next-line sonarjs/slow-regex -- ¶¶¶
1330
const doubleQuote = /"(?:[^"]|"")*?(?:\\".*|"(?!"))/
1431
const dollarQuote = /(\$(?!\d)[^$]*?\$).*?(?:\1|$)/
1532
const oracleQuote = /q'\[.*?(?:\]'|$)|q'\{.*?(?:\}'|$)|q'<.*?(?:>'|$)|q'\(.*?(?:\)'|$)/
16-
// eslint-disable-next-line sonarjs/slow-regex
33+
// eslint-disable-next-line sonarjs/slow-regex -- ¶¶¶
1734
const comment = /(?:#|--).*?(?=\r|\n|$)/
1835
const multilineComment = /\/\*(?:[^/]|\/[^*])*?(?:\*\/|\/\*.*)/
1936
const uuid = /\{?(?:[0-9a-f]-*){32}\}?/

0 commit comments

Comments
 (0)