rapid7/nexpose-client

View on GitHub

Showing 173 of 173 total issues

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

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

        def self.build_import_ad_assets_option(name:, discovery_conn_id:, site_id: nil)
          step1 = Step.new(service_name: ServiceNames::ACTIVE_DIRECTORY, type_name: StepNames::DISCOVER_ACTIVE_DIRECTORY)
                      .add_property(StepConfiguration::ConfigParamProperties::DISCOVERY_CONFIG_ID, discovery_conn_id)
          step2 = Step.new(service_name: ServiceNames::NEXPOSE, type_name: StepNames::IMPORT_EXTERNAL, previous_type_name: step1.type_name)
    
    
    Severity: Major
    Found in lib/eso/integration_options_manager.rb and 3 other locations - About 1 hr to fix
    lib/eso/integration_options_manager.rb on lines 77..84
    lib/eso/integration_options_manager.rb on lines 97..104
    lib/eso/integration_options_manager.rb on lines 119..126

    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 52.

    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 4 locations. Consider refactoring.
    Open

        def self.build_import_epo_assets_option(name:, discovery_conn_id:, site_id: nil)
          step1 = Step.new(service_name: ServiceNames::EPO, type_name: StepNames::DISCOVER_EPO)
                      .add_property(StepConfiguration::ConfigParamProperties::DISCOVERY_CONFIG_ID, discovery_conn_id)
          step2 = Step.new(service_name: ServiceNames::NEXPOSE, type_name: StepNames::IMPORT_EXTERNAL, previous_type_name: step1.type_name)
    
    
    Severity: Major
    Found in lib/eso/integration_options_manager.rb and 3 other locations - About 1 hr to fix
    lib/eso/integration_options_manager.rb on lines 87..94
    lib/eso/integration_options_manager.rb on lines 97..104
    lib/eso/integration_options_manager.rb on lines 119..126

    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 52.

    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 4 locations. Consider refactoring.
    Open

        def self.build_sync_aws_assets_option(name:, discovery_conn_id:, site_id: nil)
          step1 = Step.new(service_name: ServiceNames::AWS, type_name: StepNames::DISCOVER_AWS_ASSETS)
                      .add_property(StepConfiguration::ConfigParamProperties::DISCOVERY_CONFIG_ID, discovery_conn_id)
          step2 = Step.new(service_name: ServiceNames::NEXPOSE, type_name: StepNames::SYNC_EXTERNAL, previous_type_name: step1.type_name)
    
    
    Severity: Major
    Found in lib/eso/integration_options_manager.rb and 3 other locations - About 1 hr to fix
    lib/eso/integration_options_manager.rb on lines 77..84
    lib/eso/integration_options_manager.rb on lines 87..94
    lib/eso/integration_options_manager.rb on lines 119..126

    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 52.

    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 4 locations. Consider refactoring.
    Open

        def self.build_sync_azure_assets_option(name:, discovery_conn_id:, site_id: nil)
          step1 = Step.new(service_name: ServiceNames::AZURE, type_name: StepNames::DISCOVER_AZURE_ASSETS)
                      .add_property(StepConfiguration::ConfigParamProperties::DISCOVERY_CONFIG_ID, discovery_conn_id)
          step2 = Step.new(service_name: ServiceNames::NEXPOSE, type_name: StepNames::SYNC_EXTERNAL, previous_type_name: step1.type_name)
    
    
    Severity: Major
    Found in lib/eso/integration_options_manager.rb and 3 other locations - About 1 hr to fix
    lib/eso/integration_options_manager.rb on lines 77..84
    lib/eso/integration_options_manager.rb on lines 87..94
    lib/eso/integration_options_manager.rb on lines 97..104

    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 52.

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

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

          def as_xml
            xml = REXML::Element.new('DiscoveryConnection')
            xml.attributes['name']              = @name
            xml.attributes['address']           = @address
            xml.attributes['port']              = @port
      Severity: Minor
      Found in lib/nexpose/discovery.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 json_initializer has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.json_initializer(filter)
            new(filter[:start] ? 1 : 0,
                filter[:stop] ? 1 : 0,
                filter[:failed] ? 1 : 0,
                filter[:resume] ? 1 : 0,
      Severity: Minor
      Found in lib/nexpose/alert.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 create_discover_known_assets_step has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self.create_discover_known_assets_step(workflow: nil, id:, previous_type_name: StepNames::EMPTY)
            step = Step.new(workflow: workflow,
                     service_name: ServiceNames::NEXPOSE,
                     type_name: StepNames::DISCOVER_KNOWN,
                     previous_type_name: previous_type_name)
      Severity: Minor
      Found in lib/eso/nexpose.rb - About 1 hr to fix

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

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

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

                  def initialize(vuln_exploit, vuln_version, vuln_potential, not_vuln_exploit, not_vuln_version, error, disabled, other)
            Severity: Major
            Found in lib/nexpose/scan.rb - About 1 hr to fix

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

                  def remove_excluded_ip_range(from, to)
                    from_ip = IPAddr.new(from)
                    to_ip   = IPAddr.new(to)
                    (from_ip..to_ip)
                    raise 'Invalid IP range specified' if (from_ip..to_ip).to_a.size.zero?
              Severity: Minor
              Found in lib/nexpose/site.rb and 1 other location - About 1 hr to fix
              lib/nexpose/site.rb on lines 254..262

              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 47.

              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 remove_included_ip_range(from, to)
                    from_ip = IPAddr.new(from)
                    to_ip   = IPAddr.new(to)
                    (from_ip..to_ip)
                    raise 'Invalid IP range specified' if (from_ip..to_ip).to_a.size.zero?
              Severity: Minor
              Found in lib/nexpose/site.rb and 1 other location - About 1 hr to fix
              lib/nexpose/site.rb on lines 300..308

              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 47.

              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 <=> has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def <=>(other)
                    return 1 unless other.respond_to? :from
                    from    = IPAddr.new(@from)
                    to      = @to.nil? ? from : IPAddr.new(@to)
                    cf_from = IPAddr.new(other.from)
              Severity: Minor
              Found in lib/nexpose/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 to_xml has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def to_xml
                    xml = %(<ReportTemplate id='#{@id}' name='#{@name}' type='#{@type}')
                    xml << %( scope='#{@scope}') if @scope
                    xml << %( builtin='#{@built_in}') if @built_in
                    xml << '>'
              Severity: Minor
              Found in lib/nexpose/report_template.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 load has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def self.load(connection, user_id)
                    xml = '<UserConfigRequest session-id="' + connection.session_id + '"'
                    xml << %( id="#{user_id}" )
                    xml << ' />'
                    r = connection.execute(xml, '1.1')
              Severity: Minor
              Found in lib/nexpose/user.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 initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def initialize(ip, user, pass, port = 3780, silo_id = nil, token = nil, trust_cert = nil)
              Severity: Major
              Found in lib/nexpose/connection.rb - About 50 mins to fix

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

                    def initialize(config_id, name, template_id, status, generated_on, uri, scope)
                Severity: Major
                Found in lib/nexpose/report.rb - About 50 mins to fix

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

                      def initialize(name, sender, server, recipients, enabled = 1, max_alerts = -1, verbose = 0)
                  Severity: Major
                  Found in lib/nexpose/alert.rb - About 50 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language