Skip to content

Commit cccc128

Browse files
make sure symExecTarget is used to select methods
1 parent b17a32e commit cccc128

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

lib/Echidna/Campaign.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,14 @@ runSymWorker callback vm dict workerId _ name = do
232232

233233

234234
symexecTx (tx, vm', txsBase) = do
235+
conf <- asks (.cfg)
235236
dapp <- asks (.dapp)
236237
let cs = Map.elems dapp.solcByName
237238
contract <- chooseContract cs name
238239
failedTests <- findFailedTests
239240
let failedTestSignatures = map getAssertionSignature failedTests
240241
case tx of
241-
Nothing -> getRandomTargetMethod contract failedTestSignatures >>= \case
242+
Nothing -> getRandomTargetMethod contract conf.campaignConf.symExecTargets failedTestSignatures >>= \case
242243
Nothing -> do
243244
return ()
244245
Just method -> exploreAndVerify contract method vm' txsBase

lib/Echidna/SymExec/Exploration.hs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,18 @@ getTargetMethodFromTx _ _ _ = return Nothing
6060
-- This function selects a random method from the contract's ABI to explore.
6161
-- It uses the campaign configuration to determine which methods are suitable for symbolic execution.
6262
-- Additionally, it filter methods that are associated with failed properties, if any.
63-
getRandomTargetMethod :: (MonadIO m, MonadReader Echidna.Types.Config.Env m) => SolcContract -> [String] -> m (Maybe Method)
64-
getRandomTargetMethod contract failedProperties = do
63+
getRandomTargetMethod :: (MonadIO m, MonadReader Echidna.Types.Config.Env m) => SolcContract -> Maybe [Text] -> [String] -> m (Maybe Method)
64+
getRandomTargetMethod contract targets failedProperties = do
6565
env <- ask
6666
let allMethods = Map.assocs contract.abiMap
6767
assertSigs = env.world.assertSigs
6868
filterFunc (selector, method) = (null assertSigs || selector `elem` assertSigs) && suitableForSymExec method && (unpack method.methodSignature) `notElem` failedProperties
6969
filteredMethods = filter filterFunc allMethods
7070

71-
case filteredMethods of
72-
[] -> return Nothing
73-
_ -> liftIO $ rElem (fromList $ map (Just . snd) filteredMethods)
71+
case (targets, filteredMethods) of
72+
(Just ms, _) -> liftIO $ rElem (fromList $ map (Just . snd) $ filter (\(_, m) -> m.name `elem` ms) allMethods)
73+
(_, []) -> return Nothing
74+
_ -> liftIO $ rElem (fromList $ map (Just . snd) filteredMethods)
7475

7576

7677
-- | Filters methods based on the campaign configuration.

0 commit comments

Comments
 (0)