@@ -718,47 +718,33 @@ module TaintTracking {
718718 override predicate serializeStep ( DataFlow:: Node pred , DataFlow:: Node succ ) {
719719 exists ( JsonStringifyCall call , DataFlow:: Node arg |
720720 arg = call .getArgument ( 0 ) and
721- (
722- pred = arg or
723- findInObject ( arg .asExpr ( ) , pred .asExpr ( ) )
724- ) and
721+ findInObject ( arg .asExpr ( ) , pred .asExpr ( ) ) and
725722 succ = call
726723 )
727724 }
728725
729726 // find target in root object recursively
730727 private predicate findInObject ( Expr root , Expr target ) {
728+ // base case
729+ root = target
730+ or
731731 // when root is Object
732- exists ( Property property , Expr propertyVal |
732+ exists ( Property property |
733733 root instanceof ObjectExpr and
734734 property = root .( ObjectExpr ) .getAProperty ( ) and
735- propertyVal = property .getInit ( ) and
736735 (
737- target = property .getNameExpr ( ) or
738- target = propertyVal or
739- findInObject ( propertyVal , target )
736+ findInObject ( property .getNameExpr ( ) , target ) or
737+ findInObject ( property .getInit ( ) , target )
740738 )
741739 )
742740 or
743741 // when root is Array
744- exists ( Expr child |
745- root instanceof ArrayExpr and
746- child = root .( ArrayExpr ) .getAChildExpr ( ) and
747- (
748- target = child or
749- findInObject ( child , target )
750- )
751- )
742+ root instanceof ArrayExpr and
743+ findInObject ( root .( ArrayExpr ) .getAChildExpr ( ) , target )
752744 or
753745 // when root is VarRef
754- exists ( Expr var |
755- root instanceof VarRef and
756- var = root .( VarRef ) .getAVariable ( ) .getAnAssignedExpr ( ) and
757- (
758- target = var or
759- findInObject ( var , target )
760- )
761- )
746+ root instanceof VarRef and
747+ findInObject ( root .( VarRef ) .getAVariable ( ) .getAnAssignedExpr ( ) , target )
762748 }
763749 }
764750
0 commit comments