Skip to content

Commit 8ce9c9d

Browse files
authored
Merge pull request github#3441 from erik-krogh/BabelDirectives
Approved by esbena
2 parents 73882c9 + 970ddca commit 8ce9c9d

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

change-notes/1.25/analysis-javascript.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
| Uncontrolled data used in path expression (`js/path-injection`) | More results | This query now recognizes additional file system calls. |
2222
| Uncontrolled command line (`js/command-line-injection`) | More results | This query now recognizes additional command execution calls. |
2323
| Expression has no effect (`js/useless-expression`) | Less results | This query no longer flags an expression when that expression is the only content of the containing file. |
24+
| Unknown directive (`js/unknown-directive`) | Less results | This query no longer flags directives generated by the Babel compiler. |
2425

2526
## Changes to libraries
2627

javascript/ql/src/Expressions/UnknownDirective.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ where
1616
// ignore ":" pseudo-directive sometimes seen in dual-use shell/node.js scripts
1717
not d.getExpr().getStringValue() = ":" and
1818
// but exclude attribute top-levels: `<a href="javascript:'some-attribute-string'">`
19-
not d.getParent() instanceof CodeInAttribute
19+
not d.getParent() instanceof CodeInAttribute and
20+
// exclude babel generated directives like "@babel/helpers - typeof".
21+
not d.getDirectiveText().prefix(14) = "@babel/helpers"
2022
select d, "Unknown directive: '" + truncate(d.getDirectiveText(), 20, " ... (truncated)") + "'."

javascript/ql/test/query-tests/Expressions/UnknownDirective/UnknownDirective.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,7 @@ function yui() {
4545
":nomunge"; // NOT OK
4646
"foo(), bar, baz:nomunge"; // NOT OK
4747
}
48+
49+
function babel_typeof(obj) {
50+
"@babel/helpers - typeof"
51+
}

0 commit comments

Comments
 (0)