wordfence / wordfence-cli

Wordfence malware and vulnerability scanner command line utility.
https://www.wordfence.com/products/wordfence-cli/
GNU General Public License v3.0
102 stars 22 forks source link

When input an invalid license key, a traceback occurs #153

Closed davidnuzik closed 11 months ago

davidnuzik commented 11 months ago

Summary: When you supply an invalid license key such as during the configure process or with the -l flag, a traceback occurs, rather than nicely handling an invalid key.


Environment: v2.1.0-rc1 (built with pip)

Steps to Reproduce:

  1. By any means, supply an invalid key such as during the configure process or with -l

Expected Result: A traceback is shown such as follows:

License: asdf
Traceback (most recent call last):
  File "/home/david/dev/defiant/temp/wordfence-cli/venv/lib64/python3.11/site-packages/wordfence/cli/licensing.py", line 44, in validate_license
    if not client.ping_api_key():
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/david/dev/defiant/temp/wordfence-cli/venv/lib64/python3.11/site-packages/wordfence/api/noc1.py", line 126, in ping_api_key
    return self.process_simple_request('ping_api_key')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/david/dev/defiant/temp/wordfence-cli/venv/lib64/python3.11/site-packages/wordfence/api/noc1.py", line 71, in process_simple_request
    self.validate_response(response, validator)
  File "/home/david/dev/defiant/temp/wordfence-cli/venv/lib64/python3.11/site-packages/wordfence/api/noc1.py", line 57, in validate_response
    raise ApiException(
wordfence.api.exceptions.ApiException: Error message received in response body: Wordfence API error: Your site did not send an API key when contacting the Wordfence servers.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/wordfence", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/david/dev/defiant/temp/wordfence-cli/venv/lib64/python3.11/site-packages/wordfence/cli/cli.py", line 202, in main
    exit_code = cli.invoke()
                ^^^^^^^^^^^^
  File "/home/david/dev/defiant/temp/wordfence-cli/venv/lib64/python3.11/site-packages/wordfence/cli/cli.py", line 175, in invoke
    configurer.check_config()
  File "/home/david/dev/defiant/temp/wordfence-cli/venv/lib64/python3.11/site-packages/wordfence/cli/configurer.py", line 409, in check_config
    self.prompt_for_missing_config()
  File "/home/david/dev/defiant/temp/wordfence-cli/venv/lib64/python3.11/site-packages/wordfence/cli/configurer.py", line 386, in prompt_for_missing_config
    self.prompt_for_config()
  File "/home/david/dev/defiant/temp/wordfence-cli/venv/lib64/python3.11/site-packages/wordfence/cli/configurer.py", line 320, in prompt_for_config
    license = self._prompt_for_license()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/david/dev/defiant/temp/wordfence-cli/venv/lib64/python3.11/site-packages/wordfence/cli/configurer.py", line 253, in _prompt_for_license
    license = prompt(
              ^^^^^^^
  File "/home/david/dev/defiant/temp/wordfence-cli/venv/lib64/python3.11/site-packages/wordfence/util/input.py", line 58, in prompt
    return transformer(response)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/david/dev/defiant/temp/wordfence-cli/venv/lib64/python3.11/site-packages/wordfence/cli/licensing.py", line 52, in validate_license
    raise LicenseValidationFailure(
wordfence.cli.licensing.LicenseValidationFailure: Invalid license: Wordfence API error: Your site did not send an API key when contacting the Wordfence servers.

Actual Result: I expected the invalid license to be handled nicely without any traceback. I expeced just ot see the LicenseValidationFailure message "Invalid license: Wordfence API error: Your site did not send an API key when contacting the Wordfence servers."

davidnuzik commented 11 months ago

Closing as duplicate of #124 -- this is going to get fixed as a part of #124 and hence creating an issue here is not needed!