Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add global configuration mechanism #372

Closed
feliam opened this issue Jul 5, 2017 · 0 comments
Closed

Feature: Add global configuration mechanism #372

feliam opened this issue Jul 5, 2017 · 0 comments

Comments

@feliam
Copy link
Contributor

feliam commented Jul 5, 2017

Feature request.
Add a way for the different modules to register global configurations items like "solver query timeout".
This configs should be settable via a .ini file or via a command line argument like KLEE.

This .ini should be included in the analysis output so it's reproducible. It supersedes the "command.sh" at the current output.

@yan yan closed this as completed in #1139 Oct 10, 2018
yan added a commit that referenced this issue Oct 10, 2018
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 -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant