Skip to content

Commit d21c8d7

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Java: restrict sink to first arg of two-arg constructor call
1 parent bd47dcc commit d21c8d7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

java/ql/lib/semmle/code/java/security/PathSanitizer.qll

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,16 @@ private module TaintedArgConfig implements DataFlow::ConfigSig {
366366
src.asExpr().(MethodCall).getMethod().getName() = "source"
367367
}
368368

369-
predicate isSink(DataFlow::Node sink) { exists(Call call | sink.asExpr() = call.getAnArgument()) }
369+
predicate isSink(DataFlow::Node sink) {
370+
sink.asExpr() =
371+
any(ConstructorCall constrCall |
372+
constrCall.getConstructedType() instanceof TypeFile and
373+
constrCall.getNumArgument() = 2
374+
).getArgument(0)
375+
}
370376
}
371377

372-
/** Tracks taint flow to any argument. */
378+
/** Tracks taint flow to the parent argument of a `File` constructor. */
373379
private module TaintedArgFlow = TaintTracking::Global<TaintedArgConfig>;
374380

375381
/** Holds if `g` is a guard that checks for `..` components. */

0 commit comments

Comments
 (0)