Skip to content

Commit 8637eaf

Browse files
author
Max Schaefer
committed
JavaScript: Address review comments.
1 parent 5f16406 commit 8637eaf

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

change-notes/1.19/analysis-javascript.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## General improvements
44

5-
* Modelling of taint flow through array operations has been improved. This may give additional results for the security queries.
5+
* Modelling of taint flow through array and buffer operations has been improved. This may give additional results for the security queries.
66

77
* Support for AMD modules has been improved. This may give additional results for the security queries as well as any queries that use type inference on code bases that use such modules.
88

javascript/ql/src/semmle/javascript/security/dataflow/HardcodedDataInterpretedAsCode.qll

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,21 @@ module HardcodedDataInterpretedAsCode {
5151
}
5252

5353
override predicate isSanitizer(DataFlow::Node node) {
54-
super.isSanitizer(node) or
5554
node instanceof Sanitizer
5655
}
5756
}
5857

5958
/**
60-
* A constant string consisting of eight or more hexadecimal characters, viewed
61-
* as a source of hard-coded data that should not be interpreted as code.
59+
* A constant string consisting of eight or more hexadecimal characters (including at
60+
* least one digit), viewed as a source of hard-coded data that should not be
61+
* interpreted as code.
6262
*/
6363
private class DefaultSource extends Source, DataFlow::ValueNode {
6464
DefaultSource() {
65-
astNode.(Expr).getStringValue().regexpMatch("[0-9a-fA-F]{8,}")
65+
exists (string val | val = astNode.(Expr).getStringValue() |
66+
val.regexpMatch("[0-9a-fA-F]{8,}") and
67+
val.regexpMatch(".*[0-9].*")
68+
)
6669
}
6770
}
6871

javascript/ql/test/query-tests/Security/CWE-506/HardcodedDataInterpretedAsCode.expected

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,24 @@ nodes
33
| event-stream-orig.js:2:1115:2:1138 | "2e2f74 ... 617461" |
44
| event-stream.js:9:11:9:37 | e("2e2f ... 17461") |
55
| event-stream.js:9:13:9:36 | "2e2f74 ... 617461" |
6+
| tst.js:1:5:1:88 | totallyHarmlessString |
67
| tst.js:1:29:1:88 | '636f6e ... 6e2729' |
78
| tst.js:2:6:2:46 | Buffer. ... 'hex') |
89
| tst.js:2:6:2:57 | Buffer. ... tring() |
910
| tst.js:2:18:2:38 | totally ... sString |
11+
| tst.js:5:5:5:23 | test |
1012
| tst.js:5:12:5:23 | "0123456789" |
1113
| tst.js:7:8:7:11 | test |
1214
| tst.js:7:8:7:15 | test+"n" |
1315
edges
1416
| event-stream-orig.js:2:1115:2:1138 | "2e2f74 ... 617461" | event-stream-orig.js:2:1113:2:1139 | e("2e2f ... 17461") |
1517
| event-stream.js:9:13:9:36 | "2e2f74 ... 617461" | event-stream.js:9:11:9:37 | e("2e2f ... 17461") |
16-
| tst.js:1:29:1:88 | '636f6e ... 6e2729' | tst.js:2:18:2:38 | totally ... sString |
18+
| tst.js:1:5:1:88 | totallyHarmlessString | tst.js:2:18:2:38 | totally ... sString |
19+
| tst.js:1:29:1:88 | '636f6e ... 6e2729' | tst.js:1:5:1:88 | totallyHarmlessString |
1720
| tst.js:2:6:2:46 | Buffer. ... 'hex') | tst.js:2:6:2:57 | Buffer. ... tring() |
1821
| tst.js:2:18:2:38 | totally ... sString | tst.js:2:6:2:46 | Buffer. ... 'hex') |
19-
| tst.js:5:12:5:23 | "0123456789" | tst.js:7:8:7:11 | test |
22+
| tst.js:5:5:5:23 | test | tst.js:7:8:7:11 | test |
23+
| tst.js:5:12:5:23 | "0123456789" | tst.js:5:5:5:23 | test |
2024
| tst.js:7:8:7:11 | test | tst.js:7:8:7:15 | test+"n" |
2125
#select
2226
| event-stream-orig.js:2:1113:2:1139 | e("2e2f ... 17461") | event-stream-orig.js:2:1115:2:1138 | "2e2f74 ... 617461" | event-stream-orig.js:2:1113:2:1139 | e("2e2f ... 17461") | Hard-coded data from $@ is interpreted as an import path. | event-stream-orig.js:2:1115:2:1138 | "2e2f74 ... 617461" | here |

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ try {
88
console.log("Bigints supported.");
99
} catch(e) {
1010
console.log("Bigints not supported.");
11-
}
11+
}
12+
13+
require('babeface'); // OK

0 commit comments

Comments
 (0)