rapid7/metasploit-framework

View on GitHub
lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb

Summary

Maintainability
F
5 days
Test Coverage

File android.rb has 637 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rex/post/meterpreter'
require 'rex/post/meterpreter/extensions/android/command_ids'
require 'date'

module Rex
Severity: Major
Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb - About 1 day to fix

    Method cmd_dump_contacts has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

      def cmd_dump_contacts(*args)
        path   = "contacts_dump_#{::Time.new.strftime('%Y%m%d%H%M%S')}"
        format = :text
    
        dump_contacts_opts = Rex::Parser::Arguments.new(
    Severity: Minor
    Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/android.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 cmd_dump_contacts has 89 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def cmd_dump_contacts(*args)
        path   = "contacts_dump_#{::Time.new.strftime('%Y%m%d%H%M%S')}"
        format = :text
    
        dump_contacts_opts = Rex::Parser::Arguments.new(
    Severity: Major
    Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb - About 3 hrs to fix

      Method cmd_dump_sms has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

        def cmd_dump_sms(*args)
          path = "sms_dump_#{::Time.new.strftime('%Y%m%d%H%M%S')}.txt"
          dump_sms_opts = Rex::Parser::Arguments.new(
            '-h' => [ false, 'Help Banner' ],
            '-o' => [ true, 'Output path for sms list']
      Severity: Minor
      Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/android.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 cmd_dump_sms has 71 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def cmd_dump_sms(*args)
          path = "sms_dump_#{::Time.new.strftime('%Y%m%d%H%M%S')}.txt"
          dump_sms_opts = Rex::Parser::Arguments.new(
            '-h' => [ false, 'Help Banner' ],
            '-o' => [ true, 'Output path for sms list']
      Severity: Major
      Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb - About 2 hrs to fix

        Method cmd_interval_collect has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def cmd_interval_collect(*args)
              @@interval_collect_opts ||= Rex::Parser::Arguments.new(
                '-h' => [false, 'Help Banner'],
                '-a' => [true, "Action (required, one of: #{client.android.collect_actions.join(', ')})"],
                '-c' => [true, "Collector type (required, one of: #{client.android.collect_types.join(', ')})"],
        Severity: Major
        Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb - About 2 hrs to fix

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

            def cmd_send_sms(*args)
              send_sms_opts = Rex::Parser::Arguments.new(
                '-h' => [ false, 'Help Banner' ],
                '-d' => [ true, 'Destination number' ],
                '-t' => [ true, 'SMS body text' ],
          Severity: Minor
          Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb - About 2 hrs to fix

            Method cmd_dump_calllog has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def cmd_dump_calllog(*args)
                path = "calllog_dump_#{::Time.new.strftime('%Y%m%d%H%M%S')}.txt"
                dump_calllog_opts = Rex::Parser::Arguments.new(
                  '-h' => [ false, 'Help Banner' ],
                  '-o' => [ true, 'Output path for call log']
            Severity: Minor
            Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb - About 1 hr to fix

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

                def cmd_interval_collect(*args)
                    @@interval_collect_opts ||= Rex::Parser::Arguments.new(
                      '-h' => [false, 'Help Banner'],
                      '-a' => [true, "Action (required, one of: #{client.android.collect_actions.join(', ')})"],
                      '-c' => [true, "Collector type (required, one of: #{client.android.collect_types.join(', ')})"],
              Severity: Minor
              Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/android.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_wlan_geolocate has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def cmd_wlan_geolocate(*args)
                  wlan_geolocate_opts = Rex::Parser::Arguments.new(
                    '-h' => [ false, 'Help Banner' ],
                    '-a' => [ true, 'API key' ],
                  )
              Severity: Minor
              Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb - About 1 hr to fix

                Method cmd_sqlite_query has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def cmd_sqlite_query(*args)
                    sqlite_query_opts = Rex::Parser::Arguments.new(
                      '-h' => [ false, 'Help Banner' ],
                      '-d' => [ true, 'The sqlite database file'],
                      '-q' => [ true, 'The sqlite statement to execute'],
                Severity: Minor
                Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb - About 1 hr to fix

                  Method cmd_send_sms has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def cmd_send_sms(*args)
                      send_sms_opts = Rex::Parser::Arguments.new(
                        '-h' => [ false, 'Help Banner' ],
                        '-d' => [ true, 'Destination number' ],
                        '-t' => [ true, 'SMS body text' ],
                  Severity: Minor
                  Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/android.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 commands has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def commands
                      all = {
                        'dump_sms'          => 'Get sms messages',
                        'dump_contacts'     => 'Get contacts list',
                        'geolocate'         => 'Get current lat-long using geolocation',
                  Severity: Minor
                  Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb - About 1 hr to fix

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

                      def cmd_wakelock(*args)
                        wakelock_opts = Rex::Parser::Arguments.new(
                          '-h' => [ false, 'Help Banner' ],
                          '-r' => [ false, 'Release wakelock' ],
                          '-w' => [ false, 'Turn screen on' ],
                    Severity: Minor
                    Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb - About 1 hr to fix

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

                        def cmd_geolocate(*args)
                          generate_map = false
                          geolocate_opts = Rex::Parser::Arguments.new(
                            '-h' => [ false, 'Help Banner' ],
                            '-g' => [ false, 'Generate map using google-maps']
                      Severity: Minor
                      Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb - About 1 hr to fix

                        Method cmd_dump_calllog has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def cmd_dump_calllog(*args)
                            path = "calllog_dump_#{::Time.new.strftime('%Y%m%d%H%M%S')}.txt"
                            dump_calllog_opts = Rex::Parser::Arguments.new(
                              '-h' => [ false, 'Help Banner' ],
                              '-o' => [ true, 'Output path for call log']
                        Severity: Minor
                        Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/android.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_device_shutdown has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def cmd_device_shutdown(*args)
                            seconds = 0
                            device_shutdown_opts = Rex::Parser::Arguments.new(
                              '-h' => [ false, 'Help Banner' ],
                              '-t' => [ false, 'Shutdown after n seconds']
                        Severity: Minor
                        Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/android.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

                        Avoid too many return statements within this method.
                        Open

                              return false
                        Severity: Major
                        Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb - About 30 mins to fix

                          Method cmd_wlan_geolocate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def cmd_wlan_geolocate(*args)
                              wlan_geolocate_opts = Rex::Parser::Arguments.new(
                                '-h' => [ false, 'Help Banner' ],
                                '-a' => [ true, 'API key' ],
                              )
                          Severity: Minor
                          Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/android.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_sqlite_query has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def cmd_sqlite_query(*args)
                              sqlite_query_opts = Rex::Parser::Arguments.new(
                                '-h' => [ false, 'Help Banner' ],
                                '-d' => [ true, 'The sqlite database file'],
                                '-q' => [ true, 'The sqlite statement to execute'],
                          Severity: Minor
                          Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/android.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

                              all = {
                                'dump_sms'          => 'Get sms messages',
                                'dump_contacts'     => 'Get contacts list',
                                'geolocate'         => 'Get current lat-long using geolocation',
                                'dump_calllog'      => 'Get call log',
                          plugins/nexpose.rb on lines 17..34

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

                          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