rapid7/metasploit-framework

View on GitHub
modules/exploits/linux/http/axis_app_install.rb

Summary

Maintainability
C
1 day
Test Coverage

Method initialize has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'Axis IP Camera Application Upload',
Severity: Major
Found in modules/exploits/linux/http/axis_app_install.rb - About 2 hrs to fix

    Method create_eap has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def create_eap(payload, appname)
        print_status("Creating an application package named: #{appname}")
        script_name = "#{Rex::Text.rand_text_alpha_lower(3..8)}.sh"
    
        package_conf = "PACKAGENAME='#{Rex::Text.rand_text_alpha(4..14)}'\n" \
    Severity: Minor
    Found in modules/exploits/linux/http/axis_app_install.rb - About 1 hr to fix

      Method exploit has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def exploit
          appname = Rex::Text.rand_text_alpha_lower(3)
          eap = create_eap(payload.encoded, appname)
      
          # Instruct the application to install the constructed EAP
      Severity: Minor
      Found in modules/exploits/linux/http/axis_app_install.rb - About 1 hr to fix

        Method exploit has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def exploit
            appname = Rex::Text.rand_text_alpha_lower(3)
            eap = create_eap(payload.encoded, appname)
        
            # Instruct the application to install the constructed EAP
        Severity: Minor
        Found in modules/exploits/linux/http/axis_app_install.rb - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method check has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def check
            # grab the brand/model. Shouldn't require authentication.
            res = send_request_cgi({
              'method' => 'GET',
              'uri' => normalize_uri(target_uri.path, '/axis-cgi/prod_brand_info/getbrand.cgi')
        Severity: Minor
        Found in modules/exploits/linux/http/axis_app_install.rb - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Avoid too many return statements within this method.
        Open

            return CheckCode::Safe(check_comment) if res.code != 200
        Severity: Major
        Found in modules/exploits/linux/http/axis_app_install.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

              return CheckCode::Safe(check_comment) unless res.body.include?('<reply result="ok">') != 200
          Severity: Major
          Found in modules/exploits/linux/http/axis_app_install.rb - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status