Skip to content

Commit bc40a42

Browse files
committed
Do not use full regex match for %T
1 parent f944ff4 commit bc40a42

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

go/ql/lib/semmle/go/Concepts.qll

+5-2
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,11 @@ class LoggerCall extends DataFlow::Node instanceof LoggerCall::Range {
367367
DataFlow::Node getAValueFormattedMessageComponent() {
368368
result = this.getAMessageComponent() and
369369
not exists(string formatSpecifier |
370-
formatSpecifier.regexpMatch("%[^%]*T") and
371-
result = this.(StringOps::Formatting::StringFormatCall).getOperand(_, formatSpecifier)
370+
result = this.(StringOps::Formatting::StringFormatCall).getOperand(_, formatSpecifier) and
371+
// We already know that `formatSpecifier` starts with `%`, so we check
372+
// that it ends with `T` to confirm that it is `%T` or possibly some
373+
// variation on it.
374+
formatSpecifier.matches("%T")
372375
)
373376
}
374377
}

0 commit comments

Comments
 (0)