Skip to content

Commit 9bb5fe8

Browse files
Jami CogswellJami Cogswell
Jami Cogswell
authored and
Jami Cogswell
committedFeb 17, 2025·
Java: address review comments
1 parent 61a184c commit 9bb5fe8

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed
 

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

+7-18
Original file line numberDiff line numberDiff line change
@@ -347,16 +347,6 @@ private class FileGetNameSanitizer extends PathInjectionSanitizer {
347347
}
348348
}
349349

350-
/** Holds if `expr` may be null. */
351-
private predicate maybeNull(Expr expr) {
352-
exists(DataFlow::Node src, DataFlow::Node sink |
353-
src.asExpr() = nullExpr() and
354-
sink.asExpr() = expr
355-
|
356-
DataFlow::localFlow(src, sink)
357-
)
358-
}
359-
360350
/** Holds if `g` is a guard that checks for `..` components. */
361351
private predicate pathTraversalGuard(Guard g, Expr e, boolean branch) {
362352
// Local taint-flow is used here to handle cases where the validated expression comes from the
@@ -383,14 +373,13 @@ private class FileConstructorChildArgumentStep extends AdditionalTaintStep {
383373
exists(ConstructorCall constrCall |
384374
constrCall.getConstructedType() instanceof TypeFile and
385375
n1.asExpr() = constrCall.getArgument(1) and
386-
n2.asExpr() = constrCall and
387-
(
388-
not n1 = DataFlow::BarrierGuard<pathTraversalGuard/3>::getABarrierNode() and
389-
not n1 = ValidationMethod<pathTraversalGuard/3>::getAValidatedNode() and
390-
not TaintTracking::localExprTaint(any(PathNormalizeSanitizer p), n1.asExpr())
391-
or
392-
maybeNull(constrCall.getArgument(0))
393-
)
376+
n2.asExpr() = constrCall
377+
|
378+
not n1 = DataFlow::BarrierGuard<pathTraversalGuard/3>::getABarrierNode() and
379+
not n1 = ValidationMethod<pathTraversalGuard/3>::getAValidatedNode() and
380+
not TaintTracking::localExprTaint(any(PathNormalizeSanitizer p), n1.asExpr())
381+
or
382+
DataFlow::localExprFlow(nullExpr(), constrCall.getArgument(0))
394383
)
395384
}
396385
}

0 commit comments

Comments
 (0)
Please sign in to comment.