Skip to content

Commit 28373e0

Browse files
committed
JS: Adapt to changes in shared code
1 parent 0e81577 commit 28373e0

File tree

7 files changed

+33
-220
lines changed

7 files changed

+33
-220
lines changed

config/identical-files.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,6 @@
469469
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/AccessPathSyntax.qll",
470470
"go/ql/lib/semmle/go/dataflow/internal/AccessPathSyntax.qll",
471471
"java/ql/lib/semmle/code/java/dataflow/internal/AccessPathSyntax.qll",
472-
"javascript/ql/lib/semmle/javascript/frameworks/data/internal/AccessPathSyntax.qll",
473472
"python/ql/lib/semmle/python/dataflow/new/internal/AccessPathSyntax.qll",
474473
"swift/ql/lib/codeql/swift/dataflow/internal/AccessPathSyntax.qll"
475474
],

javascript/ql/lib/qlpack.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ extractor: javascript
66
library: true
77
upgrades: upgrades
88
dependencies:
9+
codeql/dataflow: ${workspace}
910
codeql/mad: ${workspace}
1011
codeql/regex: ${workspace}
1112
codeql/tutorial: ${workspace}

javascript/ql/lib/semmle/javascript/frameworks/data/internal/AccessPathSyntax.qll

Lines changed: 0 additions & 182 deletions
This file was deleted.

javascript/ql/lib/semmle/javascript/frameworks/data/internal/ApiGraphModels.qll

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ private module API = Specific::API;
7070

7171
private module DataFlow = Specific::DataFlow;
7272

73-
private import Specific::AccessPathSyntax
7473
private import ApiGraphModelsExtensions as Extensions
74+
import codeql.dataflow.internal.AccessPathSyntax
7575

7676
/** Module containing hooks for providing input data to be interpreted as a model. */
7777
module ModelInput {
@@ -327,29 +327,29 @@ predicate isRelevantFullPath(string type, string path) {
327327
}
328328

329329
/** A string from a CSV row that should be parsed as an access path. */
330-
private class AccessPathRange extends AccessPath::Range {
331-
AccessPathRange() {
332-
isRelevantFullPath(_, this)
333-
or
334-
exists(string type | isRelevantType(type) |
335-
summaryModel(type, _, this, _, _) or
336-
summaryModel(type, _, _, this, _)
337-
)
338-
or
339-
typeVariableModel(_, this)
340-
}
330+
private predicate accessPathRange(string s) {
331+
isRelevantFullPath(_, s)
332+
or
333+
exists(string type | isRelevantType(type) |
334+
summaryModel(type, _, s, _, _) or
335+
summaryModel(type, _, _, s, _)
336+
)
337+
or
338+
typeVariableModel(_, s)
341339
}
342340

341+
import AccessPath<accessPathRange/1>
342+
343343
/**
344344
* Gets a successor of `node` in the API graph.
345345
*/
346346
bindingset[token]
347-
API::Node getSuccessorFromNode(API::Node node, AccessPathToken token) {
347+
API::Node getSuccessorFromNode(API::Node node, AccessPathTokenBase token) {
348348
// API graphs use the same label for arguments and parameters. An edge originating from a
349349
// use-node represents an argument, and an edge originating from a def-node represents a parameter.
350350
// We just map both to the same thing.
351351
token.getName() = ["Argument", "Parameter"] and
352-
result = node.getParameter(AccessPath::parseIntUnbounded(token.getAnArgument()))
352+
result = node.getParameter(parseIntUnbounded(token.getAnArgument()))
353353
or
354354
token.getName() = "ReturnValue" and
355355
result = node.getReturn()
@@ -362,11 +362,9 @@ API::Node getSuccessorFromNode(API::Node node, AccessPathToken token) {
362362
* Gets an API-graph successor for the given invocation.
363363
*/
364364
bindingset[token]
365-
API::Node getSuccessorFromInvoke(Specific::InvokeNode invoke, AccessPathToken token) {
365+
API::Node getSuccessorFromInvoke(Specific::InvokeNode invoke, AccessPathTokenBase token) {
366366
token.getName() = "Argument" and
367-
result =
368-
invoke
369-
.getParameter(AccessPath::parseIntWithArity(token.getAnArgument(), invoke.getNumArgument()))
367+
result = invoke.getParameter(parseIntWithArity(token.getAnArgument(), invoke.getNumArgument()))
370368
or
371369
token.getName() = "ReturnValue" and
372370
result = invoke.getReturn()
@@ -378,10 +376,12 @@ API::Node getSuccessorFromInvoke(Specific::InvokeNode invoke, AccessPathToken to
378376
/**
379377
* Holds if `invoke` invokes a call-site filter given by `token`.
380378
*/
381-
pragma[inline]
382-
private predicate invocationMatchesCallSiteFilter(Specific::InvokeNode invoke, AccessPathToken token) {
379+
bindingset[token]
380+
private predicate invocationMatchesCallSiteFilter(
381+
Specific::InvokeNode invoke, AccessPathTokenBase token
382+
) {
383383
token.getName() = "WithArity" and
384-
invoke.getNumArgument() = AccessPath::parseIntUnbounded(token.getAnArgument())
384+
invoke.getNumArgument() = parseIntUnbounded(token.getAnArgument())
385385
or
386386
Specific::invocationMatchesExtraCallSiteFilter(invoke, token)
387387
}

javascript/ql/lib/semmle/javascript/frameworks/data/internal/ApiGraphModelsSpecific.qll

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
* It must export the following members:
55
* ```ql
66
* class Unit // a unit type
7-
* module AccessPathSyntax // a re-export of the AccessPathSyntax module
87
* class InvokeNode // a type representing an invocation connected to the API graph
98
* module API // the API graph module
109
* predicate isPackageUsed(string package)
1110
* API::Node getExtraNodeFromPath(string package, string type, string path, int n)
12-
* API::Node getExtraSuccessorFromNode(API::Node node, AccessPathToken token)
13-
* API::Node getExtraSuccessorFromInvoke(InvokeNode node, AccessPathToken token)
14-
* predicate invocationMatchesExtraCallSiteFilter(InvokeNode invoke, AccessPathToken token)
11+
* API::Node getExtraSuccessorFromNode(API::Node node, AccessPathTokenBase token)
12+
* API::Node getExtraSuccessorFromInvoke(InvokeNode node, AccessPathTokenBase token)
13+
* predicate invocationMatchesExtraCallSiteFilter(InvokeNode invoke, AccessPathTokenBase token)
1514
* InvokeNode getAnInvocationOf(API::Node node)
1615
* predicate isExtraValidTokenNameInIdentifyingAccessPath(string name)
1716
* predicate isExtraValidNoArgumentTokenInIdentifyingAccessPath(string name)
@@ -25,9 +24,7 @@ private import ApiGraphModels
2524
// Re-export libraries needed by ApiGraphModels.qll
2625
module API = JS::API;
2726

28-
import semmle.javascript.frameworks.data.internal.AccessPathSyntax as AccessPathSyntax
2927
import JS::DataFlow as DataFlow
30-
private import AccessPathSyntax
3128

3229
/**
3330
* Holds if `rawType` represents the JavaScript type `qualifiedName` from the given NPM `package`.
@@ -137,7 +134,7 @@ API::Node getExtraNodeFromType(string type) {
137134
* Gets a JavaScript-specific API graph successor of `node` reachable by resolving `token`.
138135
*/
139136
bindingset[token]
140-
API::Node getExtraSuccessorFromNode(API::Node node, AccessPathToken token) {
137+
API::Node getExtraSuccessorFromNode(API::Node node, AccessPathTokenBase token) {
141138
token.getName() = "Member" and
142139
result = node.getMember(token.getAnArgument())
143140
or
@@ -183,7 +180,7 @@ API::Node getExtraSuccessorFromNode(API::Node node, AccessPathToken token) {
183180
* Gets a JavaScript-specific API graph successor of `node` reachable by resolving `token`.
184181
*/
185182
bindingset[token]
186-
API::Node getExtraSuccessorFromInvoke(API::InvokeNode node, AccessPathToken token) {
183+
API::Node getExtraSuccessorFromInvoke(API::InvokeNode node, AccessPathTokenBase token) {
187184
token.getName() = "Instance" and
188185
result = node.getInstance()
189186
or
@@ -233,7 +230,7 @@ API::Node getAFuzzySuccessor(API::Node node) {
233230
* Holds if `invoke` matches the JS-specific call site filter in `token`.
234231
*/
235232
bindingset[token]
236-
predicate invocationMatchesExtraCallSiteFilter(API::InvokeNode invoke, AccessPathToken token) {
233+
predicate invocationMatchesExtraCallSiteFilter(API::InvokeNode invoke, AccessPathTokenBase token) {
237234
token.getName() = "NewCall" and
238235
invoke instanceof API::NewNode
239236
or
@@ -246,9 +243,8 @@ predicate invocationMatchesExtraCallSiteFilter(API::InvokeNode invoke, AccessPat
246243
operand = token.getAnArgument() and
247244
argIndex = operand.splitAt("=", 0) and
248245
stringValue = operand.splitAt("=", 1) and
249-
invoke
250-
.getArgument(AccessPath::parseIntWithArity(argIndex, invoke.getNumArgument()))
251-
.getStringValue() = stringValue
246+
invoke.getArgument(parseIntWithArity(argIndex, invoke.getNumArgument())).getStringValue() =
247+
stringValue
252248
)
253249
}
254250

@@ -338,7 +334,7 @@ predicate isExtraValidTokenArgumentInIdentifyingAccessPath(string name, string a
338334
or
339335
name = "WithStringArgument" and
340336
exists(argument.indexOf("=")) and
341-
exists(AccessPath::parseIntWithArity(argument.splitAt("=", 0), 10))
337+
exists(parseIntWithArity(argument.splitAt("=", 0), 10))
342338
}
343339

344340
module ModelOutputSpecific {

javascript/ql/test/library-tests/frameworks/data/test.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import javascript
22
import testUtilities.ConsistencyChecking
3-
import semmle.javascript.frameworks.data.internal.AccessPathSyntax as AccessPathSyntax
3+
import semmle.javascript.frameworks.data.internal.ApiGraphModels as ApiGraphModels
44

55
class Steps extends ModelInput::SummaryModelCsv {
66
override predicate row(string row) {
@@ -126,6 +126,6 @@ class SyntaxErrorTest extends ModelInput::SinkModelCsv {
126126
}
127127
}
128128

129-
query predicate syntaxErrors(AccessPathSyntax::AccessPath path) { path.hasSyntaxError() }
129+
query predicate syntaxErrors(ApiGraphModels::AccessPath path) { path.hasSyntaxError() }
130130

131131
query predicate warning = ModelOutput::getAWarning/0;

javascript/ql/test/library-tests/frameworks/data/warnings.ql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import javascript
2-
import semmle.javascript.frameworks.data.internal.AccessPathSyntax as AccessPathSyntax
32
import semmle.javascript.frameworks.data.internal.ApiGraphModels as ApiGraphModels
43

54
private class InvalidTypeModel extends ModelInput::TypeModelCsv {

0 commit comments

Comments
 (0)