Skip to content

Commit d549a0d

Browse files
authored
Merge pull request #1111 from xiemaisi/js/performance-fiddling
Approved by esben-semmle
2 parents bd3792a + 8e52528 commit d549a0d

File tree

5 files changed

+23
-19
lines changed

5 files changed

+23
-19
lines changed

javascript/ql/src/semmle/javascript/dataflow/Configuration.qll

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -570,10 +570,24 @@ private predicate reachableFromInput(
570570
callInputStep(f, invk, input, nd, cfg) and
571571
summary = PathSummary::level()
572572
or
573-
exists(DataFlow::Node mid, PathSummary oldSummary, PathSummary newSummary |
573+
exists(DataFlow::Node mid, PathSummary oldSummary |
574574
reachableFromInput(f, invk, input, mid, cfg, oldSummary) and
575-
flowStep(mid, cfg, nd, newSummary) and
576-
summary = oldSummary.append(newSummary)
575+
appendStep(mid, cfg, oldSummary, nd, summary)
576+
)
577+
}
578+
579+
/**
580+
* Holds if there is a step from `pred` to `succ` under `cfg` that can be appended
581+
* to a path represented by `oldSummary` yielding a path represented by `newSummary`.
582+
*/
583+
pragma[noinline]
584+
private predicate appendStep(
585+
DataFlow::Node pred, DataFlow::Configuration cfg, PathSummary oldSummary, DataFlow::Node succ,
586+
PathSummary newSummary
587+
) {
588+
exists(PathSummary stepSummary |
589+
flowStep(pred, cfg, succ, stepSummary) and
590+
newSummary = oldSummary.append(stepSummary)
577591
)
578592
}
579593

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module Electron {
1616
/**
1717
* An instantiation of `BrowserWindow` or `BrowserView`.
1818
*/
19-
abstract private class NewBrowserObject extends BrowserObject, DataFlow::TrackedNode {
19+
abstract private class NewBrowserObject extends BrowserObject, DataFlow::SourceNode {
2020
DataFlow::NewNode self;
2121

2222
NewBrowserObject() { this = self }
@@ -250,10 +250,10 @@ module Electron {
250250
/**
251251
* An additional flow step via an Electron IPC message.
252252
*/
253-
private class IPCAdditionalFlowStep extends DataFlow::Configuration {
254-
IPCAdditionalFlowStep() { this instanceof DataFlow::Configuration }
253+
private class IPCAdditionalFlowStep extends DataFlow::AdditionalFlowStep {
254+
IPCAdditionalFlowStep() { ipcFlowStep(this, _) }
255255

256-
override predicate isAdditionalFlowStep(DataFlow::Node pred, DataFlow::Node succ) {
256+
override predicate step(DataFlow::Node pred, DataFlow::Node succ) {
257257
ipcFlowStep(pred, succ)
258258
}
259259
}

javascript/ql/test/library-tests/frameworks/Electron/BrowserObject.expected

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
| electron.js:3:10:3:48 | new Bro ... s: {}}) |
55
| electron.js:4:5:4:46 | bv |
66
| electron.js:4:10:4:46 | new Bro ... s: {}}) |
7-
| electron.js:35:14:35:14 | x |
8-
| electron.js:36:12:36:12 | x |
9-
| electron.js:39:1:39:7 | foo(bw) |
107
| electron.js:39:5:39:6 | bw |
11-
| electron.js:40:1:40:7 | foo(bv) |
128
| electron.js:40:5:40:6 | bv |
139
| electron.ts:3:12:3:13 | bw |
1410
| electron.ts:3:40:3:41 | bv |
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import javascript
22

3-
class TestConfig extends DataFlow::Configuration {
4-
TestConfig() { this = "TestConfig" }
5-
}
6-
7-
from TestConfig cfg, DataFlow::Node pred, DataFlow::Node succ
8-
where cfg.isAdditionalFlowStep(pred, succ)
3+
from DataFlow::AdditionalFlowStep afs, DataFlow::Node pred, DataFlow::Node succ
4+
where afs.step(pred, succ)
95
select pred, succ
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
| electron.js:39:1:39:19 | foo(bw).webContents |
2-
| electron.js:40:1:40:19 | foo(bv).webContents |
31
| electron.ts:4:3:4:16 | bw.webContents |
42
| electron.ts:5:3:5:16 | bv.webContents |

0 commit comments

Comments
 (0)