rapid7/nexpose-client

View on GitHub

Showing 112 of 173 total issues

Class ScanTemplate has 65 methods (exceeds 20 allowed). Consider refactoring.
Open

  class ScanTemplate
    include Sanitize

    # Parsed XML of a scan template.
    attr_reader :xml
Severity: Major
Found in lib/nexpose/scan_template.rb - About 1 day to fix

    File scan.rb has 490 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Nexpose
      class Connection
        include XMLUtils
    
        # Perform an ad hoc scan of a single device.
    Severity: Minor
    Found in lib/nexpose/scan.rb - About 7 hrs to fix

      File site.rb has 417 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Nexpose
      
        class Connection
          include XMLUtils
      
      
      Severity: Minor
      Found in lib/nexpose/site.rb - About 6 hrs to fix

        File report.rb has 412 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        module Nexpose
        
          class Connection
            include XMLUtils
        
        
        Severity: Minor
        Found in lib/nexpose/report.rb - About 5 hrs to fix

          Method execute has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
          Open

              def execute(options = {})
                @conn_tries = 0
                begin
                  prepare_http_client
                  @http.read_timeout = options.key?(:timeout) ? options[:timeout] : 120
          Severity: Minor
          Found in lib/nexpose/api_request.rb - About 5 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 from_hash has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.from_hash(hash)
                start = nil
                start = Nexpose::ISO8601.to_time(hash[:start_date]) if hash[:start_date]
                repeat_scan_hash = hash[:repeat_scan]
                if repeat_scan_hash.nil?
          Severity: Minor
          Found in lib/nexpose/common.rb - About 4 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 to_h has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
          Open

              def to_h
                schedule_hash = {
                  enabled: @enabled,
                  scan_template_id: @scan_template_id,
                  maximum_scan_duration: @max_duration
          Severity: Minor
          Found in lib/nexpose/common.rb - About 4 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

          File scan_template.rb has 356 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module Nexpose
          
            class Connection
          
              # List the scan templates currently configured on the console.
          Severity: Minor
          Found in lib/nexpose/scan_template.rb - About 4 hrs to fix

            Class Site has 34 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class Site < APIObject
                include JsonSerializer
                # The site ID. An ID of -1 is used to designate a site that has not been
                # saved to a Nexpose console.
                attr_accessor :id
            Severity: Minor
            Found in lib/nexpose/site.rb - About 4 hrs to fix

              Method list_vuln_exceptions has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
              Open

                  def list_vuln_exceptions(status = nil)
                    unless is_valid_vuln_exception_status?(status)
                      raise "Unknown Status ~> '#{status}' :: For available options refer to Nexpose::VulnException::Status"
                    end
              
              
              Severity: Minor
              Found in lib/nexpose/vuln_exception.rb - About 3 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

              Class Connection has 27 methods (exceeds 20 allowed). Consider refactoring.
              Open

                class Connection
                  include XMLUtils
              
                  # Perform an ad hoc scan of a single device.
                  #
              Severity: Minor
              Found in lib/nexpose/scan.rb - About 3 hrs to fix

                File common.rb has 298 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                module Nexpose
                  # Constants useful across the Nexpose module.
                  module Scope
                    GLOBAL = 'global'
                    SILO   = 'silo'
                Severity: Minor
                Found in lib/nexpose/common.rb - About 3 hrs to fix

                  Method execute has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def execute(options = {})
                        @conn_tries = 0
                        begin
                          prepare_http_client
                          @http.read_timeout = options.key?(:timeout) ? options[:timeout] : 120
                  Severity: Major
                  Found in lib/nexpose/api_request.rb - About 2 hrs to fix

                    Method deserialize has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def deserialize(data)
                          data.each do |key, value|
                            if respond_to?(key)
                              property = value
                              if value.respond_to? :each
                    Severity: Minor
                    Found in lib/nexpose/json_serializer.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 generate has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def generate(connection, timeout = 300, raw = false)
                          xml = %(<ReportAdhocGenerateRequest session-id="#{connection.session_id}">)
                          xml << to_xml
                          xml << '</ReportAdhocGenerateRequest>'
                          response = connection.execute(xml, '1.1', timeout: timeout, raw: raw)
                    Severity: Minor
                    Found in lib/nexpose/report.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 validate has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def validate
                          raise ArgumentError.new('No vuln_id.') unless @vuln_id
                          raise ArgumentError.new('No scope.') unless @scope
                          raise ArgumentError.new('No reason.') unless @reason
                    
                    
                    Severity: Minor
                    Found in lib/nexpose/vuln_exception.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

                    File silo.rb has 268 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    module Nexpose
                    
                      class Connection
                        include XMLUtils
                    
                    
                    Severity: Minor
                    Found in lib/nexpose/silo.rb - About 2 hrs to fix

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

                          def self.parse(xml)
                            rexml = REXML::Document.new(xml)
                            rexml.elements.each('Credential') do |c|
                              cred = new(c.elements['Name'].text, c.attributes['id'].to_i)
                      
                      
                      Severity: Minor
                      Found in lib/nexpose/shared_credential.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 parse has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def self.parse(xml)
                            rexml = REXML::Document.new(xml)
                            rexml.elements.each('Credential') do |c|
                              cred = new(c.elements['Name'].text, c.attributes['id'].to_i)
                      
                      
                      Severity: Minor
                      Found in lib/nexpose/shared_credential.rb - About 1 hr to fix

                        Method as_xml has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def as_xml
                              xml = REXML::Element.new('Schedule')
                              xml.attributes['enabled']       = @enabled ? 1 : 0
                              xml.attributes['type']          = @type
                              xml.attributes['interval']      = @interval
                        Severity: Minor
                        Found in lib/nexpose/common.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

                        Severity
                        Category
                        Status
                        Source
                        Language