Skip to content

Commit fd965c8

Browse files
committed
improved and reduced warning messages
1 parent 1890a4d commit fd965c8

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

go-lisa/src/main/java/it/unive/golisa/checker/hf/CrossChannelInvocationsIssuesChecker.java

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.util.Collection;
3434
import java.util.HashMap;
3535
import java.util.HashSet;
36+
import java.util.Iterator;
3637
import java.util.List;
3738
import java.util.Map;
3839
import java.util.Set;
@@ -145,16 +146,35 @@ public void afterExecution(
145146
}
146147
}
147148

149+
Map<Statement, Set<Statement>> results = new HashMap<>();
148150
for( Pair<Statement, Statement> cchs : multipleCrossChannelInvocations) {
149-
tool.warnOn(cchs.getLeft(),
150-
"Detected cross-channel invocations on different channels. The other invocation: "
151-
+ cchs.getRight().getLocation() + ". They may lead to a lack of transparency because no new transactions are created during the invocation.");
152-
if(intraChaincode)
153-
tool.warnOn(cchs.getLeft(),
154-
"Detected cross-channel invocations on different channels. The other invocation: "
155-
+ cchs.getRight().getLocation() + ". They may lead to uncommited write operations during the execution of callee chaincode.");
151+
if(!results.containsKey(cchs.getLeft()))
152+
results.put(cchs.getLeft(), new HashSet<>());
153+
results.get(cchs.getLeft()).add(cchs.getRight());
154+
}
155+
156+
for(Statement target : results.keySet()) {
157+
Set<Statement> others = results.get(target);
158+
tool.warnOn(target,
159+
"Detected cross-channel invocations on different channels. The other invocations: "
160+
+ printOtherLocations(others) + ". They may lead to a lack of transparency because no new transactions are created during the invocation.");
161+
if(intraChaincode)
162+
tool.warnOn(target,
163+
"Detected cross-channel invocations on different channels. The other invocations: "
164+
+ printOtherLocations(others) + ". They may lead to uncommited write operations during the execution of callee chaincode.");
156165
}
166+
}
157167

168+
private String printOtherLocations(Set<Statement> others) {
169+
String result = "";
170+
Iterator<Statement> iter = others.iterator();
171+
while(iter.hasNext()) {
172+
Statement cchi = iter.next();
173+
result += cchi.getLocation();
174+
if(iter.hasNext())
175+
result += ", ";
176+
}
177+
return result;
158178
}
159179

160180
@Override

0 commit comments

Comments
 (0)