Skip to content

Commit d6300bc

Browse files
committed
add support for the replicator library
1 parent babf657 commit d6300bc

File tree

5 files changed

+9
-1
lines changed

5 files changed

+9
-1
lines changed

javascript/change-notes/2021-06-24-json.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ lgtm,codescanning
55
[json5](https://npmjs.com/package/json5),
66
[prettyjson](https://npmjs.com/package/prettyjson),
77
[flatted](https://npmjs.com/package/flatted),
8-
[teleport-javascript](https://npmjs.com/package/teleport-javascript)
8+
[teleport-javascript](https://npmjs.com/package/teleport-javascript),
9+
[replicator](https://npmjs.com/package/replicator)

javascript/ql/src/semmle/javascript/JsonParsers.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ private class PlainJsonParserCall extends JsonParserCall {
2727
exists(DataFlow::SourceNode callee | this = callee.getACall() |
2828
callee = DataFlow::globalVarRef("JSON").getAPropertyRead("parse") or
2929
callee = DataFlow::moduleMember(["json3", "json5", "flatted", "teleport-javascript"], "parse") or
30+
callee = API::moduleImport("replicator").getInstance().getMember("decode").getAnImmediateUse() or
3031
callee = DataFlow::moduleImport("parse-json") or
3132
callee = DataFlow::moduleImport("json-parse-better-errors") or
3233
callee = DataFlow::moduleImport("json-safe-parse") or

javascript/ql/src/semmle/javascript/JsonStringifiers.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class JsonStringifyCall extends DataFlow::CallNode {
1313
callee = DataFlow::globalVarRef("JSON").getAPropertyRead("stringify") or
1414
callee =
1515
DataFlow::moduleMember(["json3", "json5", "flatted", "teleport-javascript"], "stringify") or
16+
callee = API::moduleImport("replicator").getInstance().getMember("encode").getAnImmediateUse() or
1617
callee =
1718
DataFlow::moduleImport([
1819
"json-stringify-safe", "json-stable-stringify", "stringify-object",

javascript/ql/test/library-tests/TaintTracking/BasicTaintTracking.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ typeInferenceMismatch
9494
| json-stringify.js:2:16:2:23 | source() | json-stringify.js:24:8:24:43 | json5.s ... ource)) |
9595
| json-stringify.js:2:16:2:23 | source() | json-stringify.js:27:8:27:47 | flatted ... ource)) |
9696
| json-stringify.js:2:16:2:23 | source() | json-stringify.js:30:8:30:49 | telepor ... ource)) |
97+
| json-stringify.js:2:16:2:23 | source() | json-stringify.js:34:8:34:51 | replica ... ource)) |
9798
| json-stringify.js:3:15:3:22 | source() | json-stringify.js:8:8:8:31 | jsonStr ... (taint) |
9899
| nested-props.js:4:13:4:20 | source() | nested-props.js:5:10:5:14 | obj.x |
99100
| nested-props.js:9:18:9:25 | source() | nested-props.js:10:10:10:16 | obj.x.y |

javascript/ql/test/library-tests/TaintTracking/json-stringify.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,8 @@ function foo() {
2828

2929
const teleport = require('teleport-javascript');
3030
sink(teleport.stringify(teleport.parse(source))); // NOT OK
31+
32+
const Replicator = require('replicator');
33+
const replicator = new Replicator();
34+
sink(replicator.encode(replicator.decode(source))); // NOT OK
3135
}

0 commit comments

Comments
 (0)