Skip to content

Commit 961b09d

Browse files
committed
Use methods of AccessPathToken more
1 parent 9f7c475 commit 961b09d

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,15 @@ predicate hasExternalSpecification(Function f) {
330330
}
331331

332332
private predicate parseField(AccessPathToken c, DataFlow::FieldContent f) {
333-
exists(string fieldRegex, string package, string className, string fieldName |
334-
fieldRegex = "^Field\\[(.*)\\.([^.]+)\\.([^.]+)\\]$" and
335-
package = c.regexpCapture(fieldRegex, 1) and
336-
className = c.regexpCapture(fieldRegex, 2) and
337-
fieldName = c.regexpCapture(fieldRegex, 3) and
333+
exists(
334+
string fieldRegex, string qualifiedName, string package, string className, string fieldName
335+
|
336+
c.getName() = "Field" and
337+
qualifiedName = c.getAnArgument() and
338+
fieldRegex = "^(.*)\\.([^.]+)\\.([^.]+)$" and
339+
package = qualifiedName.regexpCapture(fieldRegex, 1) and
340+
className = qualifiedName.regexpCapture(fieldRegex, 2) and
341+
fieldName = qualifiedName.regexpCapture(fieldRegex, 3) and
338342
f.getField().hasQualifiedName(package, className, fieldName)
339343
)
340344
}
@@ -351,11 +355,12 @@ class SyntheticField extends string {
351355
}
352356

353357
private predicate parseSynthField(AccessPathToken c, string f) {
354-
c.regexpCapture("SyntheticField\\[([.a-zA-Z0-9]+)\\]", 1) = f
358+
c.getName() = "SyntheticField" and
359+
f = c.getAnArgument()
355360
}
356361

357362
/** Holds if the specification component parses as a `Content`. */
358-
predicate parseContent(string component, DataFlow::Content content) {
363+
predicate parseContent(AccessPathToken component, DataFlow::Content content) {
359364
parseField(component, content)
360365
or
361366
parseSynthField(component, content.(DataFlow::SyntheticFieldContent).getField())

0 commit comments

Comments
 (0)