-
Notifications
You must be signed in to change notification settings - Fork 1.9k
JS: Improve alert messages of js/incomplete-sanitization
#19953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5fad828
JS:Fix double curly brace issue in incomplete sanitization alerts
Napalys c7e5ede
JS: add change note
Napalys 953bd90
JS: display `this node` if the current node does not have string value.
Napalys cc1d2c4
JS: add extra test case with `}`
Napalys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
javascript/ql/src/change-notes/2025-07-02-incomplete-sanitization.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: fix | ||
| --- | ||
| * Fixed incorrect display of some special characters in `js/incomplete-sanitization` alert messages. |
75 changes: 38 additions & 37 deletions
75
.../test/query-tests/Security/CWE-116/IncompleteSanitization/IncompleteSanitization.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,38 @@ | ||
| | tst.js:5:10:5:18 | s.replace | This replaces only the first occurrence of "'". | | ||
| | tst.js:9:10:9:18 | s.replace | This replaces only the first occurrence of /'/. | | ||
| | tst.js:13:10:13:18 | s.replace | This does not escape backslash characters in the input. | | ||
| | tst.js:17:10:17:18 | s.replace | This does not escape backslash characters in the input. | | ||
| | tst.js:21:10:21:18 | s.replace | This does not escape backslash characters in the input. | | ||
| | tst.js:25:10:25:18 | s.replace | This does not escape backslash characters in the input. | | ||
| | tst.js:29:10:29:18 | s.replace | This does not escape backslash characters in the input. | | ||
| | tst.js:33:10:33:18 | s.replace | This replaces only the first occurrence of '\|'. | | ||
| | tst.js:37:10:37:18 | s.replace | This does not escape backslash characters in the input. | | ||
| | tst.js:41:10:41:18 | s.replace | This replaces only the first occurrence of "/". | | ||
| | tst.js:45:10:45:18 | s.replace | This replaces only the first occurrence of "%25". | | ||
| | tst.js:49:10:49:18 | s.replace | This replaces only the first occurrence of `'`. | | ||
| | tst.js:53:10:53:18 | s.replace | This replaces only the first occurrence of "'". | | ||
| | tst.js:57:10:57:18 | s.replace | This replaces only the first occurrence of `'`. | | ||
| | tst.js:61:10:61:18 | s.replace | This replaces only the first occurrence of "'" + "". | | ||
| | tst.js:65:10:65:18 | s.replace | This replaces only the first occurrence of "'". | | ||
| | tst.js:69:10:69:18 | s.replace | This replaces only the first occurrence of "'" + "". | | ||
| | tst.js:133:2:133:10 | s.replace | This replaces only the first occurrence of '<'. | | ||
| | tst.js:133:2:133:27 | s.repla ... replace | This replaces only the first occurrence of '>'. | | ||
| | tst.js:135:2:135:10 | s.replace | This replaces only the first occurrence of '['. | | ||
| | tst.js:135:2:135:30 | s.repla ... replace | This replaces only the first occurrence of ']'. | | ||
| | tst.js:136:2:136:10 | s.replace | This replaces only the first occurrence of '{'. | | ||
| | tst.js:136:2:136:30 | s.repla ... replace | This replaces only the first occurrence of '}'. | | ||
| | tst.js:140:2:140:10 | s.replace | This replaces only the first occurrence of /{/. | | ||
| | tst.js:140:2:140:27 | s.repla ... replace | This replaces only the first occurrence of /}/. | | ||
| | tst.js:141:2:141:10 | s.replace | This replaces only the first occurrence of ']'. | | ||
| | tst.js:141:2:141:27 | s.repla ... replace | This replaces only the first occurrence of '['. | | ||
| | tst.js:148:2:148:10 | x.replace | This replaces only the first occurrence of "\\n". | | ||
| | tst.js:149:2:149:24 | x.repla ... replace | This replaces only the first occurrence of "\\n". | | ||
| | tst.js:193:9:193:17 | s.replace | This replaces only the first occurrence of /'/. | | ||
| | tst.js:202:10:202:18 | p.replace | This replaces only the first occurrence of "/../". | | ||
| | tst.js:341:9:341:17 | p.replace | This replaces only the first occurrence of /\\.\\.//. | | ||
| | tst.js:345:9:345:17 | s.replace | This does not escape backslash characters in the input. | | ||
| | tst.js:349:9:349:17 | s.replace | This replaces only the first occurrence of /'/. | | ||
| | tst.js:353:9:353:17 | s.replace | This does not escape backslash characters in the input. | | ||
| | tst.js:362:2:362:10 | x.replace | This replaces only the first occurrence of /\n/. | | ||
| | tst.js:363:2:363:24 | x.repla ... replace | This replaces only the first occurrence of /\n/. | | ||
| | tst.js:5:10:5:18 | s.replace | This replaces only the first occurrence of $@. | tst.js:5:20:5:22 | "'" | "'" | | ||
| | tst.js:9:10:9:18 | s.replace | This replaces only the first occurrence of $@. | tst.js:9:20:9:22 | /'/ | this node | | ||
| | tst.js:13:10:13:18 | s.replace | This does not escape backslash characters in the input. | tst.js:13:20:13:23 | /'/g | | | ||
| | tst.js:17:10:17:18 | s.replace | This does not escape backslash characters in the input. | tst.js:17:20:17:23 | /'/g | | | ||
| | tst.js:21:10:21:18 | s.replace | This does not escape backslash characters in the input. | tst.js:21:20:21:26 | /['"]/g | | | ||
| | tst.js:25:10:25:18 | s.replace | This does not escape backslash characters in the input. | tst.js:25:20:25:28 | /(['"])/g | | | ||
| | tst.js:29:10:29:18 | s.replace | This does not escape backslash characters in the input. | tst.js:29:20:29:27 | /('\|")/g | | | ||
| | tst.js:33:10:33:18 | s.replace | This replaces only the first occurrence of $@. | tst.js:33:20:33:22 | '\|' | '\|' | | ||
| | tst.js:37:10:37:18 | s.replace | This does not escape backslash characters in the input. | tst.js:37:20:37:23 | /"/g | | | ||
| | tst.js:41:10:41:18 | s.replace | This replaces only the first occurrence of $@. | tst.js:41:20:41:22 | "/" | "/" | | ||
| | tst.js:45:10:45:18 | s.replace | This replaces only the first occurrence of $@. | tst.js:45:20:45:24 | "%25" | "%25" | | ||
| | tst.js:49:10:49:18 | s.replace | This replaces only the first occurrence of $@. | tst.js:49:20:49:22 | `'` | `'` | | ||
| | tst.js:53:10:53:18 | s.replace | This replaces only the first occurrence of $@. | tst.js:53:20:53:22 | "'" | "'" | | ||
| | tst.js:57:10:57:18 | s.replace | This replaces only the first occurrence of $@. | tst.js:57:20:57:22 | `'` | `'` | | ||
| | tst.js:61:10:61:18 | s.replace | This replaces only the first occurrence of $@. | tst.js:61:20:61:27 | "'" + "" | "'" + "" | | ||
| | tst.js:65:10:65:18 | s.replace | This replaces only the first occurrence of $@. | tst.js:65:20:65:22 | "'" | "'" | | ||
| | tst.js:69:10:69:18 | s.replace | This replaces only the first occurrence of $@. | tst.js:69:20:69:27 | "'" + "" | "'" + "" | | ||
| | tst.js:133:2:133:10 | s.replace | This replaces only the first occurrence of $@. | tst.js:133:12:133:14 | '<' | '<' | | ||
| | tst.js:133:2:133:27 | s.repla ... replace | This replaces only the first occurrence of $@. | tst.js:133:29:133:31 | '>' | '>' | | ||
| | tst.js:135:2:135:10 | s.replace | This replaces only the first occurrence of $@. | tst.js:135:12:135:14 | '[' | '[' | | ||
| | tst.js:135:2:135:30 | s.repla ... replace | This replaces only the first occurrence of $@. | tst.js:135:32:135:34 | ']' | ']' | | ||
| | tst.js:136:2:136:10 | s.replace | This replaces only the first occurrence of $@. | tst.js:136:12:136:14 | '{' | '{' | | ||
| | tst.js:136:2:136:30 | s.repla ... replace | This replaces only the first occurrence of $@. | tst.js:136:32:136:34 | '}' | '}' | | ||
| | tst.js:140:2:140:10 | s.replace | This replaces only the first occurrence of $@. | tst.js:140:12:140:14 | /{/ | this node | | ||
| | tst.js:140:2:140:27 | s.repla ... replace | This replaces only the first occurrence of $@. | tst.js:140:29:140:31 | /}/ | this node | | ||
| | tst.js:141:2:141:10 | s.replace | This replaces only the first occurrence of $@. | tst.js:141:12:141:14 | ']' | ']' | | ||
| | tst.js:141:2:141:27 | s.repla ... replace | This replaces only the first occurrence of $@. | tst.js:141:29:141:31 | '[' | '[' | | ||
| | tst.js:148:2:148:10 | x.replace | This replaces only the first occurrence of $@. | tst.js:148:12:148:15 | "\\n" | "\\n" | | ||
| | tst.js:149:2:149:24 | x.repla ... replace | This replaces only the first occurrence of $@. | tst.js:149:26:149:29 | "\\n" | "\\n" | | ||
| | tst.js:193:9:193:17 | s.replace | This replaces only the first occurrence of $@. | tst.js:192:17:192:19 | /'/ | this node | | ||
| | tst.js:202:10:202:18 | p.replace | This replaces only the first occurrence of $@. | tst.js:202:20:202:25 | "/../" | "/../" | | ||
| | tst.js:341:9:341:17 | p.replace | This replaces only the first occurrence of $@. | tst.js:341:19:341:39 | new Reg ... .\\\\./") | this node | | ||
| | tst.js:345:9:345:17 | s.replace | This does not escape backslash characters in the input. | tst.js:345:19:345:38 | new RegExp("\\'","g") | | | ||
| | tst.js:349:9:349:17 | s.replace | This replaces only the first occurrence of $@. | tst.js:349:19:349:34 | new RegExp("\\'") | this node | | ||
| | tst.js:353:9:353:17 | s.replace | This does not escape backslash characters in the input. | tst.js:353:19:353:50 | new Reg ... lags()) | | | ||
| | tst.js:362:2:362:10 | x.replace | This replaces only the first occurrence of $@. | tst.js:362:12:362:27 | new RegExp("\\n") | this node | | ||
| | tst.js:363:2:363:24 | x.repla ... replace | This replaces only the first occurrence of $@. | tst.js:363:26:363:41 | new RegExp("\\n") | this node | | ||
| | tst.js:367:2:367:24 | x.repla ... replace | This replaces only the first occurrence of $@. | tst.js:367:26:367:28 | '}' | '}' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Using 'toString' in query logic Warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node.toString()seems to give a bit more user friendly messages compared tonode.getStringValue()