Skip to content

Commit b71d096

Browse files
committed
JS: Update type usage in Electron model
1 parent ace8b09 commit b71d096

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,19 @@ module Electron {
4141
BrowserView() { this = DataFlow::moduleMember("electron", "BrowserView").getAnInstantiation() }
4242
}
4343

44-
/**
45-
* An expression of type `BrowserWindow` or `BrowserView`.
46-
*/
47-
private class BrowserObjectByType extends BrowserObject {
48-
BrowserObjectByType() {
49-
exists(string tp | tp = "BrowserWindow" or tp = "BrowserView" |
50-
this.asExpr().getType().hasUnderlyingType("electron", tp)
51-
)
44+
private class ElectronEntryPoint extends API::EntryPoint {
45+
ElectronEntryPoint() { this = "Electron.Browser" }
46+
47+
override DataFlow::SourceNode getASource() {
48+
result.hasUnderlyingType(["Electron.BrowserWindow", "Electron.BrowserView"])
5249
}
5350
}
5451

55-
private API::Node browserObject() { result.asSource() instanceof NewBrowserObject }
52+
private API::Node browserObject() {
53+
result.asSource() instanceof NewBrowserObject or
54+
result = API::Node::ofType("electron", ["BrowserWindow", "BrowserView"]) or
55+
result = any(ElectronEntryPoint e).getANode()
56+
}
5657

5758
/**
5859
* A data flow node whose value may originate from a browser object instantiation.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ browserObject
1616
| electron.js:63:3:63:5 | win |
1717
| electron.js:65:18:65:20 | win |
1818
| electronTs.ts:3:12:3:13 | bw |
19+
| electronTs.ts:3:12:3:13 | bw |
20+
| electronTs.ts:3:40:3:41 | bv |
1921
| electronTs.ts:3:40:3:41 | bv |
2022
| electronTs.ts:4:3:4:4 | bw |
2123
| electronTs.ts:5:3:5:4 | bv |

0 commit comments

Comments
 (0)