Skip to content

Commit 089d030

Browse files
committed
make ApiLabel into a IPA type, and cache the public API of ApiGraphs
1 parent 1f3f7e9 commit 089d030

File tree

13 files changed

+343
-158
lines changed

13 files changed

+343
-158
lines changed

javascript/ql/lib/semmle/javascript/ApiGraphs.qll

Lines changed: 275 additions & 137 deletions
Large diffs are not rendered by default.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module D3 {
2323
or
2424
result = API::moduleImport("d3-node").getInstance().getMember("d3")
2525
or
26-
result = API::root().getASuccessor(any(D3GlobalEntry i))
26+
result = any(D3GlobalEntry i).getNode()
2727
}
2828

2929
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module History {
1717
* Gets a reference to the [`history`](https://npmjs.org/package/history) library.
1818
*/
1919
private API::Node history() {
20-
result = [API::moduleImport("history"), API::root().getASuccessor(any(HistoryGlobalEntry h))]
20+
result = [API::moduleImport("history"), any(HistoryGlobalEntry h).getNode()]
2121
}
2222

2323
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ private module Immutable {
2727
API::Node immutableImport() {
2828
result = API::moduleImport("immutable")
2929
or
30-
result = API::root().getASuccessor(any(ImmutableGlobalEntry i))
30+
result = any(ImmutableGlobalEntry i).getNode()
3131
}
3232

3333
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private module Console {
4545
*/
4646
private API::Node console() {
4747
result = API::moduleImport("console") or
48-
result = API::root().getASuccessor(any(ConsoleGlobalEntry e))
48+
result = any(ConsoleGlobalEntry e).getNode()
4949
}
5050

5151
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ module NestJS {
151151
private API::Node validationPipe() {
152152
result = nestjs().getMember("ValidationPipe")
153153
or
154-
result = API::root().getASuccessor(any(ValidationNodeEntry e))
154+
result = any(ValidationNodeEntry e).getNode()
155155
}
156156

157157
/**

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,9 +1111,7 @@ module Redux {
11111111

11121112
/** A heuristic call to `connect`, recognized by it taking arguments named `mapStateToProps` and `mapDispatchToProps`. */
11131113
private class HeuristicConnectFunction extends ConnectCall {
1114-
HeuristicConnectFunction() {
1115-
this = API::root().getASuccessor(any(HeuristicConnectEntryPoint e)).getACall()
1116-
}
1114+
HeuristicConnectFunction() { this = any(HeuristicConnectEntryPoint e).getNode().getACall() }
11171115

11181116
override API::Node getMapStateToProps() {
11191117
result = getAParameter() and

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module Vue {
3535
API::Node vueLibrary() {
3636
result = API::moduleImport("vue")
3737
or
38-
result = API::root().getASuccessor(any(GlobalVueEntryPoint e))
38+
result = any(GlobalVueEntryPoint e).getNode()
3939
}
4040

4141
/**
@@ -51,7 +51,7 @@ module Vue {
5151
or
5252
result = vueLibrary().getMember("component").getReturn()
5353
or
54-
result = API::root().getASuccessor(any(VueFileImportEntryPoint e))
54+
result = any(VueFileImportEntryPoint e).getNode()
5555
}
5656

5757
/**

javascript/ql/lib/semmle/javascript/internal/CachedStages.qll

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,43 @@ module Stages {
233233
}
234234
}
235235

236+
/**
237+
* The `APIStage` stage.
238+
*/
239+
cached
240+
module APIStage {
241+
/**
242+
* Always holds.
243+
* Ensures that a predicate is evaluated as part of the APIStage stage.
244+
*/
245+
cached
246+
predicate ref() { 1 = 1 }
247+
248+
/**
249+
* DONT USE!
250+
* Contains references to each predicate that use the above `ref` predicate.
251+
*/
252+
cached
253+
predicate backref() {
254+
1 = 1
255+
or
256+
exists(
257+
API::moduleImport("foo")
258+
.getMember("bar")
259+
.getUnknownMember()
260+
.getAMember()
261+
.getAParameter()
262+
.getPromised()
263+
.getReturn()
264+
.getParameter(2)
265+
.getUnknownMember()
266+
.getInstance()
267+
.getReceiver()
268+
.getPromisedError()
269+
)
270+
}
271+
}
272+
236273
/**
237274
* The `taint` stage.
238275
*/

javascript/ql/lib/semmle/javascript/security/dataflow/ExternalAPIUsedWithUntrustedDataCustomizations.qll

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,9 @@ module ExternalAPIUsedWithUntrustedData {
211211
node = getNamedParameter(base.getAParameter(), paramName) and
212212
result = basename + ".[callback].[param '" + paramName + "']"
213213
or
214-
exists(string callbackName, string index |
215-
node =
216-
getNamedParameter(base.getASuccessor("parameter " + index).getMember(callbackName),
217-
paramName) and
218-
index != "-1" and // ignore receiver
214+
exists(string callbackName, int index |
215+
node = getNamedParameter(base.getParameter(index).getMember(callbackName), paramName) and
216+
index != -1 and // ignore receiver
219217
result =
220218
basename + ".[callback " + index + " '" + callbackName + "'].[param '" + paramName +
221219
"']"

0 commit comments

Comments
 (0)