Skip to content

Commit d4fa1f7

Browse files
authored
Merge pull request #6295 from erik-krogh/sort-keys
Approved by asgerf
2 parents 5203375 + 28b98c1 commit d4fa1f7

File tree

5 files changed

+39
-1
lines changed

5 files changed

+39
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
lgtm,codescanning
2+
* The dataflow libraries now model dataflow in the `sort-keys` and `camelcase-keys` library.
3+
Affected packages are
4+
[sort-keys](https://npmjs.com/package/sort-keys),
5+
[camelcase-keys](https://npmjs.com/package/camelcase-keys)

javascript/ql/src/semmle/javascript/Extend.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ private import semmle.javascript.dataflow.internal.PreCallGraphStep
183183
private class CloneStep extends PreCallGraphStep {
184184
override predicate step(DataFlow::Node pred, DataFlow::Node succ) {
185185
exists(DataFlow::CallNode call |
186-
call = DataFlow::moduleImport(["clone", "fclone"]).getACall()
186+
// `camelcase-keys` isn't quite a cloning library. But it's pretty close.
187+
call = DataFlow::moduleImport(["clone", "fclone", "sort-keys", "camelcase-keys"]).getACall()
187188
or
188189
call = DataFlow::moduleMember("json-cycle", ["decycle", "retrocycle"]).getACall()
189190
|

javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/ReflectedXss.expected

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,14 @@ nodes
206206
| tst2.js:75:12:75:12 | p |
207207
| tst2.js:76:12:76:18 | other.p |
208208
| tst2.js:76:12:76:18 | other.p |
209+
| tst2.js:82:7:82:24 | p |
210+
| tst2.js:82:9:82:9 | p |
211+
| tst2.js:82:9:82:9 | p |
212+
| tst2.js:85:11:85:11 | p |
213+
| tst2.js:88:12:88:12 | p |
214+
| tst2.js:88:12:88:12 | p |
215+
| tst2.js:89:12:89:18 | other.p |
216+
| tst2.js:89:12:89:18 | other.p |
209217
| tst3.js:5:7:5:24 | p |
210218
| tst3.js:5:9:5:9 | p |
211219
| tst3.js:5:9:5:9 | p |
@@ -389,6 +397,13 @@ edges
389397
| tst2.js:69:9:69:9 | p | tst2.js:69:7:69:24 | p |
390398
| tst2.js:72:11:72:11 | p | tst2.js:76:12:76:18 | other.p |
391399
| tst2.js:72:11:72:11 | p | tst2.js:76:12:76:18 | other.p |
400+
| tst2.js:82:7:82:24 | p | tst2.js:85:11:85:11 | p |
401+
| tst2.js:82:7:82:24 | p | tst2.js:88:12:88:12 | p |
402+
| tst2.js:82:7:82:24 | p | tst2.js:88:12:88:12 | p |
403+
| tst2.js:82:9:82:9 | p | tst2.js:82:7:82:24 | p |
404+
| tst2.js:82:9:82:9 | p | tst2.js:82:7:82:24 | p |
405+
| tst2.js:85:11:85:11 | p | tst2.js:89:12:89:18 | other.p |
406+
| tst2.js:85:11:85:11 | p | tst2.js:89:12:89:18 | other.p |
392407
| tst3.js:5:7:5:24 | p | tst3.js:6:12:6:12 | p |
393408
| tst3.js:5:7:5:24 | p | tst3.js:6:12:6:12 | p |
394409
| tst3.js:5:9:5:9 | p | tst3.js:5:7:5:24 | p |
@@ -446,5 +461,7 @@ edges
446461
| tst2.js:64:12:64:18 | other.p | tst2.js:57:9:57:9 | p | tst2.js:64:12:64:18 | other.p | Cross-site scripting vulnerability due to $@. | tst2.js:57:9:57:9 | p | user-provided value |
447462
| tst2.js:75:12:75:12 | p | tst2.js:69:9:69:9 | p | tst2.js:75:12:75:12 | p | Cross-site scripting vulnerability due to $@. | tst2.js:69:9:69:9 | p | user-provided value |
448463
| tst2.js:76:12:76:18 | other.p | tst2.js:69:9:69:9 | p | tst2.js:76:12:76:18 | other.p | Cross-site scripting vulnerability due to $@. | tst2.js:69:9:69:9 | p | user-provided value |
464+
| tst2.js:88:12:88:12 | p | tst2.js:82:9:82:9 | p | tst2.js:88:12:88:12 | p | Cross-site scripting vulnerability due to $@. | tst2.js:82:9:82:9 | p | user-provided value |
465+
| tst2.js:89:12:89:18 | other.p | tst2.js:82:9:82:9 | p | tst2.js:89:12:89:18 | other.p | Cross-site scripting vulnerability due to $@. | tst2.js:82:9:82:9 | p | user-provided value |
449466
| tst3.js:6:12:6:12 | p | tst3.js:5:9:5:9 | p | tst3.js:6:12:6:12 | p | Cross-site scripting vulnerability due to $@. | tst3.js:5:9:5:9 | p | user-provided value |
450467
| tst3.js:12:12:12:15 | code | tst3.js:11:32:11:39 | reg.body | tst3.js:12:12:12:15 | code | Cross-site scripting vulnerability due to $@. | tst3.js:11:32:11:39 | reg.body | user-provided value |

javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/ReflectedXssWithCustomSanitizer.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,7 @@
4444
| tst2.js:64:12:64:18 | other.p | Cross-site scripting vulnerability due to $@. | tst2.js:57:9:57:9 | p | user-provided value |
4545
| tst2.js:75:12:75:12 | p | Cross-site scripting vulnerability due to $@. | tst2.js:69:9:69:9 | p | user-provided value |
4646
| tst2.js:76:12:76:18 | other.p | Cross-site scripting vulnerability due to $@. | tst2.js:69:9:69:9 | p | user-provided value |
47+
| tst2.js:88:12:88:12 | p | Cross-site scripting vulnerability due to $@. | tst2.js:82:9:82:9 | p | user-provided value |
48+
| tst2.js:89:12:89:18 | other.p | Cross-site scripting vulnerability due to $@. | tst2.js:82:9:82:9 | p | user-provided value |
4749
| tst3.js:6:12:6:12 | p | Cross-site scripting vulnerability due to $@. | tst3.js:5:9:5:9 | p | user-provided value |
4850
| tst3.js:12:12:12:15 | code | Cross-site scripting vulnerability due to $@. | tst3.js:11:32:11:39 | reg.body | user-provided value |

javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/tst2.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,19 @@ app.get('/baz', function(req, res) {
7272
obj.p = p;
7373
var other = jc.retrocycle(jc.decycle(obj));
7474

75+
res.send(p); // NOT OK
76+
res.send(other.p); // NOT OK
77+
});
78+
79+
const sortKeys = require('sort-keys');
80+
81+
app.get('/baz', function(req, res) {
82+
let { p } = req.params;
83+
84+
var obj = {};
85+
obj.p = p;
86+
var other = sortKeys(obj);
87+
7588
res.send(p); // NOT OK
7689
res.send(other.p); // NOT OK
7790
});

0 commit comments

Comments
 (0)