Skip to content

Commit 8eeef83

Browse files
committed
chore: clean up the file path traversal example tests
1 parent b68be37 commit 8eeef83

File tree

3 files changed

+2
-19
lines changed

3 files changed

+2
-19
lines changed

sanitizers/src/test/java/com/example/AbsoluteFilePathTraversal.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.example;
1818

19-
import com.code_intelligence.jazzer.mutation.annotation.DoubleInRange;
2019
import com.code_intelligence.jazzer.mutation.annotation.NotNull;
2120
import com.code_intelligence.jazzer.mutation.annotation.WithUtf8Length;
2221
import java.io.BufferedReader;
@@ -32,21 +31,14 @@ public class AbsoluteFilePathTraversal {
3231
System.setProperty("jazzer.file_path_traversal_target", "/custom/path/jazzer-traversal");
3332
}
3433

35-
public static void fuzzerTestOneInput(
36-
@WithUtf8Length(max = 100) @NotNull String pathFromFuzzer,
37-
@NotNull @DoubleInRange(min = 0.0, max = 1.0) Double fixedPathProbability) {
38-
// Slow down the fuzzer a bit, otherwise it finds file path traversal way too quickly!
39-
String path = fixedPathProbability < 0.95 ? "/a/b/c/fixed-path" : pathFromFuzzer;
40-
34+
public static void fuzzerTestOneInput(@WithUtf8Length(max = 100) @NotNull String path) {
4135
try {
4236
Path p = Paths.get(path);
4337
try (BufferedReader r = Files.newBufferedReader(p, StandardCharsets.UTF_8)) {
4438
r.read();
4539
} catch (IOException ignored) {
46-
// swallow
4740
}
4841
} catch (InvalidPathException ignored) {
49-
// swallow
5042
}
5143
}
5244
}

sanitizers/src/test/java/com/example/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ java_fuzz_target_test(
6767
"com.code_intelligence.jazzer.api.FuzzerSecurityIssueCritical",
6868
],
6969
target_class = "com.example.AbsoluteFilePathTraversal",
70-
#not clear why reproducer doesn't work TODO -- fix this
7170
verify_crash_reproducer = False,
7271
deps = [
7372
"//src/main/java/com/code_intelligence/jazzer/mutation/annotation",
@@ -83,7 +82,6 @@ java_fuzz_target_test(
8382
"com.code_intelligence.jazzer.api.FuzzerSecurityIssueCritical",
8483
],
8584
target_class = "com.example.FilePathTraversal",
86-
#not clear why reproducer doesn't work TODO -- fix this
8785
verify_crash_reproducer = False,
8886
deps = [
8987
"//src/main/java/com/code_intelligence/jazzer/mutation/annotation",

sanitizers/src/test/java/com/example/FilePathTraversal.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.example;
1818

19-
import com.code_intelligence.jazzer.mutation.annotation.DoubleInRange;
2019
import com.code_intelligence.jazzer.mutation.annotation.NotNull;
2120
import com.code_intelligence.jazzer.mutation.annotation.WithUtf8Length;
2221
import java.io.BufferedReader;
@@ -29,20 +28,14 @@
2928

3029
public class FilePathTraversal {
3130

32-
public static void fuzzerTestOneInput(
33-
@WithUtf8Length(max = 100) @NotNull String pathFromFuzzer,
34-
@NotNull @DoubleInRange(min = 0.0, max = 1.0) Double fixedPathProbability) {
35-
// Slow down the fuzzer a bit, otherwise it finds file path traversal way too quickly!
36-
String path = fixedPathProbability < 0.95 ? "/a/b/c/fixed-path" : pathFromFuzzer;
31+
public static void fuzzerTestOneInput(@WithUtf8Length(max = 100) @NotNull String path) {
3732
try {
3833
Path p = Paths.get(path);
3934
try (BufferedReader r = Files.newBufferedReader(p, StandardCharsets.UTF_8)) {
4035
r.read();
4136
} catch (IOException ignored) {
42-
// swallow
4337
}
4438
} catch (InvalidPathException ignored) {
45-
// swallow
4639
}
4740
}
4841
}

0 commit comments

Comments
 (0)