1818import it .unive .lisa .util .representation .StructuredRepresentation ;
1919import java .util .ArrayList ;
2020import java .util .Collections ;
21- import java .util .HashSet ;
2221import java .util .Iterator ;
2322import java .util .List ;
2423import java .util .function .Predicate ;
@@ -27,37 +26,25 @@ public class TaintAbstractDomain implements ValueDomain<TaintAbstractDomain>, Ba
2726
2827 private static int STACK_LIMIT = 32 ;
2928 private static final TaintAbstractDomain TOP = new TaintAbstractDomain (
30- new ArrayList <>(Collections .nCopies (STACK_LIMIT , TaintElement .BOTTOM )), new HashSet < String >() );
31- private static final TaintAbstractDomain BOTTOM = new TaintAbstractDomain (null , new HashSet < String >() );
29+ new ArrayList <>(Collections .nCopies (STACK_LIMIT , TaintElement .BOTTOM )));
30+ private static final TaintAbstractDomain BOTTOM = new TaintAbstractDomain (null );
3231
3332 private final ArrayList <TaintElement > stack ;
34-
35- private final HashSet <String > pushTaintList ;
3633
3734 /**
3835 * Builds an initial symbolic stack.
3936 */
4037 public TaintAbstractDomain () {
4138 this .stack = new ArrayList <>(Collections .nCopies (STACK_LIMIT , TaintElement .BOTTOM ));
42- this .pushTaintList = new HashSet <String >();
43- }
44-
45- /**
46- * Builds a taint abstract stack starting from a given list of elements that push taint .
47- */
48- public TaintAbstractDomain (HashSet <String > pushTaintList ) {
49- this .stack = new ArrayList <>(Collections .nCopies (STACK_LIMIT , TaintElement .BOTTOM ));
50- this .pushTaintList = pushTaintList ;
5139 }
5240
5341 /**
54- * Builds a taint abstract stack starting from a given stack and a list of elements that push taint .
42+ * Builds a taint abstract stack starting from a given stack.
5543 *
5644 * @param stack the stack of values
5745 */
58- private TaintAbstractDomain (ArrayList <TaintElement > stack , HashSet < String > pushTaintList ) {
46+ private TaintAbstractDomain (ArrayList <TaintElement > stack ) {
5947 this .stack = stack ;
60- this .pushTaintList = pushTaintList ;
6148 }
6249
6350 @ Override
@@ -83,8 +70,12 @@ public TaintAbstractDomain smallStepSemantics(ValueExpression expression, Progra
8370
8471 if (op != null ) {
8572 switch (op .getClass ().getSimpleName ()) {
73+ case "OriginOperator" : {
74+ TaintAbstractDomain resultStack = clone ();
75+ resultStack .push (TaintElement .TAINT );
76+ return resultStack ;
77+ }
8678 case "TimestampOperator" :
87- case "OriginOperator" :
8879 case "CodesizeOperator" :
8980 case "GaspriceOperator" :
9081 case "ReturndatasizeOperator" :
@@ -105,10 +96,7 @@ public TaintAbstractDomain smallStepSemantics(ValueExpression expression, Progra
10596 case "PushOperator" :
10697 case "Push0Operator" : {
10798 TaintAbstractDomain resultStack = clone ();
108- if (this .pushTaintList .contains (op .getClass ().getSimpleName ()))
109- resultStack .push (TaintElement .TAINT );
110- else resultStack .push (TaintElement .CLEAN );
111- resultStack .toString ();
99+ resultStack .push (TaintElement .CLEAN );
112100 return resultStack ;
113101 }
114102
@@ -121,22 +109,21 @@ public TaintAbstractDomain smallStepSemantics(ValueExpression expression, Progra
121109
122110 case "JumpOperator" : { // JUMP
123111 if (hasBottomUntil (1 ))
124- return BOTTOM ;
112+ return BOTTOM ;
125113
126114 TaintAbstractDomain resultStack = clone ();
127- TaintElement opnd1 = resultStack .pop ();
128-
115+ resultStack .pop ();
116+
129117 return resultStack ;
130118 }
131119 case "JumpiOperator" : { // JUMPI
132-
133120 if (hasBottomUntil (2 ))
134121 return BOTTOM ;
135122
136123 TaintAbstractDomain resultStack = clone ();
137- TaintElement opnd1 = resultStack .pop ();
138- TaintElement opnd2 = resultStack .pop ();
139-
124+ resultStack .pop ();
125+ resultStack .pop ();
126+
140127 return resultStack ;
141128 }
142129
@@ -716,7 +703,7 @@ private TaintAbstractDomain swapX(int x, TaintAbstractDomain stack) {
716703 for (int i = 0 ; i < clone .size (); i ++)
717704 result .add ((TaintElement ) obj [i ]);
718705
719- return new TaintAbstractDomain (result , this . pushTaintList );
706+ return new TaintAbstractDomain (result );
720707 }
721708
722709 private TaintAbstractDomain dupX (int x , TaintAbstractDomain stack ) {
@@ -743,7 +730,7 @@ private TaintAbstractDomain dupX(int x, TaintAbstractDomain stack) {
743730 result .add (tmp );
744731 result .remove (0 );
745732
746- return new TaintAbstractDomain (result , this . pushTaintList );
733+ return new TaintAbstractDomain (result );
747734 }
748735
749736 private ArrayList <TaintElement > getStack () {
@@ -854,7 +841,7 @@ public TaintAbstractDomain glbAux(TaintAbstractDomain other) throws SemanticExce
854841 result .add (thisElement .glb (otherElement ));
855842 }
856843
857- return new TaintAbstractDomain (result , this . pushTaintList );
844+ return new TaintAbstractDomain (result );
858845 }
859846
860847 @ Override
@@ -870,7 +857,7 @@ public TaintAbstractDomain lubAux(TaintAbstractDomain other) throws SemanticExce
870857 result .add (thisElement .lub (otherElement ));
871858 }
872859
873- return new TaintAbstractDomain (result , this . pushTaintList );
860+ return new TaintAbstractDomain (result );
874861 }
875862
876863 @ Override
@@ -916,9 +903,9 @@ public TaintElement pop() {
916903 * Checks whether between 0 and x-positions of the stack an element is
917904 * bottom. /** Checks whether between 0 and x-positions of the stack an
918905 * element is bottom.
919- *
906+ *
920907 * @param x the position
921- *
908+ *
922909 * @return {@code true} if between 0 and x-positions of the stack an element
923910 * is bottom, {@code false} otherwise.
924911 */
@@ -933,7 +920,7 @@ public boolean hasBottomUntil(int x) {
933920 public TaintAbstractDomain clone () {
934921 if (isBottom ())
935922 return this ;
936- return new TaintAbstractDomain (new ArrayList <>(stack ), new HashSet < String >( pushTaintList ) );
923+ return new TaintAbstractDomain (new ArrayList <>(stack ));
937924 }
938925
939926 @ Override
@@ -968,4 +955,4 @@ else if (isTop())
968955 return TaintElement .TOP ;
969956 return this .stack .get (STACK_LIMIT - 1 );
970957 }
971- }
958+ }
0 commit comments