@@ -279,23 +279,18 @@ private module CryptoJS {
279
279
/**
280
280
* Matches `CryptoJS.<algorithmName>` and `require("crypto-js/<algorithmName>")`
281
281
*/
282
- private DataFlow :: SourceNode getAlgorithmNode ( CryptographicAlgorithm algorithm ) {
282
+ private API :: Node getAlgorithmNode ( CryptographicAlgorithm algorithm ) {
283
283
exists ( string algorithmName | algorithm .matchesName ( algorithmName ) |
284
- exists ( DataFlow :: SourceNode mod | mod = DataFlow :: moduleImport ( "crypto-js" ) |
285
- result = mod .getAPropertyRead ( algorithmName ) or
286
- result = mod .getAPropertyRead ( "Hmac" + algorithmName ) // they prefix Hmac
284
+ exists ( API :: Node mod | mod = API :: moduleImport ( "crypto-js" ) |
285
+ result = mod .getMember ( algorithmName ) or
286
+ result = mod .getMember ( "Hmac" + algorithmName ) // they prefix Hmac
287
287
)
288
288
or
289
- exists ( DataFlow:: SourceNode mod |
290
- mod = DataFlow:: moduleImport ( "crypto-js/" + algorithmName ) and
291
- result = mod
292
- )
289
+ result = API:: moduleImport ( "crypto-js/" + algorithmName )
293
290
)
294
291
}
295
292
296
- private DataFlow:: CallNode getEncryptionApplication (
297
- DataFlow:: Node input , CryptographicAlgorithm algorithm
298
- ) {
293
+ private API:: CallNode getEncryptionApplication ( API:: Node input , CryptographicAlgorithm algorithm ) {
299
294
/*
300
295
* ```
301
296
* var CryptoJS = require("crypto-js");
@@ -309,13 +304,11 @@ private module CryptoJS {
309
304
* Also matches where `CryptoJS.<algorithmName>` has been replaced by `require("crypto-js/<algorithmName>")`
310
305
*/
311
306
312
- result = getAlgorithmNode ( algorithm ) .getAMemberCall ( "encrypt" ) and
313
- input = result .getArgument ( 0 )
307
+ result = getAlgorithmNode ( algorithm ) .getMember ( "encrypt" ) . getACall ( ) and
308
+ input = result .getParameter ( 0 )
314
309
}
315
310
316
- private DataFlow:: CallNode getDirectApplication (
317
- DataFlow:: Node input , CryptographicAlgorithm algorithm
318
- ) {
311
+ private API:: CallNode getDirectApplication ( API:: Node input , CryptographicAlgorithm algorithm ) {
319
312
/*
320
313
* ```
321
314
* var CryptoJS = require("crypto-js");
@@ -331,28 +324,27 @@ private module CryptoJS {
331
324
*/
332
325
333
326
result = getAlgorithmNode ( algorithm ) .getACall ( ) and
334
- input = result .getArgument ( 0 )
327
+ input = result .getParameter ( 0 )
335
328
}
336
329
337
- private class Apply extends CryptographicOperation:: Range , DataFlow :: CallNode {
338
- DataFlow :: Node input ;
330
+ private class Apply extends CryptographicOperation:: Range instanceof API :: CallNode {
331
+ API :: Node input ;
339
332
CryptographicAlgorithm algorithm ; // non-functional
340
333
341
334
Apply ( ) {
342
335
this = getEncryptionApplication ( input , algorithm ) or
343
336
this = getDirectApplication ( input , algorithm )
344
337
}
345
338
346
- override DataFlow:: Node getAnInput ( ) { result = input }
339
+ override DataFlow:: Node getAnInput ( ) { result = input . asSink ( ) }
347
340
348
341
override CryptographicAlgorithm getAlgorithm ( ) { result = algorithm }
349
342
350
343
// e.g. CryptoJS.AES.encrypt("msg", "key", { mode: CryptoJS.mode.<modeString> })
351
344
private BlockMode getExplicitBlockMode ( ) {
352
- exists ( DataFlow:: ObjectLiteralNode o , DataFlow:: SourceNode modeNode , string modeString |
353
- modeNode = API:: moduleImport ( "crypto-js" ) .getMember ( "mode" ) .getMember ( modeString ) .asSource ( ) and
354
- o .flowsTo ( this .getArgument ( 2 ) ) and
355
- modeNode = o .getAPropertySource ( "mode" )
345
+ exists ( string modeString |
346
+ API:: moduleImport ( "crypto-js" ) .getMember ( "mode" ) .getMember ( modeString ) .asSource ( ) =
347
+ super .getParameter ( 2 ) .getMember ( "mode" ) .asSink ( )
356
348
|
357
349
result .matchesString ( modeString )
358
350
)
@@ -372,15 +364,13 @@ private module CryptoJS {
372
364
373
365
private class Key extends CryptographicKey {
374
366
Key ( ) {
375
- exists ( DataFlow:: SourceNode e , CryptographicAlgorithm algorithm |
376
- e = getAlgorithmNode ( algorithm )
377
- |
367
+ exists ( API:: Node e , CryptographicAlgorithm algorithm | e = getAlgorithmNode ( algorithm ) |
378
368
exists ( string name |
379
369
name = "encrypt" or
380
370
name = "decrypt"
381
371
|
382
372
algorithm instanceof EncryptionAlgorithm and
383
- this = e .getAMemberCall ( name ) .getArgument ( 1 )
373
+ this = e .getMember ( name ) . getACall ( ) .getArgument ( 1 )
384
374
)
385
375
or
386
376
algorithm instanceof HashingAlgorithm and
0 commit comments