viper-framework / viper

Binary analysis and management framework
Other
1.54k stars 353 forks source link

Set Root Module Path #781

Closed xorhex closed 4 years ago

xorhex commented 4 years ago

Added the ability to set a module path in the config so that we can control where the modules are checked out to. If value not set, it will use the default ~/.viper.

xorhex commented 4 years ago

W00t, finally looks like it is all set :smiley:

botherder commented 4 years ago

Thanks for this. When the value of the config entry is empty, should it skip loading it to sys.path?

xorhex commented 4 years ago

Referring to plugins.py?

    # Add root module_path as a Python path.
    sys.path.insert(0, cfg.paths.module_path)

If it is not set, then a default is provided via config.py when the config is parsed.

        # Set a default value for the module_path if one was not set
        if 'module_path' not in self.paths or len(self.paths['module_path']) < 1:
            self.paths['module_path'] = os.path.join(expanduser('~'), ".viper")
            if not os.path.exists(self.paths['module_path']):
                os.makedirs(self.paths['module_path'])

Added a default this way so that we'd not have to add os.path.join(expanduser('~'), ".viper") in multiple places.

I'm happy to make additional changes to stay in line with the team's vision/use of the tool. Let me know. I find this tool very helpful in my day to day work and want to contribute back. :-)

botherder commented 4 years ago

Nah, I think it looks good. I was actually wondering whether it could make sense to also have an argparse argument to the command-line in order to load modules on the fly for test/dev purposes. In the meantime, I will merge this. Thanks!