mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Merge pull request #10768 from erik-krogh/fixFileLoops
JS: fix that js/file-system-race could have FPs related to loops
This commit is contained in:
@@ -106,7 +106,7 @@ predicate useAfterCheck(FileCheck check, FileUse use) {
|
||||
)
|
||||
)
|
||||
or
|
||||
check.getBasicBlock().getASuccessor+() = use.getBasicBlock()
|
||||
check.getBasicBlock().(ReachableBasicBlock).strictlyDominates(use.getBasicBlock())
|
||||
}
|
||||
|
||||
from FileCheck check, FileUse use
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
category: minorAnalysis
|
||||
---
|
||||
* Removed some false positives from the `js/file-system-race` query by requiring that the file-check dominates the file-access.
|
||||
@@ -41,3 +41,8 @@ const filePath3 = createFile();
|
||||
if (fs.existsSync(filePath3)) {
|
||||
fs.readFileSync(filePath3); // OK - a read after an existence check is OK
|
||||
}
|
||||
|
||||
const filePath4 = createFile();
|
||||
while(Math.random() > 0.5) {
|
||||
fs.open(filePath4); // OK - it is only ever opened here.
|
||||
}
|
||||
Reference in New Issue
Block a user