11package it .unipr ;
22
33import it .unipr .analysis .*;
4+ import it .unipr .analysis .taint .TimestampDependencyAbstractDomain ;
45import it .unipr .analysis .taint .TxOriginAbstractDomain ;
56import it .unipr .cfg .*;
67import it .unipr .checker .JumpSolver ;
78import it .unipr .checker .ReentrancyChecker ;
9+ import it .unipr .checker .TimestampDependencyChecker ;
810import it .unipr .checker .TxOriginChecker ;
911import it .unipr .frontend .EVMFrontend ;
1012import it .unive .lisa .LiSA ;
@@ -72,6 +74,7 @@ public class EVMLiSA {
7274 private static final boolean REGENERATE = false ;
7375 private static boolean ENABLE_REENTRANCY_CHECKER = false ;
7476 private static boolean ENABLE_TXORIGIN_CHECKER = false ;
77+ private static boolean ENABLE_TIMESTAMPDEPENDENCY_CHECKER = false ;
7578
7679 /**
7780 * Generates a control flow graph (represented as a LiSA {@code Program})
@@ -201,6 +204,7 @@ private void setupGlobalOptions(CommandLine cmd) {
201204
202205 ENABLE_REENTRANCY_CHECKER = cmd .hasOption ("checker-reentrancy" );
203206 ENABLE_TXORIGIN_CHECKER = cmd .hasOption ("checker-txorigin" );
207+ ENABLE_TIMESTAMPDEPENDENCY_CHECKER = cmd .hasOption ("checker-timestampdependency" );
204208
205209 try {
206210 if (cmd .hasOption ("stack-size" ))
@@ -544,6 +548,19 @@ void checkers(LiSAConfiguration conf, LiSA lisa, Program program, JumpSolver che
544548 jsonOptions .put ("tx-origin-warning" ,
545549 MyCache .getInstance ().getTxOriginWarnings (checker .getComputedCFG ().hashCode ()));
546550 }
551+
552+ if (ENABLE_TIMESTAMPDEPENDENCY_CHECKER ) {
553+ // Clear existing checks and add the TimestampdependencyChecker
554+ conf .semanticChecks .clear ();
555+ conf .semanticChecks .add (new TimestampDependencyChecker ());
556+ conf .abstractState = new SimpleAbstractState <>(new MonolithicHeap (), new TimestampDependencyAbstractDomain (),
557+ new TypeEnvironment <>(new InferredTypes ()));
558+ lisa .run (program );
559+
560+ // Store timestamp-dependency warnings in the JSON options
561+ jsonOptions .put ("timestamp-dependency-warning" ,
562+ MyCache .getInstance ().getTimestampDependencyWarnings (checker .getComputedCFG ().hashCode ()));
563+ }
547564 }
548565
549566 /**
@@ -1143,6 +1160,13 @@ private Options getOptions() {
11431160 .hasArg (false )
11441161 .build ();
11451162
1163+ Option enableTimestampDependencyCheckerOption = Option .builder ()
1164+ .longOpt ("checker-timestampdependency" )
1165+ .desc ("Enable timestamp-dependency checker." )
1166+ .required (false )
1167+ .hasArg (false )
1168+ .build ();
1169+
11461170 options .addOption (addressOption );
11471171 options .addOption (outputOption );
11481172 options .addOption (filePathOption );
@@ -1163,6 +1187,8 @@ private Options getOptions() {
11631187 options .addOption (dumpDotOption );
11641188 options .addOption (enableReentrancyCheckerOption );
11651189 options .addOption (enableTxOriginCheckerOption );
1190+ options .addOption (enableTimestampDependencyCheckerOption );
1191+
11661192
11671193 return options ;
11681194 }
0 commit comments