Skip to content

Commit 62e9946

Browse files
authored
Merge pull request #150 from asger-semmle/ts-asi-bug
Approved by xiemaisi
2 parents 727ab94 + 6ceb103 commit 62e9946

File tree

5 files changed

+20
-2
lines changed

5 files changed

+20
-2
lines changed

change-notes/1.18/analysis-javascript.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,12 @@
107107
| Hard-coded credentials | More true-positive results | This rule now recognizes secret cryptographic keys. |
108108
| Incomplete string escaping or encoding | Better name, more true-positive results | This rule has been renamed to more clearly reflect its purpose. Also, it now recognizes incomplete URL encoding and decoding. |
109109
| Insecure randomness | More true-positive results | This rule now recognizes secret cryptographic keys. |
110+
| Misleading indentation after control statement | Fewer results | This rule temporarily ignores TypeScript files. |
110111
| Missing rate limiting | More true-positive results, fewer false-positive results | This rule now recognizes additional rate limiters and expensive route handlers. |
111112
| Missing X-Frame-Options HTTP header | Fewer false-positive results | This rule now treats header names case-insensitively. |
113+
| Omitted array element | Fewer results | This rule temporarily ignores TypeScript files. |
112114
| Reflected cross-site scripting | Fewer false-positive results | This rule now treats header names case-insensitively. |
115+
| Semicolon insertion | Fewer results | This rule temporarily ignores TypeScript files. |
113116
| Server-side URL redirect | More true-positive results | This rule now treats header names case-insensitively. |
114117
| Superfluous trailing arguments | Fewer false-positive results | This rule now ignores calls to some empty functions. |
115118
| Type confusion through parameter tampering | Fewer false-positive results | This rule no longer flags emptiness checks. |

javascript/ql/src/LanguageFeatures/EmptyArrayInit.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ class OmittedArrayElement extends ArrayExpr {
4545
}
4646

4747
from OmittedArrayElement ae
48+
where not ae.getFile().getFileType().isTypeScript() // ignore quirks in TypeScript tokenizer
4849
select ae, "Avoid omitted array elements."

javascript/ql/src/LanguageFeatures/SemicolonInsertion.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ where s.hasSemicolonInserted() and
3636
asi = strictcount(Stmt ss | asi(sc, ss, true)) and
3737
nstmt = strictcount(Stmt ss | asi(sc, ss, _)) and
3838
perc = ((1-asi/nstmt)*100).floor() and
39-
perc >= 90
39+
perc >= 90 and
40+
not s.getFile().getFileType().isTypeScript() // ignore some quirks in the TypeScript tokenizer
4041
select (LastLineOf)s, "Avoid automated semicolon insertion " +
4142
"(" + perc + "% of all statements in $@ have an explicit semicolon).",
4243
sc, "the enclosing " + sctype

javascript/ql/src/Statements/MisleadingIndentationAfterControlStmt.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ where misleadingIndentationCandidate(ctrl, s1, s2) and
3939
f.hasIndentation(ctrlStartLine, indent, _) and
4040
f.hasIndentation(startLine1, indent, _) and
4141
f.hasIndentation(startLine2, indent, _) and
42-
not s2 instanceof EmptyStmt
42+
not s2 instanceof EmptyStmt and
43+
not f.getFileType().isTypeScript() // ignore quirks in TypeScript tokenizer
4344
select (FirstLineOf)s2, "The indentation of this statement suggests that it is controlled by $@, while in fact it is not.",
4445
(FirstLineOf)ctrl, "this statement"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function foo(arg) {
2+
console.log(arg);
3+
console.log(arg);
4+
console.log(arg);
5+
console.log(arg);
6+
console.log(arg);
7+
console.log(arg);
8+
console.log(arg);
9+
console.log(arg);
10+
console.log(arg);
11+
console.log(`Unknown option '${arg}'.`);
12+
}

0 commit comments

Comments
 (0)