rapid7/metasploit-framework

View on GitHub
lib/rex/parser/appscan_document.rb

Summary

Maintainability
F
3 days
Test Coverage

File appscan_document.rb has 315 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "rex/parser/nokogiri_doc_mixin"

module Rex
  module Parser

Severity: Minor
Found in lib/rex/parser/appscan_document.rb - About 3 hrs to fix

    Class AppscanDocument has 24 methods (exceeds 20 allowed). Consider refactoring.
    Open

        load_nokogiri && class AppscanDocument < Nokogiri::XML::SAX::Document
    
        include NokogiriDocMixin
    
        # The resolver prefers your local /etc/hosts (or windows equiv), but will
    Severity: Minor
    Found in lib/rex/parser/appscan_document.rb - About 2 hrs to fix

      Method report_web_site has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def report_web_site(&block)
            return unless @state[:uri]
            uri = @state[:uri]
            hostname = uri.host # Assume the first one is the real hostname
            address = resolve_issue_url_address(uri)
      Severity: Minor
      Found in lib/rex/parser/appscan_document.rb - About 2 hrs 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 report_web_page has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def report_web_page(&block)
            return unless(in_issue && has_text)
            return unless @state[:web_site].present?
            return unless @state[:response_headers].present?
            return unless @state[:uri].present?
      Severity: Minor
      Found in lib/rex/parser/appscan_document.rb - About 2 hrs 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 report_web_form has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def report_web_form(page_info,&block)
            return unless(in_issue && has_text)
            return unless page_info.kind_of? Hash
            return unless @state[:request_body]
            return if @state[:request_body].strip.empty?
      Severity: Minor
      Found in lib/rex/parser/appscan_document.rb - About 2 hrs 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 report_web_vuln has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def report_web_vuln(form_info,&block)
            return unless(in_issue && has_text)
            return unless form_info.kind_of? Hash
            return unless @state[:issue]
            return unless @state[:issue]["Noise"]
      Severity: Minor
      Found in lib/rex/parser/appscan_document.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 report_web_site has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def report_web_site(&block)
            return unless @state[:uri]
            uri = @state[:uri]
            hostname = uri.host # Assume the first one is the real hostname
            address = resolve_issue_url_address(uri)
      Severity: Minor
      Found in lib/rex/parser/appscan_document.rb - About 1 hr to fix

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

            def report_service_info
              return unless(in_issue && has_text)
              return unless @state[:web_site]
              return unless @state[:response_headers]
              banner = @state[:response_headers]["server"]
        Severity: Minor
        Found in lib/rex/parser/appscan_document.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 end_element has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def end_element(name=nil)
              block = @block
              case name
              when "Issue" # Wrap it up
                record_issue
        Severity: Minor
        Found in lib/rex/parser/appscan_document.rb - About 1 hr to fix

          Method report_web_page has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def report_web_page(&block)
                return unless(in_issue && has_text)
                return unless @state[:web_site].present?
                return unless @state[:response_headers].present?
                return unless @state[:uri].present?
          Severity: Minor
          Found in lib/rex/parser/appscan_document.rb - About 1 hr to fix

            Method collect_entity has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def collect_entity(attrs)
                  return unless in_issue
                  return unless @state[:issue].kind_of? Hash
                  ent_hash = attr_hash(attrs)
                  return unless ent_hash
            Severity: Minor
            Found in lib/rex/parser/appscan_document.rb - About 45 mins 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 record_request_and_response has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def record_request_and_response
                  return unless(in_issue && has_text)
                  return unless @state[:web_site].present?
                  really_original_traffic = unindent_and_crlf(@text)
                  request_headers, request_body, response_headers, response_body = really_original_traffic.split(/\r\n\r\n/)
            Severity: Minor
            Found in lib/rex/parser/appscan_document.rb - About 45 mins 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 record_issue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def record_issue
                  return unless in_issue
                  return unless @report_data[:issue].kind_of? Hash
                  return unless @state[:web_site]
                  return if @state[:issue]["Noise"].to_s.downcase == "true"
            Severity: Minor
            Found in lib/rex/parser/appscan_document.rb - About 35 mins 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 record_url has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def record_url
                  return unless in_issue
                  return unless has_text
                  uri = URI.parse(@text) rescue nil
                  return unless uri
            Severity: Minor
            Found in lib/rex/parser/appscan_document.rb - About 35 mins 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 unless code
            Severity: Major
            Found in lib/rex/parser/appscan_document.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    return unless @state[:issue]["Noise"].to_s.downcase == "false"
              Severity: Major
              Found in lib/rex/parser/appscan_document.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                      return unless parsed_params
                Severity: Major
                Found in lib/rex/parser/appscan_document.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                        return unless service.info.to_s.empty?
                  Severity: Major
                  Found in lib/rex/parser/appscan_document.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                          return unless @state[:issue][:vuln_param]
                    Severity: Major
                    Found in lib/rex/parser/appscan_document.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                            return if parsed_params.empty?
                      Severity: Major
                      Found in lib/rex/parser/appscan_document.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                              return if parsed_headers.empty?
                        Severity: Major
                        Found in lib/rex/parser/appscan_document.rb - About 30 mins to fix

                          Method in_issue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def in_issue
                                return false unless in_tag("Issue")
                                return false unless in_tag("Issues")
                                return false unless in_tag("XmlReport")
                                return true
                          Severity: Minor
                          Found in lib/rex/parser/appscan_document.rb - About 25 mins 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 end_element has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def end_element(name=nil)
                                block = @block
                                case name
                                when "Issue" # Wrap it up
                                  record_issue
                          Severity: Minor
                          Found in lib/rex/parser/appscan_document.rb - About 25 mins 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

                          There are no issues that match your filters.

                          Category
                          Status