rapid7/metasploit_data_models

View on GitHub

Showing 32 of 32 total issues

File operating_system_normalization.rb has 457 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'recog'

#
# Rules for operating system fingerprinting in Metasploit
#
Severity: Minor
Found in lib/mdm/host/operating_system_normalization.rb - About 7 hrs to fix

    Method apply_match_to_host has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

      def apply_match_to_host(match)
        host = self
    
        # These values in a match always override the current value unless
        # the host attribute has been explicitly locked by the user
    Severity: Minor
    Found in lib/mdm/host/operating_system_normalization.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 normalize_nexpose_fingerprint has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

      def normalize_nexpose_fingerprint(data)
        ret = {}
        # :family=>"Windows" :certainty=>"0.85" :vendor=>"Microsoft" :product=>"Windows 7 Ultimate Edition"
        # :family=>"Windows" :certainty=>"0.67" :vendor=>"Microsoft" :arch=>"x86" :product=>'Windows 7' :version=>'SP1'
        # :family=>"Linux" :certainty=>"0.64" :vendor=>"Linux" :product=>"Linux"
    Severity: Minor
    Found in lib/mdm/host/operating_system_normalization.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 recog_matches_for_note has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

      def recog_matches_for_note(note)
        # Skip notes that are missing the correct structure or have been blacklisted
        return [] if not validate_fingerprint_data(note)
    
        #
    Severity: Minor
    Found in lib/mdm/host/operating_system_normalization.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 apply_match_to_host has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def apply_match_to_host(match)
        host = self
    
        # These values in a match always override the current value unless
        # the host attribute has been explicitly locked by the user
    Severity: Minor
    Found in lib/mdm/host/operating_system_normalization.rb - About 1 hr to fix

      Method normalize_match has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        def normalize_match(m)
          # Normalize os.version strings containing 'Service Pack X' to just 'SPX'
          if m['os.version'] and m['os.version'].index('Service Pack ') == 0
            m['os.version'] = m['os.version'].gsub(/Service Pack /, 'SP')
          end
      Severity: Minor
      Found in lib/mdm/host/operating_system_normalization.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 parse_windows_os_str has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def parse_windows_os_str(str)
          ret = {}
      
          # Set some reasonable defaults for Windows
          ret['os.vendor']  = 'Microsoft'
      Severity: Minor
      Found in lib/mdm/host/operating_system_normalization.rb - About 1 hr to fix

        Method normalize_nexpose_fingerprint has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def normalize_nexpose_fingerprint(data)
            ret = {}
            # :family=>"Windows" :certainty=>"0.85" :vendor=>"Microsoft" :product=>"Windows 7 Ultimate Edition"
            # :family=>"Windows" :certainty=>"0.67" :vendor=>"Microsoft" :arch=>"x86" :product=>'Windows 7' :version=>'SP1'
            # :family=>"Linux" :certainty=>"0.64" :vendor=>"Linux" :product=>"Linux"
        Severity: Minor
        Found in lib/mdm/host/operating_system_normalization.rb - About 1 hr to fix

          Method recog_matches_for_note has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def recog_matches_for_note(note)
              # Skip notes that are missing the correct structure or have been blacklisted
              return [] if not validate_fingerprint_data(note)
          
              #
          Severity: Minor
          Found in lib/mdm/host/operating_system_normalization.rb - About 1 hr to fix

            Method normalize_nessus_fingerprint has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def normalize_nessus_fingerprint(data)
                ret = {}
                # :os=>"Microsoft Windows 2000 Advanced Server (English)"
                # :os=>"Microsoft Windows 2000\nMicrosoft Windows XP"
                # :os=>"Linux Kernel 2.6"
            Severity: Minor
            Found in lib/mdm/host/operating_system_normalization.rb - About 1 hr to fix

              Method guess_purpose_from_match has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def guess_purpose_from_match(match)
                  # some data that is sent to this is numeric; we do not want that
                  pstr = ""
                  # Go through each character of each value and make sure it is all
                  # UTF-8
              Severity: Minor
              Found in lib/mdm/host/operating_system_normalization.rb - About 1 hr to fix

                Method normalize_qualys_fingerprint has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  def normalize_qualys_fingerprint(data)
                    ret = {}
                    # :os=>"Microsoft Windows 2000"
                    # :os=>"Windows 2003"
                    # :os=>"Microsoft Windows XP Professional SP3"
                Severity: Minor
                Found in lib/mdm/host/operating_system_normalization.rb - About 55 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 normalize_os has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  def normalize_os
                    host   = self
                    matches = []
                
                    # Note that we're already restricting the query to this host by using
                Severity: Minor
                Found in lib/mdm/host/operating_system_normalization.rb - About 55 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 to_url has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  def to_url(ignore_vhost=false)
                    proto = self.service.name == "https" ? "https" : "http"
                    host = ignore_vhost ? self.service.host.address.to_s : self.vhost
                    port = self.service.port
                
                
                Severity: Minor
                Found in app/models/mdm/web_site.rb - About 55 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 normalize_nmap_fingerprint has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  def normalize_nmap_fingerprint(data)
                    ret = {}
                
                    # :os_vendor=>"Microsoft" :os_family=>"Windows" :os_version=>"2000" :os_accuracy=>"94"
                    ret['os.certainty'] = ( data[:os_accuracy].to_f / 100.0 ).to_s if data[:os_accuracy]
                Severity: Minor
                Found in lib/mdm/host/operating_system_normalization.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 load has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  def load(value)
                    loaded = nil
                
                    if value.blank?
                      loaded = default
                Severity: Minor
                Found in lib/metasploit_data_models/base64_serializer.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 guess_purpose_from_match has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def guess_purpose_from_match(match)
                    # some data that is sent to this is numeric; we do not want that
                    pstr = ""
                    # Go through each character of each value and make sure it is all
                    # UTF-8
                Severity: Minor
                Found in lib/mdm/host/operating_system_normalization.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 delete_file has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def delete_file
                    c = Pro::Client.get rescue nil
                    if c
                      c.task_delete_log(self[:id]) if c
                    else
                Severity: Minor
                Found in app/models/mdm/task.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 recog_matches_for_service has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def recog_matches_for_service(s)
                    #
                    # We assume that the service.info field contains certain types of probe
                    # replies and associate these with one or more Recog databases. The mapping
                    # of service.name to a specific database only fits into so many places and
                Severity: Minor
                Found in lib/mdm/host/operating_system_normalization.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 ip_address_invalid? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def ip_address_invalid?
                    begin
                      if address.is_a? IPAddr
                        potential_ip = address.dup
                      else
                Severity: Minor
                Found in app/models/mdm/host.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

                Severity
                Category
                Status
                Source
                Language