mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
JavaScript: Recognise Electron browser objects based on TypeScript types when available.
This commit is contained in:
@@ -11,7 +11,7 @@ module Electron {
|
||||
/**
|
||||
* A data flow node that may contain a `BrowserWindow` or `BrowserView` object.
|
||||
*/
|
||||
abstract private class BrowserObject extends DataFlow::Node { }
|
||||
abstract class BrowserObject extends DataFlow::Node { }
|
||||
|
||||
/**
|
||||
* An instantiation of `BrowserWindow` or `BrowserView`.
|
||||
@@ -45,6 +45,17 @@ module Electron {
|
||||
BrowserView() { this = DataFlow::moduleMember("electron", "BrowserView").getAnInstantiation() }
|
||||
}
|
||||
|
||||
/**
|
||||
* An expression of type `BrowserWindow` or `BrowserView`.
|
||||
*/
|
||||
private class BrowserObjectByType extends BrowserObject {
|
||||
BrowserObjectByType() {
|
||||
exists (string tp | tp = "BrowserWindow" or tp = "BrowserView" |
|
||||
asExpr().getType().hasUnderlyingType("electron", tp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A Node.js-style HTTP or HTTPS request made using an Electron module.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
| electron.d.ts:2:16:2:28 | BrowserWindow |
|
||||
| electron.d.ts:3:16:3:26 | BrowserView |
|
||||
| electron.js:3:1:3:39 | new Bro ... s: {}}) |
|
||||
| electron.js:4:1:4:37 | new Bro ... s: {}}) |
|
||||
| electron.ts:3:12:3:13 | bw |
|
||||
| electron.ts:3:40:3:41 | bv |
|
||||
@@ -0,0 +1,4 @@
|
||||
import javascript
|
||||
|
||||
from Electron::BrowserObject obj
|
||||
select obj
|
||||
8
javascript/ql/test/library-tests/frameworks/Electron/electron.d.ts
vendored
Normal file
8
javascript/ql/test/library-tests/frameworks/Electron/electron.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
declare namespace Electron {
|
||||
export class BrowserWindow { }
|
||||
export class BrowserView { }
|
||||
}
|
||||
|
||||
declare module 'electron' {
|
||||
export = Electron;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
///<reference path="./electron.d.ts"/>
|
||||
|
||||
function f(bw: Electron.BrowserWindow, bv: Electron.BrowserView) {
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"include": ["."]
|
||||
}
|
||||
Reference in New Issue
Block a user