File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
javascript/ql/lib/semmle/javascript/frameworks Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -276,7 +276,7 @@ private module NodeJSCrypto {
276
276
*/
277
277
private module CryptoJS {
278
278
private class InstantiatedAlgorithm extends DataFlow:: CallNode {
279
- CryptographicAlgorithm algorithm ; // non-functional
279
+ private string algorithmName ;
280
280
281
281
InstantiatedAlgorithm ( ) {
282
282
/*
@@ -295,11 +295,25 @@ private module CryptoJS {
295
295
mod = DataFlow:: moduleImport ( "crypto-js" ) and
296
296
propRead = mod .getAPropertyRead ( "algo" ) .getAPropertyRead ( ) and
297
297
this = propRead .getAMemberCall ( "create" ) and
298
- not isStrongPasswordHashingAlgorithm ( propRead .getPropertyName ( ) )
298
+ algorithmName = propRead .getPropertyName ( ) and
299
+ not isStrongPasswordHashingAlgorithm ( algorithmName )
299
300
)
300
301
}
301
302
302
- CryptographicAlgorithm getAlgorithm ( ) { result = algorithm }
303
+ CryptographicAlgorithm getAlgorithm ( ) { result .matchesName ( algorithmName ) }
304
+
305
+ private BlockMode getExplicitBlockMode ( ) { result .matchesString ( algorithmName ) }
306
+
307
+ BlockMode getBlockMode ( ) {
308
+ isBlockEncryptionAlgorithm ( this .getAlgorithm ( ) ) and
309
+ (
310
+ if exists ( this .getExplicitBlockMode ( ) )
311
+ then result = this .getExplicitBlockMode ( )
312
+ else
313
+ // CBC is the default if not explicitly specified
314
+ result = "CBC"
315
+ )
316
+ }
303
317
}
304
318
305
319
You can’t perform that action at this time.
0 commit comments