-
Notifications
You must be signed in to change notification settings - Fork 476
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce a configuration system (#1139)
This PR introduces a config/globals management system that addresses a few concerns about manticore: 1. The lack of a method to update certain configuration constants from Manticore's environment (such as solver timeout). 2. The ability to maintain a configuration file with a set of persistent flags and settings to simplify manticore invocation. (i.e. always enable all EVM detectors) 3. Make a central global place for configuration constants. ## Implementation This PR adds the `manticore.utils.config` module. It implements a way to create and set configuration groups. Manticore's `main` tries loading all groups/values from yaml files in `$PWD` (file can be `.manticore.yml`, `manticore.yml`, `.mcore.yml`, or `mcore.yml`). A `manticore.yml` is also now produced in workspace directory upon a run's completion. Variable values take the following precedence, lowest to highest: 1. The default value declared in the top of a module. 2. The configuration file read 3. The CLI if the variable is also a command line argument. (All command line arguments can be set in the yml under the key `cli`) New flag, `--config` has been added to specify a config file if it's not one of the files that are automatically discovered. `--config-print` dumps all declared constants that can be set. Declaring a configuration group is pretty straightforward. The following is a snippet from the top of `solver.py`: ``` consts = config.get_group('smt') consts.add('timeout', default=240, description='Timeout, in seconds, for each Z3 invocation') consts.add('memory', default=16384, description='Max memory for Z3 to use (in Megabytes)') consts.add('maxsolutions', default=10000, description='Maximum solutions to provide when solving for all values') ``` Then using it later is as simple as referring to `consts.memory` or `consts.timeout`. Fixes #372 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/trailofbits/manticore/1139) <!-- Reviewable:end -->
- Loading branch information
Showing
10 changed files
with
573 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.