Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1f3c496

Browse files
committed
JS: Accept some less obvious alerts
These are listed in a function called 'good' but it's difficult to say in isolation whether they should be flagged or not. Accepting the changes as they seem reasonable.
1 parent f395651 commit 1f3c496

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

  • javascript/ql/test/query-tests/Security/CWE-116/IncompleteSanitization

javascript/ql/test/query-tests/Security/CWE-116/IncompleteSanitization/tst.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,18 @@ function good11(s) {
126126
return s.replace("%d", "42");
127127
}
128128

129-
function good12(s) {
129+
function goodOrBad12(s) {
130130
s.replace('[', '').replace(']', '');
131131
s.replace('(', '').replace(')', '');
132132
s.replace('{', '').replace('}', '');
133-
s.replace('<', '').replace('>', ''); // too common as a bad HTML sanitizer
133+
s.replace('<', '').replace('>', ''); // $ Alert[js/incomplete-sanitization]
134134

135-
s.replace('[', '\\[').replace(']', '\\]');
136-
s.replace('{', '\\{').replace('}', '\\}');
135+
s.replace('[', '\\[').replace(']', '\\]'); // $ Alert[js/incomplete-sanitization]
136+
s.replace('{', '\\{').replace('}', '\\}'); // $ Alert[js/incomplete-sanitization]
137137

138138
s = s.replace('[', '');
139139
s = s.replace(']', '');
140-
s.replace(/{/, '').replace(/}/, ''); // should have used a string literal if a single replacement was intended
140+
s.replace(/{/, '').replace(/}/, ''); // $ Alert[js/incomplete-sanitization] - should have used a string literal if a single replacement was intended
141141
s.replace(']', '').replace('[', ''); // $ Alert[js/incomplete-sanitization] - probably OK, but still flagged
142142
}
143143

0 commit comments

Comments
 (0)