Skip to content

Commit e2fac8a

Browse files
author
Esben Sparre Andreasen
committed
JS: introduce concept: FileNameSource
1 parent 6d3c1a1 commit e2fac8a

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

javascript/ql/src/semmle/javascript/Concepts.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ abstract class FileSystemAccess extends DataFlow::Node {
2929
abstract DataFlow::Node getAPathArgument();
3030
}
3131

32+
/**
33+
* A data flow node that contains a file name or an array of file names from the local file system.
34+
*/
35+
abstract class FileNameSource extends DataFlow::Node {
36+
37+
}
38+
3239
/**
3340
* A data flow node that performs a database access.
3441
*/

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,22 @@ module NodeJSLib {
365365
}
366366
}
367367

368+
/**
369+
* A data flow node that contains a file name or an array of file names from the local file system.
370+
*/
371+
private class NodeJSFileNameSource extends FileNameSource {
372+
373+
NodeJSFileNameSource() {
374+
exists (string name |
375+
name = "readdir" or
376+
name = "realpath" |
377+
this = fsModuleMember(name).getACall().getCallback([1..2]).getParameter(1) or
378+
this = fsModuleMember(name + "Sync").getACall()
379+
)
380+
}
381+
382+
}
383+
368384
/**
369385
* A call to a method from module `child_process`.
370386
*/

0 commit comments

Comments
 (0)