Skip to content

Commit e8724ab

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Java: sanitize constructor call instead and update test cases
1 parent 4a4585a commit e8724ab

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ private class FileConstructorSanitizer extends PathInjectionSanitizer {
388388
arg = ValidationMethod<pathTraversalGuard/3>::getAValidatedNode().asExpr() or
389389
TaintTracking::localExprTaint(any(PathNormalizeSanitizer p), arg)
390390
) and
391-
this.asExpr() = arg
391+
this.asExpr() = constrCall
392392
)
393393
}
394394
}

java/ql/test/library-tests/pathsanitizer/Test.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ public void fileConstructorSanitizer() throws Exception {
483483
if (!source.contains("..")) {
484484
File f2 = new File(f1, source);
485485
sink(f2); // Safe
486-
sink(source); // $ MISSING: hasTaintFlow
486+
sink(source); // $ hasTaintFlow
487487
} else {
488488
File f3 = new File(f1, source);
489489
sink(f3); // $ hasTaintFlow
@@ -497,7 +497,7 @@ public void fileConstructorSanitizer() throws Exception {
497497
// `f2` is unsafe if `f1` is tainted
498498
File f2 = new File(f1Tainted, source);
499499
sink(f2); // $ hasTaintFlow
500-
sink(source); // $ MISSING: hasTaintFlow
500+
sink(source); // $ hasTaintFlow
501501
} else {
502502
File f3 = new File(f1Tainted, source);
503503
sink(f3); // $ hasTaintFlow
@@ -524,7 +524,7 @@ public void fileConstructorSanitizer() throws Exception {
524524
if (source.indexOf("..") == -1) {
525525
File f2 = new File(f1, source);
526526
sink(f2); // Safe
527-
sink(source); // $ MISSING: hasTaintFlow
527+
sink(source); // $ hasTaintFlow
528528
} else {
529529
File f3 = new File(f1, source);
530530
sink(f3); // $ hasTaintFlow
@@ -541,7 +541,7 @@ public void fileConstructorSanitizer() throws Exception {
541541
} else {
542542
File f3 = new File(f1, source);
543543
sink(f3); // Safe
544-
sink(source); // $ MISSING: hasTaintFlow
544+
sink(source); // $ hasTaintFlow
545545
}
546546
}
547547
{
@@ -550,7 +550,7 @@ public void fileConstructorSanitizer() throws Exception {
550550
if (source.lastIndexOf("..") == -1) {
551551
File f2 = new File(f1, source);
552552
sink(f2); // Safe
553-
sink(source); // $ MISSING: hasTaintFlow
553+
sink(source); // $ hasTaintFlow
554554
} else {
555555
File f3 = new File(f1, source);
556556
sink(f3); // $ hasTaintFlow
@@ -564,7 +564,7 @@ public void fileConstructorSanitizer() throws Exception {
564564
fileConstructorValidation(source);
565565
File f2 = new File(f1, source);
566566
sink(f2); // Safe
567-
sink(source); // $ MISSING: hasTaintFlow
567+
sink(source); // $ hasTaintFlow
568568
}
569569
{
570570
String source = (String) source();
@@ -575,7 +575,7 @@ public void fileConstructorSanitizer() throws Exception {
575575
} else {
576576
File f2 = new File(f1, source);
577577
sink(f2); // Safe
578-
sink(source); // $ MISSING: hasTaintFlow
578+
sink(source); // $ hasTaintFlow
579579
}
580580
}
581581
// PathNormalizeSanitizer
@@ -586,7 +586,7 @@ public void fileConstructorSanitizer() throws Exception {
586586
File f2 = new File(f1, normalized);
587587
sink(f2); // Safe
588588
sink(source); // $ hasTaintFlow
589-
sink(normalized); // $ MISSING: hasTaintFlow
589+
sink(normalized); // $ hasTaintFlow
590590
}
591591
{
592592
File source = (File) source();
@@ -595,7 +595,7 @@ public void fileConstructorSanitizer() throws Exception {
595595
File f2 = new File(f1, normalized);
596596
sink(f2); // Safe
597597
sink(source); // $ hasTaintFlow
598-
sink(normalized); // $ MISSING: hasTaintFlow
598+
sink(normalized); // $ hasTaintFlow
599599
}
600600
{
601601
String source = (String) source();
@@ -604,7 +604,7 @@ public void fileConstructorSanitizer() throws Exception {
604604
File f2 = new File(f1, normalized);
605605
sink(f2); // Safe
606606
sink(source); // $ hasTaintFlow
607-
sink(normalized); // $ MISSING: hasTaintFlow
607+
sink(normalized); // $ hasTaintFlow
608608
}
609609
}
610610
}

0 commit comments

Comments
 (0)