rapid7/metasploit-framework

View on GitHub
lib/msf/core/auxiliary/report.rb

Summary

Maintainability
F
3 days
Test Coverage

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

require 'metasploit/framework/require'

module Msf

###
Severity: Minor
Found in lib/msf/core/auxiliary/report.rb - About 6 hrs to fix

    Method store_loot has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

      def store_loot(ltype, ctype, host, data, filename=nil, info=nil, service=nil, &block)
        if ! ::File.directory?(Msf::Config.loot_directory)
          FileUtils.mkdir_p(Msf::Config.loot_directory)
        end
    
    
    Severity: Minor
    Found in lib/msf/core/auxiliary/report.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 store_cred has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

      def store_cred(opts={})
        if [opts[:port],opts[:sname]].compact.empty?
          raise ArgumentError, "Missing option: :sname or :port"
        end
        cred_opts = opts
    Severity: Minor
    Found in lib/msf/core/auxiliary/report.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 report_auth_info has 77 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def report_auth_info(opts={})
        print_warning("*** #{self.fullname} is still calling the deprecated report_auth_info method! This needs to be updated!")
        print_warning('*** For detailed information about LoginScanners and the Credentials objects see:')
        print_warning('     https://docs.metasploit.com/docs/development/developing-modules/guides/scanners/creating-metasploit-framework-loginscanners.html')
        print_warning('     https://docs.metasploit.com/docs/development/developing-modules/guides/scanners/how-to-write-a-http-loginscanner-module.html')
    Severity: Major
    Found in lib/msf/core/auxiliary/report.rb - About 3 hrs to fix

      Method store_cred has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def store_cred(opts={})
          if [opts[:port],opts[:sname]].compact.empty?
            raise ArgumentError, "Missing option: :sname or :port"
          end
          cred_opts = opts
      Severity: Major
      Found in lib/msf/core/auxiliary/report.rb - About 2 hrs to fix

        Method report_auth_info has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

          def report_auth_info(opts={})
            print_warning("*** #{self.fullname} is still calling the deprecated report_auth_info method! This needs to be updated!")
            print_warning('*** For detailed information about LoginScanners and the Credentials objects see:')
            print_warning('     https://docs.metasploit.com/docs/development/developing-modules/guides/scanners/creating-metasploit-framework-loginscanners.html')
            print_warning('     https://docs.metasploit.com/docs/development/developing-modules/guides/scanners/how-to-write-a-http-loginscanner-module.html')
        Severity: Minor
        Found in lib/msf/core/auxiliary/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 store_local has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

          def store_local(ltype=nil, ctype=nil, data=nil, filename=nil)
            if ! ::File.directory?(Msf::Config.local_directory)
              FileUtils.mkdir_p(Msf::Config.local_directory)
            end
        
        
        Severity: Minor
        Found in lib/msf/core/auxiliary/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 store_loot has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def store_loot(ltype, ctype, host, data, filename=nil, info=nil, service=nil, &block)
            if ! ::File.directory?(Msf::Config.loot_directory)
              FileUtils.mkdir_p(Msf::Config.loot_directory)
            end
        
        
        Severity: Minor
        Found in lib/msf/core/auxiliary/report.rb - About 1 hr to fix

          Method store_local has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def store_local(ltype=nil, ctype=nil, data=nil, filename=nil)
              if ! ::File.directory?(Msf::Config.local_directory)
                FileUtils.mkdir_p(Msf::Config.local_directory)
              end
          
          
          Severity: Minor
          Found in lib/msf/core/auxiliary/report.rb - About 1 hr to fix

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

              def store_loot(ltype, ctype, host, data, filename=nil, info=nil, service=nil, &block)
            Severity: Major
            Found in lib/msf/core/auxiliary/report.rb - About 1 hr to fix

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

                def create_cracked_credential(opts={})
                  if active_db?
                    opts = { :task_id => mytask.id }.merge(opts) if mytask
                    framework.db.create_cracked_credential(opts)
                  elsif !db_warning_given?
              Severity: Minor
              Found in lib/msf/core/auxiliary/report.rb and 4 other locations - About 20 mins to fix
              lib/msf/core/auxiliary/report.rb on lines 37..44
              lib/msf/core/auxiliary/report.rb on lines 47..54
              lib/msf/core/auxiliary/report.rb on lines 57..64
              lib/msf/core/auxiliary/report.rb on lines 67..74

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

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

                def create_credential(opts={})
                  if active_db?
                    opts = { :task_id => mytask.id }.merge(opts) if mytask
                    framework.db.create_credential(opts)
                  elsif !db_warning_given?
              Severity: Minor
              Found in lib/msf/core/auxiliary/report.rb and 4 other locations - About 20 mins to fix
              lib/msf/core/auxiliary/report.rb on lines 27..34
              lib/msf/core/auxiliary/report.rb on lines 47..54
              lib/msf/core/auxiliary/report.rb on lines 57..64
              lib/msf/core/auxiliary/report.rb on lines 67..74

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

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

                def create_credential_login(opts={})
                  if active_db?
                    opts = { :task_id => mytask.id }.merge(opts) if mytask
                    framework.db.create_credential_login(opts)
                  elsif !db_warning_given?
              Severity: Minor
              Found in lib/msf/core/auxiliary/report.rb and 4 other locations - About 20 mins to fix
              lib/msf/core/auxiliary/report.rb on lines 27..34
              lib/msf/core/auxiliary/report.rb on lines 37..44
              lib/msf/core/auxiliary/report.rb on lines 57..64
              lib/msf/core/auxiliary/report.rb on lines 67..74

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

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

                def invalidate_login(opts={})
                  if active_db?
                    opts = { :task_id => mytask.id }.merge(opts) if mytask
                    framework.db.invalidate_login(opts)
                  elsif !db_warning_given?
              Severity: Minor
              Found in lib/msf/core/auxiliary/report.rb and 4 other locations - About 20 mins to fix
              lib/msf/core/auxiliary/report.rb on lines 27..34
              lib/msf/core/auxiliary/report.rb on lines 37..44
              lib/msf/core/auxiliary/report.rb on lines 47..54
              lib/msf/core/auxiliary/report.rb on lines 57..64

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

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

                def create_credential_and_login(opts={})
                  if active_db?
                    opts = { :task_id => mytask.id }.merge(opts) if mytask
                    framework.db.create_credential_and_login(opts)
                  elsif !db_warning_given?
              Severity: Minor
              Found in lib/msf/core/auxiliary/report.rb and 4 other locations - About 20 mins to fix
              lib/msf/core/auxiliary/report.rb on lines 27..34
              lib/msf/core/auxiliary/report.rb on lines 37..44
              lib/msf/core/auxiliary/report.rb on lines 47..54
              lib/msf/core/auxiliary/report.rb on lines 67..74

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

              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

              There are no issues that match your filters.

              Category
              Status