mirror of
https://github.com/github/codeql.git
synced 2026-07-20 18:58:36 +02:00
Merge pull request #15622 from atorralba/atorralba/java/path-sanitizer-equals
Java: Expand ExactPathSanitizer to work on the argument of 'equals' too
This commit is contained in:
@@ -56,7 +56,7 @@ private predicate exactPathMatchGuard(Guard g, Expr e, boolean branch) {
|
||||
t instanceof StringsKt or
|
||||
t instanceof FilesKt
|
||||
|
|
||||
e = getVisualQualifier(ma).getUnderlyingExpr() and
|
||||
e = [getVisualQualifier(ma).getUnderlyingExpr(), getVisualArgument(ma, 0)] and
|
||||
ma.getMethod().getDeclaringType() = t and
|
||||
ma = g and
|
||||
getSourceMethod(ma.getMethod()).hasName(["equals", "equalsIgnoreCase"]) and
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
category: minorAnalysis
|
||||
---
|
||||
* The sanitizer for the path injection queries has been improved to handle more cases where `equals` is used to check an exact path match.
|
||||
@@ -25,6 +25,13 @@ public class Test {
|
||||
else
|
||||
sink(source); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
String source = (String) source();
|
||||
if ("/safe/path".equals(source))
|
||||
sink(source); // Safe
|
||||
else
|
||||
sink(source); // $ hasTaintFlow
|
||||
}
|
||||
{
|
||||
URI source = (URI) source();
|
||||
if (source.equals(new URI("http://safe/uri")))
|
||||
|
||||
@@ -25,6 +25,13 @@ class TestKt {
|
||||
else
|
||||
sink(source) // $ hasTaintFlow
|
||||
}
|
||||
run {
|
||||
val source = source() as String?
|
||||
if ("/safe/path".equals(source))
|
||||
sink(source) // Safe
|
||||
else
|
||||
sink(source) // $ hasTaintFlow
|
||||
}
|
||||
run {
|
||||
val source = source() as URI?
|
||||
if (source!!.equals(URI("http://safe/uri")))
|
||||
|
||||
Reference in New Issue
Block a user