Merge pull request #1202 from aschackmull/java/slf4j-print-array

Java: Exclude slf4j calls in PrintLnArray as it supports array formatting.
This commit is contained in:
yh-semmle
2019-04-04 20:08:20 -04:00
committed by GitHub
3 changed files with 9 additions and 1 deletions

View File

@@ -9,6 +9,7 @@
| **Query** | **Expected impact** | **Change** |
|----------------------------|------------------------|------------------------------------------------------------------|
| Implicit conversion from array to string (`java/print-array`) | Fewer false positive results | Results in slf4j logging calls are no longer reported as slf4j supports array printing. |
## Changes to QL libraries

View File

@@ -27,7 +27,11 @@ predicate arraysToStringArgument(Expr e) {
from Expr arr
where
arr.getType() instanceof Array and
implicitToStringCall(arr)
implicitToStringCall(arr) and
not exists(FormattingCall fmtcall |
// exclude slf4j formatting as it supports array formatting
fmtcall.getAnArgumentToBeFormatted() = arr and fmtcall.getSyntax().isLogger()
)
or
arr.getType().(Array).getComponentType() instanceof Array and
arraysToStringArgument(arr)

View File

@@ -85,6 +85,9 @@ class FmtSyntax extends TFmtSyntax {
or
result = "logger ({}) syntax" and this = TFmtLogger()
}
/** Holds if this syntax is logger ({}) syntax. */
predicate isLogger() { this = TFmtLogger() }
}
/**