diff --git a/cmd/fuzz.go b/cmd/fuzz.go index 188f5d95..c9905b84 100644 --- a/cmd/fuzz.go +++ b/cmd/fuzz.go @@ -2,12 +2,13 @@ package cmd import ( "fmt" - "github.com/crytic/medusa/cmd/exitcodes" - "github.com/crytic/medusa/logging/colors" "os" "os/signal" "path/filepath" + "github.com/crytic/medusa/cmd/exitcodes" + "github.com/crytic/medusa/logging/colors" + "github.com/crytic/medusa/fuzzing" "github.com/crytic/medusa/fuzzing/config" "github.com/spf13/cobra" @@ -102,7 +103,8 @@ func cmdRunFuzz(cmd *cobra.Command, args []string) error { if existenceError == nil { // Try to read the configuration file and throw an error if something goes wrong cmdLogger.Info("Reading the configuration file at: ", colors.Bold, configPath, colors.Reset) - projectConfig, err = config.ReadProjectConfigFromFile(configPath) + // Use the default compilation platform if the config file doesn't specify one + projectConfig, err = config.ReadProjectConfigFromFile(configPath, DefaultCompilationPlatform) if err != nil { cmdLogger.Error("Failed to run the fuzz command", err) return err @@ -144,6 +146,10 @@ func cmdRunFuzz(cmd *cobra.Command, args []string) error { return err } + if !projectConfig.Fuzzing.CoverageEnabled { + cmdLogger.Warn("Disabling coverage may limit efficacy of fuzzing. Consider enabling coverage for better results.") + } + // Create our fuzzing fuzzer, fuzzErr := fuzzing.NewFuzzer(*projectConfig) if fuzzErr != nil { diff --git a/fuzzing/config/config.go b/fuzzing/config/config.go index b37a583c..25149e10 100644 --- a/fuzzing/config/config.go +++ b/fuzzing/config/config.go @@ -3,14 +3,15 @@ package config import ( "encoding/json" "errors" + "math/big" + "os" + "github.com/crytic/medusa/chain/config" "github.com/crytic/medusa/compilation" "github.com/crytic/medusa/logging" "github.com/crytic/medusa/utils" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/rs/zerolog" - "math/big" - "os" ) // The following directives will be picked up by the `go generate` command to generate JSON marshaling code from @@ -242,7 +243,7 @@ type FileLoggingConfig struct { // ReadProjectConfigFromFile reads a JSON-serialized ProjectConfig from a provided file path. // Returns the ProjectConfig if it succeeds, or an error if one occurs. -func ReadProjectConfigFromFile(path string) (*ProjectConfig, error) { +func ReadProjectConfigFromFile(path string, platform string) (*ProjectConfig, error) { // Read our project configuration file data b, err := os.ReadFile(path) if err != nil { @@ -250,7 +251,7 @@ func ReadProjectConfigFromFile(path string) (*ProjectConfig, error) { } // Parse the project configuration - projectConfig, err := GetDefaultProjectConfig("") + projectConfig, err := GetDefaultProjectConfig(platform) if err != nil { return nil, err }