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

Added decorator requirements_check for reducing code duplication #350

Closed
wants to merge 2 commits into from

Conversation

itsdivyanshjain
Copy link
Collaborator

Checklist

  • I have followed the Contributor Guidelines.
  • The code has been thoroughly tested in my local development environment with flake8 and pylint.
  • The code is both Python 2 and Python 3 compatible.
  • The code follows the PEP8 styling guidelines with 4 spaces indentation.
  • This Pull Request relates to only one issue or only one feature
  • I have referenced the corresponding issue number in my commit message
  • My branch is up-to-date with the Upstream master branch.

Changes proposed in this pull request

following code is been used in every start function of the module which leads to Duplication of code

      if target_type(target) != 'SINGLE_IPv4' or target_type(target) != 'DOMAIN' or target_type(target) != 'HTTP':
              # requirements check
              new_extra_requirements = extra_requirements_dict()
              if methods_args is not None:
                  for extra_requirement in extra_requirements_dict():
                      if extra_requirement in methods_args:
                          new_extra_requirements[
                              extra_requirement] = methods_args[extra_requirement]
              extra_requirements = new_extra_requirements

              #optional
              if target_type(target) == 'HTTP':
                  target = target_to_host(target)

             .
             #main code
             .
      else:
              warn(messages(language, "input_target_error").format(
                  'module_name', target))

we can use decorators e.g: @requirements_check(target_to_host=True,scan_name='xss_vuln') for that and
Also we can use socks proxy decorator as per #187.

Your development environment

  • OS: Backbox
  • OS Version: 7.1
  • Python Version: 3.8.5 and 2.7.17

@itsdivyanshjain itsdivyanshjain changed the title Added decorators requirements_check for reducing code duplication Added decorator requirements_check for reducing code duplication Jan 3, 2021
@Ali-Razmjoo
Copy link
Collaborator

fixed in #440

@Ali-Razmjoo Ali-Razmjoo closed this Sep 9, 2021
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.

2 participants