aboutsummaryrefslogtreecommitdiff
path: root/sanitizers/src/test/java/com/example/BUILD.bazel
blob: 5d2e1ca53b0fe54d1688c78b24c6b7c7965ab1d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
load("//bazel:fuzz_target.bzl", "java_fuzz_target_test")
load("//bazel:compat.bzl", "SKIP_ON_MACOS")

java_fuzz_target_test(
    name = "ObjectInputStreamDeserialization",
    srcs = [
        "ObjectInputStreamDeserialization.java",
    ],
    expected_findings = ["java.lang.ExceptionInInitializerError"],
    target_class = "com.example.ObjectInputStreamDeserialization",
)

java_fuzz_target_test(
    name = "ReflectiveCall",
    srcs = [
        "ReflectiveCall.java",
    ],
    expected_findings = ["java.lang.ExceptionInInitializerError"],
    target_class = "com.example.ReflectiveCall",
)

java_fuzz_target_test(
    name = "LibraryLoad",
    srcs = [
        "LibraryLoad.java",
    ],
    target_class = "com.example.LibraryLoad",
    # loading of native libraries is very slow on macos,
    # especially using Java 17
    target_compatible_with = SKIP_ON_MACOS,
)

java_fuzz_target_test(
    name = "ExpressionLanguageInjection",
    srcs = [
        "ExpressionLanguageInjection.java",
        "InsecureEmailValidator.java",
    ],
    target_class = "com.example.ExpressionLanguageInjection",
    deps = [
        "@maven//:javax_el_javax_el_api",
        "@maven//:javax_validation_validation_api",
        "@maven//:javax_xml_bind_jaxb_api",
        "@maven//:org_glassfish_javax_el",
        "@maven//:org_hibernate_hibernate_validator",
    ],
)

java_fuzz_target_test(
    name = "OsCommandInjectionProcessBuilder",
    srcs = [
        "OsCommandInjectionProcessBuilder.java",
    ],
    target_class = "com.example.OsCommandInjectionProcessBuilder",
)

java_fuzz_target_test(
    name = "OsCommandInjectionRuntimeExec",
    srcs = [
        "OsCommandInjectionRuntimeExec.java",
    ],
    target_class = "com.example.OsCommandInjectionRuntimeExec",
)

java_fuzz_target_test(
    name = "LdapSearchInjection",
    srcs = [
        "LdapSearchInjection.java",
        "ldap/MockInitialContextFactory.java",
        "ldap/MockLdapContext.java",
    ],
    expected_findings = ["javax.naming.directory.InvalidSearchFilterException"],
    target_class = "com.example.LdapSearchInjection",
    deps = [
        "@maven//:com_unboundid_unboundid_ldapsdk",
    ],
)

java_fuzz_target_test(
    name = "LdapDnInjection",
    srcs = [
        "LdapDnInjection.java",
        "ldap/MockInitialContextFactory.java",
        "ldap/MockLdapContext.java",
    ],
    expected_findings = ["javax.naming.NamingException"],
    target_class = "com.example.LdapDnInjection",
    deps = [
        "@maven//:com_unboundid_unboundid_ldapsdk",
    ],
)

java_fuzz_target_test(
    name = "RegexInsecureQuoteInjection",
    srcs = ["RegexInsecureQuoteInjection.java"],
    target_class = "com.example.RegexInsecureQuoteInjection",
)

java_fuzz_target_test(
    name = "RegexCanonEqInjection",
    srcs = [
        "RegexCanonEqInjection.java",
    ],
    target_class = "com.example.RegexCanonEqInjection",
)

java_fuzz_target_test(
    name = "ClassLoaderLoadClass",
    srcs = [
        "ClassLoaderLoadClass.java",
    ],
    expected_findings = ["java.lang.ExceptionInInitializerError"],
    target_class = "com.example.ClassLoaderLoadClass",
)

java_fuzz_target_test(
    name = "RegexRoadblocks",
    srcs = ["RegexRoadblocks.java"],
    fuzzer_args = [
        # Limit the number of runs to verify that the regex roadblocks are
        # cleared quickly.
        "-runs=22000",
    ],
    target_class = "com.example.RegexRoadblocks",
)

java_fuzz_target_test(
    name = "SqlInjection",
    srcs = [
        "SqlInjection.java",
    ],
    expected_findings = [
        "com.code_intelligence.jazzer.api.FuzzerSecurityIssueHigh",
        "org.h2.jdbc.JdbcSQLSyntaxErrorException",
    ],
    target_class = "com.example.SqlInjection",
    deps = [
        "@maven//:com_h2database_h2",
    ],
)