1
+ /**
2
+ * Provides predicates and classes relating to encryption in Java.
3
+ */
4
+
1
5
import java
2
6
3
7
class SSLClass extends RefType {
@@ -85,17 +89,22 @@ private string algorithmRegex(string algorithmString) {
85
89
"((^|.*[A-Z]{2}|.*[^a-zA-Z])(" + algorithmString .toLowerCase ( ) + ")([^a-z].*|$))"
86
90
}
87
91
88
- /** Gets a blacklist of algorithms that are known to be insecure. */
89
- private string algorithmBlacklist ( ) {
92
+ /**
93
+ * Gets the name of an algorithm that is known to be insecure.
94
+ */
95
+ string getAnInsecureAlgorithmName ( ) {
90
96
result = "DES" or
91
97
result = "RC2" or
92
98
result = "RC4" or
93
99
result = "RC5" or
94
100
result = "ARCFOUR" // a variant of RC4
95
101
}
96
102
97
- // These are only bad if they're being used for encryption.
98
- private string hashAlgorithmBlacklist ( ) {
103
+ /**
104
+ * Gets the name of a hash algorithm that is insecure if it is being used for
105
+ * encryption.
106
+ */
107
+ string getAnInsecureHashAlgorithmName ( ) {
99
108
result = "SHA1" or
100
109
result = "MD5"
101
110
}
@@ -112,14 +121,19 @@ private string algorithmBlacklistString(int i) {
112
121
result = rankedAlgorithmBlacklist ( i ) + "|" + algorithmBlacklistString ( i - 1 )
113
122
}
114
123
115
- /** Gets a regex for matching strings that look like they contain a blacklisted algorithm. */
116
- string algorithmBlacklistRegex ( ) {
124
+ /**
125
+ * Gets the regular expression used for matching strings that look like they
126
+ * contain an algorithm that is known to be insecure.
127
+ */
128
+ string getInsecureAlgorithmRegex ( ) {
117
129
result =
118
130
algorithmRegex ( algorithmBlacklistString ( max ( int i | exists ( rankedAlgorithmBlacklist ( i ) ) ) ) )
119
131
}
120
132
121
- /** Gets a whitelist of algorithms that are known to be secure. */
122
- private string algorithmWhitelist ( ) {
133
+ /**
134
+ * Gets the name of an algorithm that is known to be secure.
135
+ */
136
+ string getASecureAlgorithmName ( ) {
123
137
result = "RSA" or
124
138
result = "SHA256" or
125
139
result = "SHA512" or
@@ -138,12 +152,43 @@ private string algorithmWhitelistString(int i) {
138
152
result = rankedAlgorithmWhitelist ( i ) + "|" + algorithmWhitelistString ( i - 1 )
139
153
}
140
154
141
- /** Gets a regex for matching strings that look like they contain a whitelisted algorithm. */
142
- string algorithmWhitelistRegex ( ) {
155
+ /**
156
+ * Gets a regular expression for matching strings that look like they
157
+ * contain an algorithm that is known to be secure.
158
+ */
159
+ string getSecureAlgorithmRegex ( ) {
143
160
result =
144
161
algorithmRegex ( algorithmWhitelistString ( max ( int i | exists ( rankedAlgorithmWhitelist ( i ) ) ) ) )
145
162
}
146
163
164
+ /**
165
+ * DEPRECATED: Terminology has been updated. Use `getAnInsecureAlgorithmName()`
166
+ * instead.
167
+ */
168
+ deprecated string algorithmBlacklist ( ) { result = getAnInsecureAlgorithmName ( ) }
169
+
170
+ /**
171
+ * DEPRECATED: Terminology has been updated. Use
172
+ * `getAnInsecureHashAlgorithmName()` instead.
173
+ */
174
+ deprecated string hashAlgorithmBlacklist ( ) { result = getAnInsecureHashAlgorithmName ( ) }
175
+
176
+ /**
177
+ * DEPRECATED: Terminology has been updated. Use `getInsecureAlgorithmRegex()` instead.
178
+ */
179
+ deprecated string algorithmBlacklistRegex ( ) { result = getInsecureAlgorithmRegex ( ) }
180
+
181
+ /**
182
+ * DEPRECATED: Terminology has been updated. Use `getASecureAlgorithmName()`
183
+ * instead.
184
+ */
185
+ deprecated string algorithmWhitelist ( ) { result = getASecureAlgorithmName ( ) }
186
+
187
+ /**
188
+ * DEPRECATED: Terminology has been updated. Use `getSecureAlgorithmRegex()` instead.
189
+ */
190
+ deprecated string algorithmWhitelistRegex ( ) { result = getSecureAlgorithmRegex ( ) }
191
+
147
192
/**
148
193
* Any use of a cryptographic element that specifies an encryption
149
194
* algorithm. For example, methods returning ciphers, decryption methods,
0 commit comments