Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions javascript/ql/src/semmle/javascript/dataflow/Configuration.qll
Original file line number Diff line number Diff line change
Expand Up @@ -570,10 +570,24 @@ private predicate reachableFromInput(
callInputStep(f, invk, input, nd, cfg) and
summary = PathSummary::level()
or
exists(DataFlow::Node mid, PathSummary oldSummary, PathSummary newSummary |
exists(DataFlow::Node mid, PathSummary oldSummary |
reachableFromInput(f, invk, input, mid, cfg, oldSummary) and
flowStep(mid, cfg, nd, newSummary) and
summary = oldSummary.append(newSummary)
appendStep(mid, cfg, oldSummary, nd, summary)
)
}

/**
* Holds if there is a step from `pred` to `succ` under `cfg` that can be appended
* to a path represented by `oldSummary` yielding a path represented by `newSummary`.
*/
pragma[noinline]
private predicate appendStep(
DataFlow::Node pred, DataFlow::Configuration cfg, PathSummary oldSummary, DataFlow::Node succ,
PathSummary newSummary
) {
exists(PathSummary stepSummary |
flowStep(pred, cfg, succ, stepSummary) and
newSummary = oldSummary.append(stepSummary)
)
}

Expand Down
8 changes: 4 additions & 4 deletions javascript/ql/src/semmle/javascript/frameworks/Electron.qll
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module Electron {
/**
* An instantiation of `BrowserWindow` or `BrowserView`.
*/
abstract private class NewBrowserObject extends BrowserObject, DataFlow::TrackedNode {
abstract private class NewBrowserObject extends BrowserObject, DataFlow::SourceNode {
DataFlow::NewNode self;

NewBrowserObject() { this = self }
Expand Down Expand Up @@ -250,10 +250,10 @@ module Electron {
/**
* An additional flow step via an Electron IPC message.
*/
private class IPCAdditionalFlowStep extends DataFlow::Configuration {
IPCAdditionalFlowStep() { this instanceof DataFlow::Configuration }
private class IPCAdditionalFlowStep extends DataFlow::AdditionalFlowStep {
IPCAdditionalFlowStep() { ipcFlowStep(this, _) }

override predicate isAdditionalFlowStep(DataFlow::Node pred, DataFlow::Node succ) {
override predicate step(DataFlow::Node pred, DataFlow::Node succ) {
ipcFlowStep(pred, succ)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
| electron.js:3:10:3:48 | new Bro ... s: {}}) |
| electron.js:4:5:4:46 | bv |
| electron.js:4:10:4:46 | new Bro ... s: {}}) |
| electron.js:35:14:35:14 | x |
| electron.js:36:12:36:12 | x |
| electron.js:39:1:39:7 | foo(bw) |
| electron.js:39:5:39:6 | bw |
| electron.js:40:1:40:7 | foo(bv) |
| electron.js:40:5:40:6 | bv |
| electron.ts:3:12:3:13 | bw |
| electron.ts:3:40:3:41 | bv |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import javascript

class TestConfig extends DataFlow::Configuration {
TestConfig() { this = "TestConfig" }
}

from TestConfig cfg, DataFlow::Node pred, DataFlow::Node succ
where cfg.isAdditionalFlowStep(pred, succ)
from DataFlow::AdditionalFlowStep afs, DataFlow::Node pred, DataFlow::Node succ
where afs.step(pred, succ)
select pred, succ
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
| electron.js:39:1:39:19 | foo(bw).webContents |
| electron.js:40:1:40:19 | foo(bv).webContents |
| electron.ts:4:3:4:16 | bw.webContents |
| electron.ts:5:3:5:16 | bv.webContents |