rapid7/nexpose-client

View on GitHub

Showing 112 of 173 total issues

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

    def as_xml
      xml = REXML::Element.new('Credential')
      xml.add_attribute('id', @id)
      xml.add_element('Name').add_text(@name)
      xml.add_element('Description').add_text(@description)
Severity: Minor
Found in lib/nexpose/shared_credential.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 as_xml has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def as_xml
      xml = REXML::Element.new('SiloProfileConfig')
      xml.add_attributes({ 'id' => @id,
                           'name' => @name,
                           'description' => @description,
Severity: Minor
Found in lib/nexpose/silo_profile.rb - About 1 hr to fix

    Method list_vuln_exceptions has 44 lines of code (exceeds 25 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 1 hr to fix

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

            def parse(data)
              prev = nil
              data.gsub("\r", '').split("\n").each do |line|
      
                # Handle header folding
      Severity: Minor
      Found in lib/nexpose/rexlite/mime/header.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 initialize has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

            def initialize(data=nil)
              self.header = Rexlite::MIME::Header.new
              self.parts  = []
              self.bound  = "_Part_#{rand(1024)}_#{rand(0xffffffff)}_#{rand(0xffffffff)}"
              self.content = ''
      Severity: Minor
      Found in lib/nexpose/rexlite/mime/message.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 has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.parse(xml)
            schedule = Schedule.new(xml.attributes['type'],
                                    xml.attributes['interval'].to_i,
                                    xml.attributes['start'],
                                    xml.attributes['enabled'] != '0')
      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

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

            def process_operands(operands)
              @operands =
                if ["IS_EMPTY", "IS_NOT_EMPTY"].include? @operator
                  nil
                elsif @type == "#{Eso::Filters::IP_ADDRESS}_ITEM" ||
      Severity: Minor
      Found in lib/eso/filter.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 object_from_hash has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def object_from_hash(nsc, hash)
            hash.each do |k, v|
              next if k == :url # Do not store self-referential URL.
              # Store resource URLs separately and create lazy accessors.
              if v.is_a?(Hash) && v.key?(:url)
      Severity: Minor
      Found in lib/nexpose/api.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 as_xml has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def as_xml
            xml = REXML::Element.new('Credential')
            xml.add_attribute('id', @id)
            xml.add_element('Name').add_text(@name)
            xml.add_element('Description').add_text(@description)
      Severity: Minor
      Found in lib/nexpose/shared_credential.rb - About 1 hr to fix

        Method generate_report has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def generate_report(report_id, wait = false)
              xml = make_xml('ReportGenerateRequest', { 'report-id' => report_id })
              response = execute(xml)
              if response.success
                response.res.elements.each('//ReportSummary') do |summary|
        Severity: Minor
        Found in lib/nexpose/report.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 as_xml has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def as_xml
              xml = REXML::Element.new('SiloProfileConfig')
              xml.add_attributes({ 'id' => @id,
                                   'name' => @name,
                                   'description' => @description,
        Severity: Minor
        Found in lib/nexpose/silo_profile.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 has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def self.parse(xml)
                new do |merchant|
                  merchant.acquirer_relationship = xml.attributes['acquirer-relationship'].to_s.chomp.eql?('true')
                  merchant.agent_relationship    = xml.attributes['agent-relationship'].to_s.chomp.eql?('true')
                  merchant.ecommerce             = xml.attributes['ecommerce'].to_s.chomp.eql?('true')
        Severity: Minor
        Found in lib/nexpose/silo.rb - About 1 hr to fix

          Method initialize has 11 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def initialize(id, auth_source, auth_module, name, full_name, email, is_admin, is_disabled, is_locked, site_count, group_count)
          Severity: Major
          Found in lib/nexpose/user.rb - About 1 hr to fix

            Method to_hash has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def to_hash
                    hash = {
                      valueClass: "Object",
                      objectType: @type,
                      properties: {
            Severity: Minor
            Found in lib/eso/filter.rb - About 1 hr to fix

              Method initialize has 10 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def initialize(scan_id, site_id, engine_id, status, start_time, end_time, message, tasks, nodes, vulnerabilities)
              Severity: Major
              Found in lib/nexpose/scan.rb - About 1 hr to fix

                Method initialize has 10 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def initialize(name, full_name, password, role_name = 'user', id = -1, enabled = 1, email = nil, all_sites = false, all_groups = false, token = nil)
                Severity: Major
                Found in lib/nexpose/user.rb - About 1 hr to fix

                  Method workflow_histories has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def workflow_histories(starttime, endtime)
                        histories = []
                        json_data = get(url: "#{@url}workflows/history/#{starttime}/#{endtime}")
                        json_data.each do |wf|
                          # Initialize WorkflowHistory elements
                  Severity: Minor
                  Found in lib/eso/conductor.rb - About 1 hr to fix

                    Method from_hash has 31 lines of code (exceeds 25 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 1 hr to fix

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

                          def self.create(hash)
                            alert_type = hash[:alert_type]
                            raise 'An alert must have an alert type' if alert_type.nil?
                            raise 'Alert name cannot be empty.' if !hash.key?(:name) || hash[:name].to_s == ''
                            raise 'SNMP and Syslog alerts must have a server defined' if ['SNMP', 'Syslog'].include?(alert_type) && hash[:server].to_s == ''
                      Severity: Minor
                      Found in lib/nexpose/alert.rb - About 1 hr to fix

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

                              def process_operands(operands)
                                @operands =
                                  if ["IS_EMPTY", "IS_NOT_EMPTY"].include? @operator
                                    nil
                                  elsif @type == "#{Eso::Filters::IP_ADDRESS}_ITEM" ||
                        Severity: Minor
                        Found in lib/eso/filter.rb - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language