@@ -40,7 +40,6 @@ private module AlgorithmNames {
40
40
name = "RIPEMD" or
41
41
name = "RIPEMD128" or
42
42
name = "RIPEMD256" or
43
- name = "RIPEMD160" or
44
43
name = "RIPEMD320" or
45
44
name = "SHA0" or
46
45
name = "SHA1"
@@ -122,7 +121,8 @@ abstract class CryptographicAlgorithm extends TCryptographicAlgorithm {
122
121
*/
123
122
bindingset [ name]
124
123
predicate matchesName ( string name ) {
125
- name .toUpperCase ( ) .regexpReplaceAll ( "[-_ ]" , "" ) .regexpMatch ( ".*" + getName ( ) + ".*" )
124
+ exists ( name .regexpReplaceAll ( "[-_]" , "" ) .regexpFind ( "(?i)\\Q" + getName ( ) + "\\E" , _, _) )
125
+ // name.toUpperCase().regexpReplaceAll("[-_ ]", "").regexpMatch(".*" + getName() + ".*")
126
126
}
127
127
128
128
/**
@@ -188,6 +188,10 @@ abstract class CryptographicOperation extends Expr {
188
188
abstract CryptographicAlgorithm getAlgorithm ( ) ;
189
189
}
190
190
191
+ /**
192
+ * Below are the cryptographic functions that have been implemented so far for this library.
193
+ * Class that checks for use of Md5 package.
194
+ */
191
195
class Md5 extends CryptographicOperation {
192
196
Expr input ;
193
197
CryptographicAlgorithm algorithm ;
@@ -207,16 +211,20 @@ class Md5 extends CryptographicOperation {
207
211
override CryptographicAlgorithm getAlgorithm ( ) { result = algorithm }
208
212
}
209
213
214
+ /**
215
+ * Class that checks for use of Des package.
216
+ */
210
217
class Des extends CryptographicOperation {
211
218
Expr input ;
212
219
CryptographicAlgorithm algorithm ;
213
- CallExpr call ;
214
220
SelectorExpr sel ;
221
+ CallExpr call ;
215
222
216
223
Des ( ) {
217
224
this = call and
218
- algorithm .matchesName ( call . getCalleeName ( ) ) and
225
+ algorithm .matchesName ( sel . getBase ( ) . toString ( ) ) and
219
226
algorithm .matchesName ( "DES" ) and
227
+ sel .getSelector ( ) .toString ( ) = call .getCalleeName ( ) .toString ( ) and
220
228
call .getArgument ( 0 ) = input
221
229
}
222
230
0 commit comments