Skip to content

Commit 846a876

Browse files
committed
Go: update to use new API exposed by FlowSummaryImpl.qll
1 parent da52cb2 commit 846a876

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

ql/lib/semmle/go/dataflow/ExternalFlow.qll

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ private import go
6464
private import internal.DataFlowPrivate
6565
private import internal.FlowSummaryImpl::Private::External
6666
private import internal.FlowSummaryImplSpecific
67+
private import internal.AccessPathSyntax
6768
private import FlowSummary
6869

6970
/**
@@ -295,7 +296,7 @@ module CsvValidation {
295296
msg = "Unrecognized extra API graph element \"" + ext + "\" in " + pred + " model."
296297
)
297298
or
298-
exists(string pred, string input, string part |
299+
exists(string pred, AccessPath input, string part |
299300
sinkModel(_, _, _, _, _, _, input, _) and pred = "sink"
300301
or
301302
summaryModel(_, _, _, _, _, _, input, _, _) and pred = "summary"
@@ -305,7 +306,7 @@ module CsvValidation {
305306
not part = "" and
306307
not parseArg(part, _)
307308
or
308-
specSplit(input, part, _) and
309+
part = input.getToken(_) and
309310
parseParam(part, _)
310311
) and
311312
msg = "Unrecognized input specification \"" + part + "\" in " + pred + " model."
@@ -403,8 +404,7 @@ predicate hasExternalSpecification(Function f) {
403404
exists(SourceOrSinkElement e | f = e.asEntity() | sourceElement(e, _, _) or sinkElement(e, _, _))
404405
}
405406

406-
private predicate parseField(string c, DataFlow::FieldContent f) {
407-
specSplit(_, c, _) and
407+
private predicate parseField(AccessPathToken c, DataFlow::FieldContent f) {
408408
exists(string fieldRegex, string package, string className, string fieldName |
409409
fieldRegex = "^Field\\[(.*)\\.([^.]+)\\.([^.]+)\\]$" and
410410
package = c.regexpCapture(fieldRegex, 1) and
@@ -425,8 +425,7 @@ class SyntheticField extends string {
425425
Type getType() { result instanceof EmptyInterfaceType }
426426
}
427427

428-
private predicate parseSynthField(string c, string f) {
429-
specSplit(_, c, _) and
428+
private predicate parseSynthField(AccessPathToken c, string f) {
430429
c.regexpCapture("SyntheticField\\[([.a-zA-Z0-9]+)\\]", 1) = f
431430
}
432431

ql/lib/semmle/go/dataflow/internal/FlowSummaryImplSpecific.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,12 @@ predicate interpretInputSpecific(string c, InterpretNode mid, InterpretNode n) {
272272
}
273273

274274
/** Holds if specification component `c` parses as return value `n`. */
275-
predicate parseReturn(string c, int n) {
276-
External::specSplit(_, c, _) and
275+
predicate parseReturn(AccessPathToken c, int n) {
277276
(
278277
c = "ReturnValue" and n = 0
279278
or
280-
n = parseConstantOrRange(c.regexpCapture("ReturnValue\\[([^\\]]+)\\]", 1))
279+
c.getName() = "ReturnValue" and
280+
n = parseConstantOrRange(c.getAnArgument())
281281
)
282282
}
283283

0 commit comments

Comments
 (0)