Skip to content

Commit

Permalink
parse assert location fields from slither
Browse files Browse the repository at this point in the history
  • Loading branch information
ggrieco-tob committed Sep 1, 2023
1 parent 9ea8a2c commit 08bb39b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
21 changes: 20 additions & 1 deletion lib/Echidna/Processor.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,30 @@ enhanceConstants si =
enh (AbiString s) = makeArrayAbiValues s
enh v = [v]

data AssertLocation = AssertLocation
{ start :: Int
, filenameRelative :: String
, filenameAbsolute :: String
, assertLines :: [Int]
, startColumn :: Int
, endingColumn :: Int
} deriving (Show)

instance FromJSON AssertLocation where
parseJSON = withObject "" $ \o -> do
start <- o.: "start"
filenameRelative <- o.: "filename_relative"
filenameAbsolute <- o.: "filename_absolute"
assertLines <- o.: "lines"
startColumn <- o.: "start_column"
endingColumn <- o.: "ending_column"
pure AssertLocation {..}

-- we loose info on what constants are in which functions
data SlitherInfo = SlitherInfo
{ payableFunctions :: Map ContractName [FunctionName]
, constantFunctions :: Map ContractName [FunctionName]
, asserts :: Map ContractName [FunctionName]
, asserts :: Map ContractName (Map FunctionName [AssertLocation])
, constantValues :: Map ContractName (Map FunctionName [AbiValue])
, generationGraph :: Map ContractName (Map FunctionName [FunctionName])
, solcVersions :: [Version]
Expand Down
4 changes: 2 additions & 2 deletions lib/Echidna/Solidity.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import Echidna.Etheno (loadEthenoBatch)
import Echidna.Events (EventMap, extractEvents)
import Echidna.Exec (execTx, initialVM)
import Echidna.Processor
import Echidna.Test (createTests, isAssertionMode, isPropertyMode, isDapptestMode)
import Echidna.Test (createTests, isPropertyMode, isDapptestMode)
import Echidna.Types.Config (EConfig(..), Env(..))
import Echidna.Types.Signature
(ContractName, SolSignature, SignatureMap, getBytecodeMetadata)
Expand Down Expand Up @@ -315,7 +315,7 @@ mkWorld
mkWorld SolConf{sender, testMode} em m c si =
let
ps = filterResults c si.payableFunctions
as = if isAssertionMode testMode then filterResults c si.asserts else []
as = {-if isAssertionMode testMode then filterResults c (Map.keys si.asserts) else-} []
cs = if isDapptestMode testMode then [] else filterResults c si.constantFunctions \\ as
(hm, lm) = prepareHashMaps cs as $ filterFallbacks c si.fallbackDefined si.receiveDefined m
in World sender hm lm ps em
Expand Down

0 comments on commit 08bb39b

Please sign in to comment.