rapid7/metasploit-framework

View on GitHub
lib/msf/core/rpc/v10/rpc_module.rb

Summary

Maintainability
F
4 days
Test Coverage

File rpc_module.rb has 474 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'json'

module Msf
module RPC
class RPC_Module < RPC_Base
Severity: Minor
Found in lib/msf/core/rpc/v10/rpc_module.rb - About 7 hrs to fix

    Class RPC_Module has 37 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class RPC_Module < RPC_Base
    
      # Returns a list of exploit names. The 'exploit/' prefix will not be included.
      #
      # @return [Hash] A list of exploit names. It contains the following key:
    Severity: Minor
    Found in lib/msf/core/rpc/v10/rpc_module.rb - About 4 hrs to fix

      Method rpc_info has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

        def rpc_info(mtype, mname)
          m = _find_module(mtype,mname)
          res = module_short_info(m)
          res['description'] = Rex::Text.compress(m.description)
          res['license'] = m.license
      Severity: Minor
      Found in lib/msf/core/rpc/v10/rpc_module.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 rpc_payloads has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def rpc_payloads(module_info = nil, arch = nil)
          module_info_contains_size = false
      
          unless module_info.nil?
            module_info = module_info.strip.split(',').map(&:strip)
      Severity: Minor
      Found in lib/msf/core/rpc/v10/rpc_module.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 rpc_info has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def rpc_info(mtype, mname)
          m = _find_module(mtype,mname)
          res = module_short_info(m)
          res['description'] = Rex::Text.compress(m.description)
          res['license'] = m.license
      Severity: Minor
      Found in lib/msf/core/rpc/v10/rpc_module.rb - About 2 hrs to fix

        Method rpc_encode has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def rpc_encode(data, encoder, options)
            # Load supported formats
            supported_formats = Msf::Simple::Buffer.transform_formats + Msf::Util::EXE.to_executable_fmt_formats
        
            if (fmt = options['format'])
        Severity: Minor
        Found in lib/msf/core/rpc/v10/rpc_module.rb - About 2 hrs to fix

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

            def rpc_encoders(module_info = nil, arch = nil)
              unless module_info.nil?
                module_info = module_info.strip.split(',').map(&:strip)
                module_info.map!(&:to_sym)
              end
          Severity: Minor
          Found in lib/msf/core/rpc/v10/rpc_module.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 rpc_nops has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def rpc_nops(module_info = nil, arch = nil)
              unless module_info.nil?
                module_info = module_info.strip.split(',').map(&:strip)
                module_info.map!(&:to_sym)
              end
          Severity: Minor
          Found in lib/msf/core/rpc/v10/rpc_module.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 rpc_encode has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def rpc_encode(data, encoder, options)
              # Load supported formats
              supported_formats = Msf::Simple::Buffer.transform_formats + Msf::Util::EXE.to_executable_fmt_formats
          
              if (fmt = options['format'])
          Severity: Minor
          Found in lib/msf/core/rpc/v10/rpc_module.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 rpc_payloads has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def rpc_payloads(module_info = nil, arch = nil)
              module_info_contains_size = false
          
              unless module_info.nil?
                module_info = module_info.strip.split(',').map(&:strip)
          Severity: Minor
          Found in lib/msf/core/rpc/v10/rpc_module.rb - About 1 hr to fix

            Method _run_payload has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def _run_payload(mod, opts)
                badchars = opts['BadChars'] || ''
                fmt = opts['Format'] || 'raw'
                force = opts['ForceEncode'] || false
                template = opts['Template'] || nil
            Severity: Minor
            Found in lib/msf/core/rpc/v10/rpc_module.rb - About 1 hr to fix

              Method rpc_results has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def rpc_results(uuid)
                  if (r = self.job_status_tracker.result(uuid))
                    if r[:error]
                      {"status" => "errored", "error" => r[:error]}
                    else
              Severity: Minor
              Found in lib/msf/core/rpc/v10/rpc_module.rb - About 45 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

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

                def rpc_encoders(module_info = nil, arch = nil)
                  unless module_info.nil?
                    module_info = module_info.strip.split(',').map(&:strip)
                    module_info.map!(&:to_sym)
                  end
              Severity: Major
              Found in lib/msf/core/rpc/v10/rpc_module.rb and 1 other location - About 2 hrs to fix
              lib/msf/core/rpc/v10/rpc_module.rb on lines 157..178

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

              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 rpc_nops(module_info = nil, arch = nil)
                  unless module_info.nil?
                    module_info = module_info.strip.split(',').map(&:strip)
                    module_info.map!(&:to_sym)
                  end
              Severity: Major
              Found in lib/msf/core/rpc/v10/rpc_module.rb and 1 other location - About 2 hrs to fix
              lib/msf/core/rpc/v10/rpc_module.rb on lines 116..137

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

              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 rpc_target_compatible_evasion_payloads(mname, target)
                  m   = _find_module('evasion',mname)
                  res = {}
                  res['payloads'] = []
                  m.datastore['TARGET'] = target.to_i
              Severity: Minor
              Found in lib/msf/core/rpc/v10/rpc_module.rb and 1 other location - About 25 mins to fix
              lib/msf/core/rpc/v10/rpc_module.rb on lines 380..389

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

              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 rpc_target_compatible_payloads(mname, target)
                  m   = _find_module('exploit',mname)
                  res = {}
                  res['payloads'] = []
                  m.datastore['TARGET'] = target.to_i
              Severity: Minor
              Found in lib/msf/core/rpc/v10/rpc_module.rb and 1 other location - About 25 mins to fix
              lib/msf/core/rpc/v10/rpc_module.rb on lines 404..413

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

              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 _run_auxiliary(mod, opts)
                  uuid, job = Msf::Simple::Auxiliary.run_simple(mod,{
                    'Action'   => opts['ACTION'],
                    'RunAsJob' => true,
                    'Options'  => opts
              Severity: Minor
              Found in lib/msf/core/rpc/v10/rpc_module.rb and 1 other location - About 25 mins to fix
              lib/msf/core/rpc/v10/rpc_module.rb on lines 786..794

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

              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 _check_auxiliary(mod, opts)
                  uuid, job = Msf::Simple::Auxiliary.check_simple(mod,{
                      'Action'   => opts['ACTION'],
                      'RunAsJob' => true,
                      'Options'  => opts
              Severity: Minor
              Found in lib/msf/core/rpc/v10/rpc_module.rb and 1 other location - About 25 mins to fix
              lib/msf/core/rpc/v10/rpc_module.rb on lines 763..771

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

              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 rpc_compatible_evasion_payloads(mname)
                  m = _find_module('evasion', mname)
                  res = {}
                  res['payloads'] = []
              
              
              Severity: Minor
              Found in lib/msf/core/rpc/v10/rpc_module.rb and 1 other location - About 15 mins to fix
              lib/msf/core/rpc/v10/rpc_module.rb on lines 307..315

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

              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 rpc_compatible_payloads(mname)
                  m   = _find_module('exploit',mname)
                  res = {}
                  res['payloads'] = []
                  m.compatible_payloads.each do |k|
              Severity: Minor
              Found in lib/msf/core/rpc/v10/rpc_module.rb and 1 other location - About 15 mins to fix
              lib/msf/core/rpc/v10/rpc_module.rb on lines 329..338

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

              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