Skip to content

Commit ddf4ace

Browse files
committed
spotless
1 parent 6e2726b commit ddf4ace

File tree

2 files changed

+78
-18
lines changed

2 files changed

+78
-18
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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 TimestampDependencyAbstractDomain(list);
58+
}
59+
60+
}

src/test/java/it/unipr/analysis/cron/EVMTxOriginAbstractSemanticsTest.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,109 +62,109 @@ private static CronConfiguration createConfiguration(String testDir, String subD
6262

6363
@Test
6464
public void testTaint01() throws AnalysisSetupException, IOException {
65-
CronConfiguration conf = createConfiguration("taint", "example", "example.sol", false);
65+
CronConfiguration conf = createConfiguration("taint/testTxOrigin", "example", "example.sol", false);
6666
perform(conf);
6767
}
6868

6969
@Test
7070
public void testTaint02() throws AnalysisSetupException, IOException {
71-
CronConfiguration conf = createConfiguration("taint", "example02", "example02.sol", false);
71+
CronConfiguration conf = createConfiguration("taint/testTxOrigin", "example02", "example02.sol", false);
7272
perform(conf);
7373
}
7474

7575
@Test
7676
public void testTaint03() throws AnalysisSetupException, IOException {
77-
CronConfiguration conf = createConfiguration("taint", "example03", "example03.sol", false);
77+
CronConfiguration conf = createConfiguration("taint/testTxOrigin", "example03", "example03.sol", false);
7878
perform(conf);
7979
}
8080

8181
@Test
8282
public void testTaint04() throws AnalysisSetupException, IOException {
83-
CronConfiguration conf = createConfiguration("taint", "example04", "example04.sol", false);
83+
CronConfiguration conf = createConfiguration("taint/testTxOrigin", "example04", "example04.sol", false);
8484
perform(conf);
8585
}
8686

8787
@Test
8888
public void testTaint05() throws AnalysisSetupException, IOException {
89-
CronConfiguration conf = createConfiguration("taint", "example05", "example05.sol", false);
89+
CronConfiguration conf = createConfiguration("taint/testTxOrigin", "example05", "example05.sol", false);
9090
perform(conf);
9191
}
9292

9393
@Test
9494
public void testTaint06() throws AnalysisSetupException, IOException {
95-
CronConfiguration conf = createConfiguration("taint", "example06", "example06.sol", false);
95+
CronConfiguration conf = createConfiguration("taint/testTxOrigin", "example06", "example06.sol", false);
9696
perform(conf);
9797
}
9898

9999
@Test
100100
public void testTaint07() throws AnalysisSetupException, IOException {
101-
CronConfiguration conf = createConfiguration("taint", "example07", "example07.sol", false);
101+
CronConfiguration conf = createConfiguration("taint/testTxOrigin", "example07", "example07.sol", false);
102102
perform(conf);
103103
}
104104

105105
@Test
106106
public void testTaint08() throws AnalysisSetupException, IOException {
107-
CronConfiguration conf = createConfiguration("taint", "example08", "example08.sol", false);
107+
CronConfiguration conf = createConfiguration("taint/testTxOrigin", "example08", "example08.sol", false);
108108
perform(conf);
109109
}
110110

111111
@Test
112112
public void testTaint09() throws AnalysisSetupException, IOException {
113-
CronConfiguration conf = createConfiguration("taint", "example09", "example09.sol", false);
113+
CronConfiguration conf = createConfiguration("taint/testTxOrigin", "example09", "example09.sol", false);
114114
perform(conf);
115115
}
116116

117117
@Test
118118
public void testTaint10() throws AnalysisSetupException, IOException {
119-
CronConfiguration conf = createConfiguration("taint", "example10", "example10.sol", false);
119+
CronConfiguration conf = createConfiguration("taint/testTxOrigin", "example10", "example10.sol", false);
120120
perform(conf);
121121
}
122122

123123
@Test
124124
public void testTaint11() throws AnalysisSetupException, IOException {
125-
CronConfiguration conf = createConfiguration("taint", "example11", "example11.sol", false);
125+
CronConfiguration conf = createConfiguration("taint/testTxOrigin", "example11", "example11.sol", false);
126126
perform(conf);
127127
}
128128

129129
@Test
130130
public void testTaint12() throws AnalysisSetupException, IOException {
131-
CronConfiguration conf = createConfiguration("taint", "example12", "example12.sol", false);
131+
CronConfiguration conf = createConfiguration("taint/testTxOrigin", "example12", "example12.sol", false);
132132
perform(conf);
133133
}
134134

135135
@Test
136136
public void testTaint13() throws AnalysisSetupException, IOException {
137-
CronConfiguration conf = createConfiguration("taint", "example13", "example13.sol", false);
137+
CronConfiguration conf = createConfiguration("taint/testTxOrigin", "example13", "example13.sol", false);
138138
perform(conf);
139139
}
140140

141141
@Test
142142
public void testTaint14() throws AnalysisSetupException, IOException {
143-
CronConfiguration conf = createConfiguration("taint", "example14", "example14.sol", false);
143+
CronConfiguration conf = createConfiguration("taint/testTxOrigin", "example14", "example14.sol", false);
144144
perform(conf);
145145
}
146146

147147
@Test
148148
public void testTaint15() throws AnalysisSetupException, IOException {
149-
CronConfiguration conf = createConfiguration("taint", "example15", "example15.sol", false);
149+
CronConfiguration conf = createConfiguration("taint/testTxOrigin", "example15", "example15.sol", false);
150150
perform(conf);
151151
}
152152

153153
@Test
154154
public void testTaint16() throws AnalysisSetupException, IOException {
155-
CronConfiguration conf = createConfiguration("taint", "example16", "example16.sol", false);
155+
CronConfiguration conf = createConfiguration("taint/testTxOrigin", "example16", "example16.sol", false);
156156
perform(conf);
157157
}
158158

159159
@Test
160160
public void testTaint17() throws AnalysisSetupException, IOException {
161-
CronConfiguration conf = createConfiguration("taint", "example17", "example17.sol", false);
161+
CronConfiguration conf = createConfiguration("taint/testTxOrigin", "example17", "example17.sol", false);
162162
perform(conf);
163163
}
164164

165165
@Test
166166
public void testTaint18() throws AnalysisSetupException, IOException {
167-
CronConfiguration conf = createConfiguration("taint", "example18", "example18.sol", false);
167+
CronConfiguration conf = createConfiguration("taint/testTxOrigin", "example18", "example18.sol", false);
168168
perform(conf);
169169
}
170170
}

0 commit comments

Comments
 (0)