Skip to content

Commit 35999a7

Browse files
committed
add support for fs-extra methods in insecure-temporary-file
1 parent 573f17d commit 35999a7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

javascript/ql/lib/semmle/javascript/security/dataflow/InsecureTemporaryFileCustomizations.qll

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ module InsecureTemporaryFile {
3030
string methodName;
3131

3232
OpenFileCall() {
33-
methodName = ["open", "openSync", "writeFile", "writeFileSync"] and
33+
methodName =
34+
[
35+
"open", "openSync", "writeFile", "writeFileSync", "writeJson", "writeJSON",
36+
"writeJsonSync", "writeJSONSync", "outputJson", "outputJSON", "outputJsonSync",
37+
"outputJSONSync", "outputFile", "outputFileSync"
38+
] and
3439
this = NodeJSLib::FS::moduleMember(methodName).getACall()
3540
}
3641

@@ -40,7 +45,7 @@ module InsecureTemporaryFile {
4045
methodName = ["open", "openSync"] and
4146
result = this.getArgument(2)
4247
or
43-
methodName = ["writeFile", "writeFileSync"] and
48+
not methodName = ["open", "openSync"] and
4449
result = this.getOptionArgument(2, "mode")
4550
}
4651
}
@@ -88,7 +93,8 @@ module InsecureTemporaryFile {
8893
not this = root.getFirstLeaf()
8994
)
9095
or
91-
exists(DataFlow::CallNode join | join = DataFlow::moduleMember("path", "join").getACall() |
96+
exists(DataFlow::CallNode join |
97+
join = DataFlow::moduleMember("path", "join").getACall() and
9298
this = join.getArgument([1 .. join.getNumArgument() - 1])
9399
)
94100
}

0 commit comments

Comments
 (0)