@@ -378,10 +378,9 @@ private module CryptoJS {
378378 * A model of the TweetNaCl library.
379379 */
380380private module TweetNaCl {
381- private class Apply extends CryptographicOperation {
381+ private class Apply extends CryptographicOperation instanceof MethodCallExpr {
382382 Expr input ;
383383 CryptographicAlgorithm algorithm ;
384- MethodCallExpr mce ;
385384
386385 Apply ( ) {
387386 /*
@@ -395,15 +394,14 @@ private module TweetNaCl {
395394 * Also matches the "hash" method name, and the "nacl-fast" module.
396395 */
397396
398- this = mce and
399397 exists ( DataFlow:: SourceNode mod , string name |
400398 name = "hash" and algorithm .matchesName ( "SHA512" )
401399 or
402400 name = "sign" and algorithm .matchesName ( "ed25519" )
403401 |
404402 ( mod = DataFlow:: moduleImport ( "nacl" ) or mod = DataFlow:: moduleImport ( "nacl-fast" ) ) and
405- mce = mod .getAMemberCall ( name ) .asExpr ( ) and
406- mce .getArgument ( 0 ) = input
403+ this = mod .getAMemberCall ( name ) .asExpr ( ) and
404+ super .getArgument ( 0 ) = input
407405 )
408406 }
409407
@@ -440,10 +438,9 @@ private module HashJs {
440438 )
441439 }
442440
443- private class Apply extends CryptographicOperation {
441+ private class Apply extends CryptographicOperation instanceof MethodCallExpr {
444442 Expr input ;
445443 CryptographicAlgorithm algorithm ; // non-functional
446- MethodCallExpr mce ;
447444
448445 Apply ( ) {
449446 /*
@@ -459,9 +456,8 @@ private module HashJs {
459456 * Also matches where `hash.<algorithmName>()` has been replaced by a more specific require a la `require("hash.js/lib/hash/sha/512")`
460457 */
461458
462- this = mce and
463- mce = getAlgorithmExpr ( algorithm ) .getAMemberCall ( "update" ) .asExpr ( ) and
464- input = mce .getArgument ( 0 )
459+ this = getAlgorithmExpr ( algorithm ) .getAMemberCall ( "update" ) .asExpr ( ) and
460+ input = super .getArgument ( 0 )
465461 }
466462
467463 override Expr getInput ( ) { result = input }
@@ -535,16 +531,14 @@ private module Forge {
535531 override CryptographicAlgorithm getAlgorithm ( ) { result = algorithm }
536532 }
537533
538- private class Apply extends CryptographicOperation {
534+ private class Apply extends CryptographicOperation instanceof MethodCallExpr {
539535 Expr input ;
540536 CryptographicAlgorithm algorithm ; // non-functional
541- MethodCallExpr mce ;
542537
543538 Apply ( ) {
544- this = mce and
545539 exists ( Cipher cipher |
546- mce = cipher .getAMemberCall ( "update" ) .asExpr ( ) and
547- mce .getArgument ( 0 ) = input and
540+ this = cipher .getAMemberCall ( "update" ) .asExpr ( ) and
541+ super .getArgument ( 0 ) = input and
548542 algorithm = cipher .getAlgorithm ( )
549543 )
550544 }
@@ -596,19 +590,17 @@ private module Forge {
596590 * A model of the md5 library.
597591 */
598592private module Md5 {
599- private class Apply extends CryptographicOperation {
593+ private class Apply extends CryptographicOperation instanceof CallExpr {
600594 Expr input ;
601595 CryptographicAlgorithm algorithm ;
602- CallExpr call ;
603596
604597 Apply ( ) {
605598 // `require("md5")("message");`
606- this = call and
607599 exists ( DataFlow:: SourceNode mod |
608600 mod = DataFlow:: moduleImport ( "md5" ) and
609601 algorithm .matchesName ( "MD5" ) and
610- call = mod .getACall ( ) .asExpr ( ) and
611- call .getArgument ( 0 ) = input
602+ this = mod .getACall ( ) .asExpr ( ) and
603+ super .getArgument ( 0 ) = input
612604 )
613605 }
614606
@@ -622,14 +614,12 @@ private module Md5 {
622614 * A model of the bcrypt, bcryptjs, bcrypt-nodejs libraries.
623615 */
624616private module Bcrypt {
625- private class Apply extends CryptographicOperation {
617+ private class Apply extends CryptographicOperation instanceof MethodCallExpr {
626618 Expr input ;
627619 CryptographicAlgorithm algorithm ;
628- MethodCallExpr mce ;
629620
630621 Apply ( ) {
631622 // `require("bcrypt").hash(password);` with minor naming variations
632- this = mce and
633623 exists ( DataFlow:: SourceNode mod , string moduleName , string methodName |
634624 algorithm .matchesName ( "BCRYPT" ) and
635625 (
@@ -642,8 +632,8 @@ private module Bcrypt {
642632 methodName = "hashSync"
643633 ) and
644634 mod = DataFlow:: moduleImport ( moduleName ) and
645- mce = mod .getAMemberCall ( methodName ) .asExpr ( ) and
646- mce .getArgument ( 0 ) = input
635+ this = mod .getAMemberCall ( methodName ) .asExpr ( ) and
636+ super .getArgument ( 0 ) = input
647637 )
648638 }
649639
@@ -657,20 +647,18 @@ private module Bcrypt {
657647 * A model of the hasha library.
658648 */
659649private module Hasha {
660- private class Apply extends CryptographicOperation {
650+ private class Apply extends CryptographicOperation instanceof CallExpr {
661651 Expr input ;
662652 CryptographicAlgorithm algorithm ;
663- CallExpr call ;
664653
665654 Apply ( ) {
666655 // `require('hasha')('unicorn', { algorithm: "md5" });`
667- this = call and
668656 exists ( DataFlow:: SourceNode mod , string algorithmName , Expr algorithmNameNode |
669657 mod = DataFlow:: moduleImport ( "hasha" ) and
670- call = mod .getACall ( ) .asExpr ( ) and
671- call .getArgument ( 0 ) = input and
658+ this = mod .getACall ( ) .asExpr ( ) and
659+ super .getArgument ( 0 ) = input and
672660 algorithm .matchesName ( algorithmName ) and
673- call .hasOptionArgument ( 1 , "algorithm" , algorithmNameNode ) and
661+ super .hasOptionArgument ( 1 , "algorithm" , algorithmNameNode ) and
674662 algorithmNameNode .mayHaveStringValue ( algorithmName )
675663 )
676664 }
0 commit comments