|
25 | 25 |
|
26 | 26 | public interface VulnerabilityType { |
27 | 27 |
|
28 | | - BitSet DB_EXCLUDED = new BitSet(SourceTypes.SQL_TABLE); |
29 | | - |
30 | 28 | VulnerabilityType WEAK_CIPHER = |
31 | | - type(VulnerabilityTypes.WEAK_CIPHER).excludedSources(DB_EXCLUDED).build(); |
| 29 | + type(VulnerabilityTypes.WEAK_CIPHER).excludedSources(Builder.DB_EXCLUDED).build(); |
32 | 30 | VulnerabilityType WEAK_HASH = |
33 | | - type(VulnerabilityTypes.WEAK_HASH).excludedSources(DB_EXCLUDED).build(); |
| 31 | + type(VulnerabilityTypes.WEAK_HASH).excludedSources(Builder.DB_EXCLUDED).build(); |
34 | 32 | VulnerabilityType INSECURE_COOKIE = |
35 | 33 | type(VulnerabilityTypes.INSECURE_COOKIE) |
36 | 34 | .hash(VulnerabilityType::evidenceHash) |
37 | | - .excludedSources(DB_EXCLUDED) |
| 35 | + .excludedSources(Builder.DB_EXCLUDED) |
38 | 36 | .build(); |
39 | 37 | VulnerabilityType NO_HTTPONLY_COOKIE = |
40 | 38 | type(VulnerabilityTypes.NO_HTTPONLY_COOKIE) |
41 | 39 | .hash(VulnerabilityType::evidenceHash) |
42 | | - .excludedSources(DB_EXCLUDED) |
| 40 | + .excludedSources(Builder.DB_EXCLUDED) |
43 | 41 | .build(); |
44 | 42 | VulnerabilityType HSTS_HEADER_MISSING = |
45 | 43 | type(VulnerabilityTypes.HSTS_HEADER_MISSING) |
46 | 44 | .hash(VulnerabilityType::serviceHash) |
47 | | - .excludedSources(DB_EXCLUDED) |
| 45 | + .excludedSources(Builder.DB_EXCLUDED) |
48 | 46 | .build(); |
49 | 47 | VulnerabilityType XCONTENTTYPE_HEADER_MISSING = |
50 | 48 | type(VulnerabilityTypes.XCONTENTTYPE_HEADER_MISSING) |
51 | 49 | .hash(VulnerabilityType::serviceHash) |
52 | | - .excludedSources(DB_EXCLUDED) |
| 50 | + .excludedSources(Builder.DB_EXCLUDED) |
53 | 51 | .build(); |
54 | 52 | VulnerabilityType NO_SAMESITE_COOKIE = |
55 | 53 | type(VulnerabilityTypes.NO_SAMESITE_COOKIE) |
56 | 54 | .hash(VulnerabilityType::evidenceHash) |
57 | | - .excludedSources(DB_EXCLUDED) |
| 55 | + .excludedSources(Builder.DB_EXCLUDED) |
58 | 56 | .build(); |
59 | 57 |
|
60 | 58 | VulnerabilityType SQL_INJECTION = |
61 | 59 | type(VulnerabilityTypes.SQL_INJECTION).mark(SQL_INJECTION_MARK).build(); |
62 | 60 | VulnerabilityType COMMAND_INJECTION = |
63 | 61 | type(VulnerabilityTypes.COMMAND_INJECTION) |
64 | 62 | .mark(COMMAND_INJECTION_MARK) |
65 | | - .excludedSources(DB_EXCLUDED) |
| 63 | + .excludedSources(Builder.DB_EXCLUDED) |
66 | 64 | .build(); |
67 | 65 | VulnerabilityType PATH_TRAVERSAL = |
68 | 66 | type(VulnerabilityTypes.PATH_TRAVERSAL) |
69 | 67 | .separator(File.separatorChar) |
70 | 68 | .mark(PATH_TRAVERSAL_MARK) |
71 | | - .excludedSources(DB_EXCLUDED) |
| 69 | + .excludedSources(Builder.DB_EXCLUDED) |
72 | 70 | .build(); |
73 | 71 | VulnerabilityType LDAP_INJECTION = |
74 | 72 | type(VulnerabilityTypes.LDAP_INJECTION) |
75 | 73 | .mark(LDAP_INJECTION_MARK) |
76 | | - .excludedSources(DB_EXCLUDED) |
| 74 | + .excludedSources(Builder.DB_EXCLUDED) |
77 | 75 | .build(); |
78 | 76 | VulnerabilityType SSRF = |
79 | | - type(VulnerabilityTypes.SSRF).mark(SSRF_MARK).excludedSources(DB_EXCLUDED).build(); |
| 77 | + type(VulnerabilityTypes.SSRF).mark(SSRF_MARK).excludedSources(Builder.DB_EXCLUDED).build(); |
80 | 78 | VulnerabilityType UNVALIDATED_REDIRECT = |
81 | 79 | type(VulnerabilityTypes.UNVALIDATED_REDIRECT) |
82 | 80 | .mark(UNVALIDATED_REDIRECT_MARK) |
83 | | - .excludedSources(DB_EXCLUDED) |
| 81 | + .excludedSources(Builder.DB_EXCLUDED) |
84 | 82 | .build(); |
85 | 83 | VulnerabilityType WEAK_RANDOMNESS = |
86 | | - type(VulnerabilityTypes.WEAK_RANDOMNESS).excludedSources(DB_EXCLUDED).build(); |
| 84 | + type(VulnerabilityTypes.WEAK_RANDOMNESS).excludedSources(Builder.DB_EXCLUDED).build(); |
87 | 85 |
|
88 | 86 | VulnerabilityType XPATH_INJECTION = |
89 | 87 | type(VulnerabilityTypes.XPATH_INJECTION) |
90 | 88 | .mark(XPATH_INJECTION_MARK) |
91 | | - .excludedSources(DB_EXCLUDED) |
| 89 | + .excludedSources(Builder.DB_EXCLUDED) |
92 | 90 | .build(); |
93 | 91 |
|
94 | 92 | VulnerabilityType TRUST_BOUNDARY_VIOLATION = |
95 | 93 | type(VulnerabilityTypes.TRUST_BOUNDARY_VIOLATION) |
96 | 94 | .mark(TRUST_BOUNDARY_VIOLATION_MARK) |
97 | | - .excludedSources(DB_EXCLUDED) |
| 95 | + .excludedSources(Builder.DB_EXCLUDED) |
98 | 96 | .build(); |
99 | 97 |
|
100 | 98 | VulnerabilityType XSS = type(VulnerabilityTypes.XSS).mark(XSS_MARK).build(); |
101 | 99 |
|
102 | 100 | VulnerabilityType HEADER_INJECTION = |
103 | 101 | type(VulnerabilityTypes.HEADER_INJECTION) |
104 | 102 | .mark(HEADER_INJECTION_MARK) |
105 | | - .excludedSources(DB_EXCLUDED) |
| 103 | + .excludedSources(Builder.DB_EXCLUDED) |
106 | 104 | .build(); |
107 | 105 |
|
108 | 106 | VulnerabilityType STACKTRACE_LEAK = |
109 | | - type(VulnerabilityTypes.STACKTRACE_LEAK).excludedSources(DB_EXCLUDED).build(); |
| 107 | + type(VulnerabilityTypes.STACKTRACE_LEAK).excludedSources(Builder.DB_EXCLUDED).build(); |
110 | 108 |
|
111 | 109 | VulnerabilityType VERB_TAMPERING = |
112 | | - type(VulnerabilityTypes.VERB_TAMPERING).excludedSources(DB_EXCLUDED).build(); |
| 110 | + type(VulnerabilityTypes.VERB_TAMPERING).excludedSources(Builder.DB_EXCLUDED).build(); |
113 | 111 |
|
114 | 112 | VulnerabilityType ADMIN_CONSOLE_ACTIVE = |
115 | 113 | type(VulnerabilityTypes.ADMIN_CONSOLE_ACTIVE) |
116 | 114 | .deduplicable(false) |
117 | 115 | .hash(VulnerabilityType::serviceHash) |
118 | | - .excludedSources(DB_EXCLUDED) |
| 116 | + .excludedSources(Builder.DB_EXCLUDED) |
119 | 117 | .build(); |
120 | 118 |
|
121 | 119 | VulnerabilityType DEFAULT_HTML_ESCAPE_INVALID = |
122 | | - type(VulnerabilityTypes.DEFAULT_HTML_ESCAPE_INVALID).excludedSources(DB_EXCLUDED).build(); |
| 120 | + type(VulnerabilityTypes.DEFAULT_HTML_ESCAPE_INVALID) |
| 121 | + .excludedSources(Builder.DB_EXCLUDED) |
| 122 | + .build(); |
123 | 123 |
|
124 | 124 | VulnerabilityType SESSION_TIMEOUT = |
125 | | - type(VulnerabilityTypes.SESSION_TIMEOUT).excludedSources(DB_EXCLUDED).build(); |
| 125 | + type(VulnerabilityTypes.SESSION_TIMEOUT).excludedSources(Builder.DB_EXCLUDED).build(); |
126 | 126 |
|
127 | 127 | VulnerabilityType DIRECTORY_LISTING_LEAK = |
128 | | - type(VulnerabilityTypes.DIRECTORY_LISTING_LEAK).excludedSources(DB_EXCLUDED).build(); |
| 128 | + type(VulnerabilityTypes.DIRECTORY_LISTING_LEAK).excludedSources(Builder.DB_EXCLUDED).build(); |
129 | 129 | VulnerabilityType INSECURE_JSP_LAYOUT = |
130 | | - type(VulnerabilityTypes.INSECURE_JSP_LAYOUT).excludedSources(DB_EXCLUDED).build(); |
| 130 | + type(VulnerabilityTypes.INSECURE_JSP_LAYOUT).excludedSources(Builder.DB_EXCLUDED).build(); |
131 | 131 |
|
132 | 132 | VulnerabilityType HARDCODED_SECRET = |
133 | | - type(VulnerabilityTypes.HARDCODED_SECRET).excludedSources(DB_EXCLUDED).build(); |
| 133 | + type(VulnerabilityTypes.HARDCODED_SECRET).excludedSources(Builder.DB_EXCLUDED).build(); |
134 | 134 |
|
135 | 135 | VulnerabilityType INSECURE_AUTH_PROTOCOL = |
136 | 136 | type(VulnerabilityTypes.INSECURE_AUTH_PROTOCOL) |
137 | 137 | .hash(VulnerabilityType::evidenceHash) |
138 | | - .excludedSources(DB_EXCLUDED) |
| 138 | + .excludedSources(Builder.DB_EXCLUDED) |
139 | 139 | .build(); |
140 | 140 |
|
141 | 141 | VulnerabilityType REFLECTION_INJECTION = |
142 | 142 | type(VulnerabilityTypes.REFLECTION_INJECTION) |
143 | 143 | .mark(REFLECTION_INJECTION_MARK) |
144 | | - .excludedSources(DB_EXCLUDED) |
| 144 | + .excludedSources(Builder.DB_EXCLUDED) |
145 | 145 | .build(); |
146 | 146 |
|
147 | 147 | VulnerabilityType SESSION_REWRITING = |
148 | 148 | type(VulnerabilityTypes.SESSION_REWRITING) |
149 | 149 | .deduplicable(false) |
150 | 150 | .hash(VulnerabilityType::serviceHash) |
151 | | - .excludedSources(DB_EXCLUDED) |
| 151 | + .excludedSources(Builder.DB_EXCLUDED) |
152 | 152 | .build(); |
153 | 153 |
|
154 | 154 | VulnerabilityType DEFAULT_APP_DEPLOYED = |
155 | 155 | type(VulnerabilityTypes.DEFAULT_APP_DEPLOYED) |
156 | 156 | .deduplicable(false) |
157 | 157 | .hash(VulnerabilityType::serviceHash) |
158 | | - .excludedSources(DB_EXCLUDED) |
| 158 | + .excludedSources(Builder.DB_EXCLUDED) |
159 | 159 | .build(); |
160 | 160 |
|
161 | 161 | VulnerabilityType UNTRUSTED_DESERIALIZATION = |
162 | 162 | type(VulnerabilityTypes.UNTRUSTED_DESERIALIZATION) |
163 | 163 | .mark(UNTRUSTED_DESERIALIZATION_MARK) |
164 | | - .excludedSources(DB_EXCLUDED) |
| 164 | + .excludedSources(Builder.DB_EXCLUDED) |
165 | 165 | .build(); |
166 | 166 |
|
167 | 167 | /* All vulnerability types that have a mark. Should be updated if new vulnerabilityType with mark is added */ |
@@ -271,6 +271,13 @@ public String getName() { |
271 | 271 | } |
272 | 272 |
|
273 | 273 | class Builder { |
| 274 | + private static final BitSet DB_EXCLUDED; |
| 275 | + |
| 276 | + static { |
| 277 | + DB_EXCLUDED = new BitSet(SourceTypes.STRINGS.length + 1); |
| 278 | + DB_EXCLUDED.set(SourceTypes.SQL_TABLE); |
| 279 | + } |
| 280 | + |
274 | 281 | private final byte type; |
275 | 282 | private char separator = ' '; |
276 | 283 | private int mark = NOT_MARKED; |
|
0 commit comments