Skip to content

Commit 61880ba

Browse files
authored
Merge pull request github#5530 from erik-krogh/moreFS
Approved by esbena
2 parents e22ec50 + 2c1cc9e commit 61880ba

File tree

4 files changed

+295
-0
lines changed

4 files changed

+295
-0
lines changed

javascript/ql/src/semmle/javascript/frameworks/NodeJSLib.qll

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,28 @@ module NodeJSLib {
478478
DataFlow::moduleImport("util-promisifyall")
479479
].getACall()
480480
)
481+
or
482+
// const fs = require('fs');
483+
// let fs_copy = methods.reduce((obj, method) => {
484+
// obj[method] = fs[method];
485+
// return obj;
486+
// }, {});
487+
t.continue() = t2 and
488+
exists(
489+
DataFlow::MethodCallNode call, DataFlow::ParameterNode obj, DataFlow::SourceNode method
490+
|
491+
call.getMethodName() = "reduce" and
492+
result = call and
493+
obj = call.getABoundCallbackParameter(0, 0) and
494+
obj.flowsTo(any(DataFlow::FunctionNode f).getAReturn()) and
495+
exists(DataFlow::PropWrite write, DataFlow::PropRead read |
496+
write = obj.getAPropertyWrite() and
497+
method.flowsToExpr(write.getPropertyNameExpr()) and
498+
method.flowsToExpr(read.getPropertyNameExpr()) and
499+
read.getBase().getALocalSource() = fsModule(t2) and
500+
write.getRhs() = maybePromisified(read)
501+
)
502+
)
481503
)
482504
}
483505
}

0 commit comments

Comments
 (0)