rapid7/metasploit-framework

View on GitHub
plugins/lab.rb

Summary

Maintainability
F
4 days
Test Coverage

File lab.rb has 416 lines of code (exceeds 250 allowed). Consider refactoring.
Open

$LOAD_PATH.unshift(File.join(__dir__, '..', 'lib', 'lab'))

require 'yaml'

module Msf
Severity: Minor
Found in plugins/lab.rb - About 6 hrs to fix

    Class LabCommandDispatcher has 29 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class LabCommandDispatcher
          include Msf::Ui::Console::CommandDispatcher
    
          attr_accessor :controller
    
    
    Severity: Minor
    Found in plugins/lab.rb - About 3 hrs to fix

      Method cmd_lab_start has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def cmd_lab_start(*args)
              return lab_usage if args.empty?
      
              if args[0] == 'all'
                @controller.each do |vm|
      Severity: Minor
      Found in plugins/lab.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 cmd_lab_stop has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def cmd_lab_stop(*args)
              return lab_usage if args.empty?
      
              if args[0] == 'all'
                @controller.each do |vm|
      Severity: Minor
      Found in plugins/lab.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 cmd_lab_upload has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

            def cmd_lab_upload(*args)
              return lab_usage if args.empty?
              return lab_usage if args.count < 3
      
              local_path = args[args.count - 2]
      Severity: Minor
      Found in plugins/lab.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 cmd_lab_run_command has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

            def cmd_lab_run_command(*args)
              return lab_usage if args.empty?
      
              command = args[args.count - 1]
              if args[0] == 'all'
      Severity: Minor
      Found in plugins/lab.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 cmd_lab_browse_to has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

            def cmd_lab_browse_to(*args)
              return lab_usage if args.empty?
      
              uri = args[args.count - 1]
              if args[0] == 'all'
      Severity: Minor
      Found in plugins/lab.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 cmd_lab_load has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def cmd_lab_load(*args)
              return lab_usage unless args.count == 1
      
              res = args[0]
              good_res = nil
      Severity: Minor
      Found in plugins/lab.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 cmd_lab_load_tabs has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def cmd_lab_load_tabs(str, words)
              tabs = []
              # return tabs if words.length > 1
              if (str && str =~ (/^#{Regexp.escape(File::SEPARATOR)}/))
                # then you are probably specifying a full path so let's just use normal file completion
      Severity: Minor
      Found in plugins/lab.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 cmd_lab_load_running has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def cmd_lab_load_running(*args)
              return lab_usage if args.empty?
      
              if args[0] =~ /^remote_/
                return lab_usage unless args.count == 3
      Severity: Minor
      Found in plugins/lab.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 cmd_lab_load_config has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def cmd_lab_load_config(*args)
              return lab_usage if args.empty?
      
              if args[0] =~ /^remote_/
                return lab_usage unless args.count == 3
      Severity: Minor
      Found in plugins/lab.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 cmd_lab_snapshot has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def cmd_lab_snapshot(*args)
              return lab_usage if args.count < 2
      
              snapshot = args[args.count - 1]
      
      
      Severity: Minor
      Found in plugins/lab.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

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

            def cmd_lab_revert(*args)
              return lab_usage if args.count < 2
      
              snapshot = args[args.count - 1]
      
      
      Severity: Minor
      Found in plugins/lab.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

      Method cmd_lab_help has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def cmd_lab_help(*args)
              if args.empty?
                commands.each_pair { |k, v| print_line format("%-#{longest_cmd_size}s - %s", k, v) }
              else
                args.each do |c|
      Severity: Minor
      Found in plugins/lab.rb - About 35 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 cmd_lab_suspend has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def cmd_lab_suspend(*args)
              return lab_usage if args.empty?
      
              if args[0] == 'all'
                @controller.each(&:suspend)
      Severity: Minor
      Found in plugins/lab.rb - About 35 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 cmd_lab_reset has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def cmd_lab_reset(*args)
              return lab_usage if args.empty?
      
              if args[0] == 'all'
                print_line 'Resetting all lab vms.'
      Severity: Minor
      Found in plugins/lab.rb - About 35 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 cmd_lab_search_tags has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def cmd_lab_search_tags(*args)
              if args.empty?
                hlp_print_lab
              else
                args.each do |arg|
      Severity: Minor
      Found in plugins/lab.rb - About 25 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 cmd_lab_search has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def cmd_lab_search(*args)
              if args.empty?
                hlp_print_lab
              else
                args.each do |arg|
      Severity: Minor
      Found in plugins/lab.rb - About 25 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 cmd_lab_show has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def cmd_lab_show(*args)
              if args.empty?
                hlp_print_lab
              else
                args.each do |name|
      Severity: Minor
      Found in plugins/lab.rb - About 25 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 cmd_lab_run_command(*args)
              return lab_usage if args.empty?
      
              command = args[args.count - 1]
              if args[0] == 'all'
      Severity: Major
      Found in plugins/lab.rb and 1 other location - About 2 hrs to fix
      plugins/lab.rb on lines 402..420

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

      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 cmd_lab_browse_to(*args)
              return lab_usage if args.empty?
      
              uri = args[args.count - 1]
              if args[0] == 'all'
      Severity: Major
      Found in plugins/lab.rb and 1 other location - About 2 hrs to fix
      plugins/lab.rb on lines 345..363

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

      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 cmd_lab_revert(*args)
              return lab_usage if args.count < 2
      
              snapshot = args[args.count - 1]
      
      
      Severity: Major
      Found in plugins/lab.rb and 1 other location - About 1 hr to fix
      plugins/lab.rb on lines 309..322

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

      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 cmd_lab_snapshot(*args)
              return lab_usage if args.count < 2
      
              snapshot = args[args.count - 1]
      
      
      Severity: Major
      Found in plugins/lab.rb and 1 other location - About 1 hr to fix
      plugins/lab.rb on lines 327..340

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

      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 cmd_lab_load_running(*args)
              return lab_usage if args.empty?
      
              if args[0] =~ /^remote_/
                return lab_usage unless args.count == 3
      Severity: Minor
      Found in plugins/lab.rb and 1 other location - About 55 mins to fix
      plugins/lab.rb on lines 160..171

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

      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 cmd_lab_load_config(*args)
              return lab_usage if args.empty?
      
              if args[0] =~ /^remote_/
                return lab_usage unless args.count == 3
      Severity: Minor
      Found in plugins/lab.rb and 1 other location - About 55 mins to fix
      plugins/lab.rb on lines 145..156

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

      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