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/config refactor #201

Merged
merged 41 commits into from
Oct 8, 2019
Merged

Feature/config refactor #201

merged 41 commits into from
Oct 8, 2019

Conversation

clenk
Copy link
Contributor

@clenk clenk commented Jun 18, 2019

  • Refactors and consolidates config handling.
  • Allows selecting which modules to run.

Fixes #131, fixes #87.

clenk added 30 commits February 14, 2019 17:59
And introduce a variable to make code easier to read
get_config_path() should work on an already-parsed config object, and not need
to parse it again.
It will default to using the main MultiScanner config, but a different
config can be passed in. The component parameter must be provided.

This is a backwards-incompatible change as the order of the parameters
has switched.
They do the same thing, and it makes more sense to handle this someplace
other than the main scanning function.
It now just uses the config parameter.
Config file handling and making sure missing sections or values has been
relegated to main() in ms.py. We shouldn't need to rewrite config files
every time we do a scan, just once when start MultiScanner.
Functions like multiscan() and _subscan() now take a list of module
names instead of full paths.

Renamed MODULESLIST -> MODULE_LIST.

Stopped using globals as default parameters in certain functions so the
functions will use the most up-to-date version of the global instead of
the global's state when the function was defined.
- jQuery wasn't reading it correctly
- ElasticSearch would break if SHA256 module wasn't enabled in the UI
- Call multiscan() once per sample in non-distributed mode so we can
select which modules to run per-sample
- Consolidated _rewrite_config functions from ms.py, storage.py and
  sql_driver.py into reset_config in config.py.
- Renamed _update_DEFAULTCONF to update_paths_in_configs and put it in
  config.py.
- The sql_driver version of the function allowed passing in a configuration to
  override the default values. However it was only used by api.py, which
  creates a sql_driver.Database instance and passes in api_config.ini's
  Database section config. The consolidated reset_config doesn't have a
  parameter for overriding a DEFAULTCONF, so api.py uses regenconfig=False on
  the Database constructor so the Database config section will only be
  regenerated if it doesn't already exist.
- We never used the module_list option for config_init() in ms.py, so I removed
  it to simplify things.
Have to import config globals like CONFIG_FILE as qualified names
because importing them by name copies them so we end up not modifying
the global.

Also moved config_init and _write_missing_module_configs to make it
easier to see how they were called, in preparation for consolidating
them into config.py.
Namely, _get_main_config, _write_missing_module_config, _rewrite_config.
...instead of dicts for main configs. Needed because write_missing_config()
needs a ConfigParser object and it was being called from different
places, sometimes as a dict, sometimes ConfigParser.
We can always start with the default config and then update it based on
the config passed in.
to convert config values to Python literals (eg. "True" to a Python boolean)
- Removed _load_defalt from storage.py
- Changed write_config and read_config to use a dict for the default
config instead of a section name and dict of the values in that section.
This allows passing in more than one section at once.
- Fixed some misnamed parameters.
- Fixed bug where Mock couldn't find the Metadefender module.
clenk added 7 commits May 13, 2019 15:19
We were incorrectly replacing sys.argv, omitting the first term. It
doesn't matter what we set it to, as argparse won't care. The
try/catches are needed because 'init' calls `exit()`.
Also fix a couple config bugs
and use the same config handling code as the other configs
@emmanvg emmanvg self-requested a review June 20, 2019 18:35
clenk and others added 4 commits June 20, 2019 16:02
and fix a couple other minor things found in code review
- Similarly we now need to submit each item individually.
In the distributed case, we are obligated to pass a dict, but later we need to convert it back into a MSConfigParser. Essentially, for line 411 fallback="..."
Copy link
Contributor

@emmanvg emmanvg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Re-tested on clean environment and was not able to reproduce past findings.

@clenk clenk merged commit a33f818 into dev Oct 8, 2019
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 this pull request may close these issues.

3 participants