Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 82abd86

Browse files
committed
JS: Update uses of AccessPathSyntax
This doesn't yet migrate to the FlowSummaryImpl.qll in a qlpack, just trying to make things compile first
1 parent e5bc8db commit 82abd86

3 files changed

Lines changed: 19 additions & 21 deletions

File tree

javascript/ql/lib/semmle/javascript/dataflow/internal/Contents.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
private import javascript
2-
private import semmle.javascript.frameworks.data.internal.AccessPathSyntax as AccessPathSyntax
2+
private import semmle.javascript.frameworks.data.internal.ApiGraphModels as ApiGraphModels
33

44
module Private {
55
import Public
@@ -25,7 +25,7 @@ module Private {
2525
call.getArgument(0).getStringValue() = key
2626
)
2727
or
28-
exists(AccessPathSyntax::AccessPathToken token |
28+
exists(ApiGraphModels::AccessPathToken token |
2929
token.getName() = "MapValue" and
3030
token.getAnArgument() = key
3131
)
@@ -47,7 +47,7 @@ module Private {
4747
or
4848
this = getAPreciseArrayIndex().toString()
4949
or
50-
exists(AccessPathSyntax::AccessPathToken tok |
50+
exists(ApiGraphModels::AccessPathToken tok |
5151
tok.getName() = "Member" and this = tok.getAnArgument()
5252
)
5353
}

javascript/ql/lib/semmle/javascript/dataflow/internal/FlowSummaryPrivate.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ private import semmle.javascript.dataflow.FlowSummary as FlowSummary
99
private import sharedlib.DataFlowImplCommon
1010
private import sharedlib.FlowSummaryImpl::Private as Private
1111
private import sharedlib.FlowSummaryImpl::Public
12-
import semmle.javascript.frameworks.data.internal.AccessPathSyntax as AccessPathSyntax
12+
private import codeql.dataflow.internal.AccessPathSyntax as AccessPathSyntax
1313

1414
private class Node = DataFlow::Node;
1515

@@ -147,7 +147,7 @@ private predicate desugaredPositionName(ParameterPosition pos, string operand) {
147147
operand = "any" and
148148
pos.asPositionalLowerBound() = 0
149149
or
150-
pos.asPositional() = AccessPathSyntax::AccessPath::parseInt(operand) // parse closed intervals
150+
pos.asPositional() = AccessPathSyntax::parseInt(operand) // parse closed intervals
151151
}
152152

153153
bindingset[operand]
@@ -186,7 +186,7 @@ SummaryComponent interpretComponentSpecific(Private::AccessPathToken c) {
186186
result = makePropertyContentComponents(c, "ArrayElement", n.toString())
187187
or
188188
// ArrayElement[n..] refers to index n or greater
189-
n = AccessPathSyntax::AccessPath::parseLowerBound(c.getAnArgument()) and
189+
n = AccessPathSyntax::parseLowerBound(c.getAnArgument()) and
190190
result = makeContentComponents(c, "ArrayElement", ContentSet::arrayElementLowerBoundFromInt(n))
191191
)
192192
or
@@ -355,7 +355,7 @@ ArgumentPosition parseParamBody(string s) {
355355
or
356356
s = "function" and result.isFunctionSelfReference()
357357
or
358-
result.asPositional() = AccessPathSyntax::AccessPath::parseInt(s)
358+
result.asPositional() = AccessPathSyntax::parseInt(s)
359359
}
360360

361361
/** Gets the parameter position obtained by parsing `X` in `Argument[X]`. */

javascript/ql/lib/semmle/javascript/dataflow/internal/sharedlib/FlowSummaryImpl.qll

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ module Public {
340340
*/
341341
module Private {
342342
private import Public
343-
import AccessPathSyntax
343+
private import codeql.dataflow.internal.AccessPathSyntax
344344

345345
newtype TSummaryComponent =
346346
TContentSummaryComponent(ContentSet c) or
@@ -1037,23 +1037,21 @@ module Private {
10371037
}
10381038
}
10391039

1040+
/** Holds if `spec` is a relevant external specification. */
1041+
private predicate relevantSpec(string spec) {
1042+
summaryElement(_, spec, _, _, _) or
1043+
summaryElement(_, _, spec, _, _) or
1044+
sourceElement(_, spec, _, _) or
1045+
sinkElement(_, spec, _, _)
1046+
}
1047+
1048+
import AccessPath<relevantSpec/1>
1049+
10401050
/**
10411051
* Provides a means of translating externally (e.g., MaD) defined flow
10421052
* summaries into a `SummarizedCallable`s.
10431053
*/
10441054
module External {
1045-
/** Holds if `spec` is a relevant external specification. */
1046-
private predicate relevantSpec(string spec) {
1047-
summaryElement(_, spec, _, _, _) or
1048-
summaryElement(_, _, spec, _, _) or
1049-
sourceElement(_, spec, _, _) or
1050-
sinkElement(_, spec, _, _)
1051-
}
1052-
1053-
private class AccessPathRange extends AccessPath::Range {
1054-
AccessPathRange() { relevantSpec(this) }
1055-
}
1056-
10571055
/** Holds if specification component `token` parses as parameter `pos`. */
10581056
predicate parseParam(AccessPathToken token, ArgumentPosition pos) {
10591057
token.getName() = "Parameter" and
@@ -1184,7 +1182,7 @@ module Private {
11841182
predicate invalidIndexComponent(AccessPath spec, AccessPathToken part) {
11851183
part = spec.getToken(_) and
11861184
part.getName() = ["Parameter", "Argument"] and
1187-
AccessPath::parseInt(part.getArgumentList()) < 0
1185+
parseInt(part.getArgumentList()) < 0
11881186
}
11891187

11901188
private predicate inputNeedsReference(AccessPathToken c) {

0 commit comments

Comments
 (0)