ConfigDB silently fails when default.cfg not found #666

Closed
DePierre opened this Issue Apr 19, 2016 · 0 comments

Comments

Projects
None yet
1 participant
@DePierre
Contributor

DePierre commented Apr 19, 2016

When running OWTF from a different directory and OWTF cannot find the file profile/general/default.cfg, it silently fails.

Instead of throwing a verbose error message such as "Configuration file not found", it simply does not load the configuration DB values and later fails when loading Zest with the following error message:

Traceback (most recent call last):
  File "/home/depierre/git-repo/owtf/owtf_testing/tests_functional/cli/test_empty_run.py", line 13, in test_cli_empty_run
    self.run_owtf()
  File "/home/depierre/git-repo/owtf/owtf_testing/utils/owtftest.py", line 55, in run_owtf
    owtf.main(args)
  File "/home/depierre/git-repo/owtf/owtf.py", line 235, in main
    ComponentInitialiser.initialisation_phase_1(root_dir, owtf_pid)
  File "/home/depierre/git-repo/owtf/framework/dependency_management/component_initialiser.py", line 73, in initialisation_phase_1
    zest.init()
  File "/home/depierre/git-repo/owtf/framework/zest.py", line 25, in init
    self.StopRecorder()  # recorded should be stopped when OWTF starts
  File "/home/depierre/git-repo/owtf/framework/zest.py", line 145, in StopRecorder
    self.db_config.Update("ZEST_RECORDING", "False")
  File "/home/depierre/git-repo/owtf/framework/db/config_manager.py", line 114, in Update
    raise InvalidConfigurationReference("No setting exists with key: " + str(key))
InvalidConfigurationReference: 'No setting exists with key: ZEST_RECORDING'

The error is in https://github.com/owtf/owtf/blob/develop/framework/db/config_manager.py#L31 where the documentation of RawConfigParser.read() says:

If none of the named files exist, the ConfigParser instance will contain an empty dataset.

To fix the issue and get a verbose message, the function LoadConfigDBFromFile should use https://docs.python.org/2/library/configparser.html#ConfigParser.RawConfigParser.readfp.
Another approach would be to check that file_path exists before https://github.com/owtf/owtf/blob/develop/framework/db/config_manager.py#L31

DarKnight24 added a commit to DarKnight24/owtf that referenced this issue Apr 21, 2016

DarKnight24 added a commit to DarKnight24/owtf that referenced this issue Apr 21, 2016

DarKnight24 added a commit to DarKnight24/owtf that referenced this issue Apr 21, 2016

@DePierre DePierre referenced this issue in owtf/owtf_testing Apr 21, 2016

Open

Add regression test for owtf/owtf#666 #5

@DePierre DePierre closed this in 7d1b339 Apr 21, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment