Skip to content

Commit 6f508bc

Browse files
authored
Merge pull request github#2943 from esbena/js/more-fs-modules
Approved by erik-krogh
2 parents 8bd4f6d + 4625217 commit 6f508bc

File tree

5 files changed

+605
-5
lines changed

5 files changed

+605
-5
lines changed

change-notes/1.24/analysis-javascript.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
| Expression has no effect (`js/useless-expression`) | Fewer false positive results | The query now recognizes block-level flow type annotations and ignores the first statement of a try block. |
6161
| Use of call stack introspection in strict mode (`js/strict-mode-call-stack-introspection`) | Fewer false positive results | The query no longer flags expression statements. |
6262
| Missing CSRF middleware (`js/missing-token-validation`) | Fewer false positive results | The query reports fewer duplicates and only flags handlers that explicitly access cookie data. |
63-
| Uncontrolled data used in path expression (`js/path-injection`) | More results | This query now recognizes additional ways dangerous paths can be constructed. |
63+
| Uncontrolled data used in path expression (`js/path-injection`) | More results | This query now recognizes additional ways dangerous paths can be constructed and used. |
6464
| Uncontrolled command line (`js/command-line-injection`) | More results | This query now recognizes additional ways of constructing arguments to `cmd.exe` and `/bin/sh`. |
6565

6666
## Changes to libraries

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,16 +429,27 @@ module NodeJSLib {
429429
}
430430

431431
/**
432-
* A member `member` from module `fs` or its drop-in replacements `graceful-fs` or `fs-extra`.
432+
* A member `member` from module `fs` or its drop-in replacements `graceful-fs`, `fs-extra`, `original-fs`.
433433
*/
434434
private DataFlow::SourceNode fsModuleMember(string member) {
435+
result = fsModule(DataFlow::TypeTracker::end()).getAPropertyRead(member)
436+
}
437+
438+
private DataFlow::SourceNode fsModule(DataFlow::TypeTracker t) {
435439
exists(string moduleName |
436440
moduleName = "fs" or
437441
moduleName = "graceful-fs" or
438-
moduleName = "fs-extra"
442+
moduleName = "fs-extra" or
443+
moduleName = "original-fs"
439444
|
440-
result = DataFlow::moduleMember(moduleName, member)
441-
)
445+
result = DataFlow::moduleImport(moduleName)
446+
or
447+
// extra support for flexible names
448+
result.asExpr().(Require).getArgument(0).mayHaveStringValue(moduleName)
449+
) and
450+
t.start()
451+
or
452+
exists(DataFlow::TypeTracker t2 | result = fsModule(t2).track(t2, t))
442453
}
443454

444455
/**

0 commit comments

Comments
 (0)