Skip to content

Commit f22b953

Browse files
committed
JS: Add missing content flow.
1 parent 408d9e6 commit f22b953

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

‎javascript/ql/lib/semmle/javascript/frameworks/NodeJSLib.qll‎

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,11 @@ module NodeJSLib {
10831083
)
10841084
or
10851085
node instanceof ReadableFromCall and
1086-
tag = "nodejs.readable.from.chunk"
1086+
tag =
1087+
[
1088+
"nodejs.readable.from.chunk", "nodejs.readable.from.map-key",
1089+
"nodejs.readable.from.map-value"
1090+
]
10871091
) and
10881092
container.asSourceCallable() = node.getContainer()
10891093
}
@@ -1120,15 +1124,20 @@ module NodeJSLib {
11201124
DataFlow::Node pred, DataFlow::ContentSet contents, DataFlow::Node succ
11211125
) {
11221126
// `pred` is an iterable input to `Readable.from`
1123-
exists(ReadableFromCall call |
1124-
pred = call.getArgument(0).flow() and
1127+
exists(ReadableFromCall call | pred = call.getArgument(0).flow() |
11251128
contents =
11261129
[
11271130
DataFlow::ContentSet::arrayElement(), DataFlow::ContentSet::setElement(),
11281131
DataFlow::ContentSet::iteratorElement()
11291132
] and
11301133
// `succ` is the synthesized chunk emitted by `Readable.from`
11311134
succ = getSynthesizedNode(call, "nodejs.readable.from.chunk")
1135+
or
1136+
contents = DataFlow::ContentSet::mapKey() and
1137+
succ = getSynthesizedNode(call, "nodejs.readable.from.map-key")
1138+
or
1139+
contents = DataFlow::ContentSet::mapValueAll() and
1140+
succ = getSynthesizedNode(call, "nodejs.readable.from.map-value")
11321141
)
11331142
or
11341143
// `pred` is the readable receiver of a `pipe` call
@@ -1150,6 +1159,18 @@ module NodeJSLib {
11501159
succ = call.flow()
11511160
)
11521161
or
1162+
exists(ReadableFromCall call |
1163+
// `pred` is a synthesized Map key
1164+
pred = getSynthesizedNode(call, "nodejs.readable.from.map-key") and
1165+
contents.asSingleton().asArrayIndex() = 0
1166+
or
1167+
// `pred` is a synthesized Map value
1168+
pred = getSynthesizedNode(call, "nodejs.readable.from.map-value") and
1169+
contents.asSingleton().asArrayIndex() = 1
1170+
|
1171+
succ = getSynthesizedNode(call, "nodejs.readable.from.chunk")
1172+
)
1173+
or
11531174
// `pred` is the output argument to a transform completion callback
11541175
exists(PipeHookCall hook, DataFlow::CallNode callback |
11551176
callback = pipeTransformCallback(hook, DataFlow::TypeTracker::end()).getACall() and

0 commit comments

Comments
 (0)