rapid7/metasploit-credential

View on GitHub

Showing 29 of 29 total issues

Method import_long_form has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring.
Open

  def import_long_form
    all_creds_valid = true
    realms = Hash.new
    Metasploit::Credential::Core.transaction do
      core_opts = []
Severity: Minor
Found in lib/metasploit/credential/importer/core.rb - About 1 day 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 creation.rb has 323 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rex/socket'

# Implements a set of "convenience methods" for creating credentials and related portions of the object graph.  Creates
# {Metasploit::Credential::Core} objects and their attendant relationships as well as {Metasploit::Credential::Login}
# objects and their attendant `Mdm::Host` and `Mdm::Service` objects.
Severity: Minor
Found in lib/metasploit/credential/creation.rb - About 3 hrs to fix

    Method create_credential_login has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

      def create_credential_login(opts={})
        return nil unless active_db?
    
        if self.respond_to?(:[]) and self[:task]
          opts[:task_id] ||= self[:task].record.id
    Severity: Minor
    Found in lib/metasploit/credential/creation.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

    Method import_short_form has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

      def import_short_form
        core_opts = []
        all_creds_valid = true
        Metasploit::Credential::Core.transaction do
          csv_object.each do |row|
    Severity: Minor
    Found in lib/metasploit/credential/importer/core.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

    Method import_long_form has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def import_long_form
        all_creds_valid = true
        realms = Hash.new
        Metasploit::Credential::Core.transaction do
          core_opts = []
    Severity: Major
    Found in lib/metasploit/credential/importer/core.rb - About 2 hrs to fix

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

        def create_credential_and_login(opts={})
          return nil unless active_db?
      
          if self.respond_to?(:[]) and self[:task]
            opts[:task_id] ||= self[:task].record.id
      Severity: Minor
      Found in lib/metasploit/credential/creation.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 import! has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def import!
          service_info = nil
          Metasploit::Credential::Core.transaction do
            input.each_line do |line|
              case line
      Severity: Major
      Found in lib/metasploit/credential/importer/pwdump.rb - About 2 hrs to fix

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

          def import!
            service_info = nil
            Metasploit::Credential::Core.transaction do
              input.each_line do |line|
                case line
        Severity: Minor
        Found in lib/metasploit/credential/importer/pwdump.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 consistent_workspaces has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

          def consistent_workspaces
            case origin
              when Metasploit::Credential::Origin::Manual
                user = origin.user
        
        
        Severity: Minor
        Found in app/models/metasploit/credential/core.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_cracked_credential has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def create_cracked_credential(opts={})
            return nil unless active_db?
        
            if self.respond_to?(:[]) and self[:task]
              opts[:task_id] ||= self[:task].record.id
        Severity: Minor
        Found in lib/metasploit/credential/creation.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_cracked_credential has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def create_cracked_credential(opts={})
            return nil unless active_db?
        
            if self.respond_to?(:[]) and self[:task]
              opts[:task_id] ||= self[:task].record.id
        Severity: Minor
        Found in lib/metasploit/credential/creation.rb - About 1 hr to fix

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

            def create_credential_private(opts={})
              return nil unless active_db?
              private_data = opts.fetch(:private_data)
              private_type = opts.fetch(:private_type)
          
          
          Severity: Minor
          Found in lib/metasploit/credential/creation.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_credential has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def create_credential(opts={})
              return nil unless active_db?
          
              if self.respond_to?(:[]) and self[:task]
                opts[:task_id] ||= self[:task].record.id
          Severity: Minor
          Found in lib/metasploit/credential/creation.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_credential_private has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def create_credential_private(opts={})
              return nil unless active_db?
              private_data = opts.fetch(:private_data)
              private_type = opts.fetch(:private_type)
          
          
          Severity: Minor
          Found in lib/metasploit/credential/creation.rb - About 1 hr to fix

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

              scope :services_hosts, lambda {
                core_table    = Metasploit::Credential::Core.arel_table
                service_table = Mdm::Service.arel_table
                host_table    = Mdm::Host.arel_table
                origin_table  = Metasploit::Credential::Origin::Service.arel_table.alias('origins_for_service')
            Severity: Major
            Found in app/models/metasploit/credential/core.rb and 1 other location - About 1 hr to fix
            app/models/metasploit/credential/core.rb on lines 190..198

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

            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

              scope :sessions_hosts, lambda {
                core_table    = Metasploit::Credential::Core.arel_table
                session_table = Mdm::Session.arel_table
                host_table    = Mdm::Host.arel_table
                origin_table  = Metasploit::Credential::Origin::Session.arel_table.alias('origins_for_session')
            Severity: Major
            Found in app/models/metasploit/credential/core.rb and 1 other location - About 1 hr to fix
            app/models/metasploit/credential/core.rb on lines 173..181

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

            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 create_credential_login has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def create_credential_login(opts={})
                return nil unless active_db?
            
                if self.respond_to?(:[]) and self[:task]
                  opts[:task_id] ||= self[:task].record.id
            Severity: Minor
            Found in lib/metasploit/credential/creation.rb - About 1 hr to fix

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

                def create_credential_and_login(opts={})
                  return nil unless active_db?
              
                  if self.respond_to?(:[]) and self[:task]
                    opts[:task_id] ||= self[:task].record.id
              Severity: Minor
              Found in lib/metasploit/credential/creation.rb - About 1 hr to fix

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

                  def self.cluster(*classes)
                    class_queue = classes.dup
                    visited_class_set = Set.new
                
                    until class_queue.empty?
                Severity: Minor
                Found in lib/metasploit/credential/entity_relationship_diagram.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 header_format_and_csv_wellformedness has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                  def header_format_and_csv_wellformedness
                    begin
                      if csv_object.header_row?
                        csv_headers = csv_object.first.fields
                        if csv_headers_are_correct?(csv_headers)
                Severity: Minor
                Found in lib/metasploit/credential/importer/core.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