rapid7/nexpose-client

View on GitHub

Showing 173 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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            def self.build_verify_aws_targets_option(name:, discovery_conn_id:)
              step1 = Step.new(service_name: ServiceNames::AWS, type_name: StepNames::VERIFY_AWS_ASSETS)
                          .add_property(StepConfiguration::ConfigParamProperties::DISCOVERY_CONFIG_ID, discovery_conn_id)
              step2 = Step.new(service_name: ServiceNames::NEXPOSE, type_name: StepNames::VERIFY_EXTERNAL_TARGETS,
                               previous_type_name: step1.type_name)
        Severity: Major
        Found in lib/eso/integration_options_manager.rb and 1 other location - About 1 hr to fix
        lib/eso/integration_options_manager.rb on lines 162..168

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 61.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            def self.build_find_vuln_details_option(name:, discovery_conn_id:)
              step1 = Step.new(service_name: ServiceNames::DXL, type_name: StepNames::VULN_DETAILS_REQUEST)
                          .add_property(StepConfiguration::ConfigParamProperties::DISCOVERY_CONFIG_ID, discovery_conn_id)
              step2 = Step.new(service_name: ServiceNames::NEXPOSE, type_name: StepNames::VULN_DETAILS, previous_type_name: step1.type_name)
              step3 = Step.new(service_name: ServiceNames::DXL, type_name: StepNames::VULN_DETAILS_REQUEST, previous_type_name: step2.type_name)
        Severity: Major
        Found in lib/eso/integration_options_manager.rb and 1 other location - About 1 hr to fix
        lib/eso/integration_options_manager.rb on lines 107..116

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 61.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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
                      Severity
                      Category
                      Status
                      Source
                      Language