|
| 1 | +package it.unipr.analysis.taint; |
| 2 | + |
| 3 | +import it.unipr.analysis.operator.BalanceOperator; |
| 4 | +import it.unipr.analysis.operator.BlockhashOperator; |
| 5 | +import it.unipr.analysis.operator.DifficultyOperator; |
| 6 | +import it.unipr.analysis.operator.TimestampOperator; |
| 7 | +import it.unive.lisa.symbolic.value.Operator; |
| 8 | +import java.util.ArrayList; |
| 9 | +import java.util.Collections; |
| 10 | +import java.util.HashSet; |
| 11 | +import java.util.Set; |
| 12 | + |
| 13 | +public class TimestampDependencyAbstractDomain extends TaintAbstractDomain { |
| 14 | + private static final TimestampDependencyAbstractDomain TOP = new TimestampDependencyAbstractDomain( |
| 15 | + new ArrayList<>(Collections.nCopies(TaintAbstractDomain.STACK_LIMIT, TaintElement.BOTTOM))); |
| 16 | + private static final TimestampDependencyAbstractDomain BOTTOM = new TimestampDependencyAbstractDomain(null); |
| 17 | + |
| 18 | + /** |
| 19 | + * Builds an initial symbolic stack. |
| 20 | + */ |
| 21 | + public TimestampDependencyAbstractDomain() { |
| 22 | + this(new ArrayList<>(Collections.nCopies(STACK_LIMIT, TaintElement.BOTTOM))); |
| 23 | + } |
| 24 | + |
| 25 | + /** |
| 26 | + * Builds a taint abstract stack starting from a given stack and a list of |
| 27 | + * elements that push taint. |
| 28 | + * |
| 29 | + * @param stack the stack of values |
| 30 | + */ |
| 31 | + protected TimestampDependencyAbstractDomain(ArrayList<TaintElement> stack) { |
| 32 | + super(stack); |
| 33 | + } |
| 34 | + |
| 35 | + @Override |
| 36 | + public Set<Operator> getTaintedOpcode() { |
| 37 | + Set<Operator> taintedOpcode = new HashSet<>(); |
| 38 | + taintedOpcode.add(TimestampOperator.INSTANCE); |
| 39 | + taintedOpcode.add(BlockhashOperator.INSTANCE); |
| 40 | + taintedOpcode.add(DifficultyOperator.INSTANCE); |
| 41 | + taintedOpcode.add(BalanceOperator.INSTANCE); |
| 42 | + return taintedOpcode; |
| 43 | + } |
| 44 | + |
| 45 | + @Override |
| 46 | + public TimestampDependencyAbstractDomain top() { |
| 47 | + return TOP; |
| 48 | + } |
| 49 | + |
| 50 | + @Override |
| 51 | + public TimestampDependencyAbstractDomain bottom() { |
| 52 | + return BOTTOM; |
| 53 | + } |
| 54 | + |
| 55 | + @Override |
| 56 | + public TaintAbstractDomain mk(ArrayList<TaintElement> list) { |
| 57 | + return new TxOriginAbstractDomain(list); |
| 58 | + } |
| 59 | + |
| 60 | +} |
0 commit comments