Skip to content

Commit 25d04f1

Browse files
committed
Added support for shelljs.which
1 parent f6fae7a commit 25d04f1

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

javascript/ql/lib/semmle/javascript/frameworks/ShellJS.qll

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ module ShellJS {
1414
shellJSMember()
1515
.getMember([
1616
"exec", "cd", "cp", "touch", "chmod", "pushd", "find", "ls", "ln", "mkdir", "mv",
17-
"rm", "cat", "head", "sort", "tail", "uniq", "grep", "sed", "to", "toEnd", "echo"
17+
"rm", "cat", "head", "sort", "tail", "uniq", "grep", "sed", "to", "toEnd", "echo",
18+
"which",
1819
])
1920
.getReturn()
2021
}
@@ -99,7 +100,8 @@ module ShellJS {
99100
*/
100101
private class ShellJSGenericFileAccess extends FileSystemAccess, ShellJSCall {
101102
ShellJSGenericFileAccess() {
102-
name = ["cd", "cp", "touch", "chmod", "pushd", "find", "ls", "ln", "mkdir", "mv", "rm"]
103+
name =
104+
["cd", "cp", "touch", "chmod", "pushd", "find", "ls", "ln", "mkdir", "mv", "rm", "which"]
103105
}
104106

105107
override DataFlow::Node getAPathArgument() { result = this.getAnArgument() }
@@ -111,7 +113,8 @@ module ShellJS {
111113
private class ShellJSFilenameSource extends FileNameSource, ShellJSCall {
112114
ShellJSFilenameSource() {
113115
name = "find" or
114-
name = "ls"
116+
name = "ls" or
117+
name = "which"
115118
}
116119
}
117120

javascript/ql/test/library-tests/frameworks/Shelljs/ShellJS.expected

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ test_FileSystemAccess
5555
| tst.js:60:1:60:17 | shelljs.cat(file) |
5656
| tst.js:60:1:60:41 | shelljs ... cement) |
5757
| tst.js:61:1:61:17 | shelljs.cat(file) |
58+
| tst.js:65:1:65:19 | shelljs.which(file) |
5859
test_MissingFileSystemAccess
59-
| tst.js:65:15:65:18 | file |
6060
test_SystemCommandExecution
6161
| tst.js:14:1:14:27 | shelljs ... ts, cb) |
6262
| tst.js:60:1:60:51 | shelljs ... ec(cmd) |
@@ -67,3 +67,4 @@ test_FileNameSource
6767
| tst.js:25:1:25:22 | shelljs ... , file) |
6868
| tst.js:26:1:26:30 | shelljs ... file2) |
6969
| tst.js:27:1:27:24 | shelljs ... file2) |
70+
| tst.js:65:1:65:19 | shelljs.which(file) |

0 commit comments

Comments
 (0)