rapid7/metasploit-framework

View on GitHub
plugins/wiki.rb

Summary

Maintainability
F
4 days
Test Coverage

File wiki.rb has 354 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Msf
  ###
  #
  # This plugin extends the Rex::Text::Table class and provides commands
  # that output database information for the current workspace in a wiki
Severity: Minor
Found in plugins/wiki.rb - About 4 hrs to fix

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

          def vulns_to_table(opts = {})
            tbl = Rex::Text::Table.new({ 'Columns' => ['Title', 'Host', 'Port', 'Info', 'Detail Count', 'Attempt Count', 'Exploited At', 'Updated At'] })
            tbl.header = 'Vulns'
            tbl.headeri = opts[:heading_size]
            framework.db.vulns.each do |vuln|
    Severity: Minor
    Found in plugins/wiki.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 loot_to_table has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

          def loot_to_table(opts = {})
            tbl = Rex::Text::Table.new({ 'Columns' => ['host', 'service', 'type', 'name', 'content', 'info', 'path'] })
            tbl.header = 'Loot'
            tbl.headeri = opts[:heading_size]
            framework.db.loots.each do |loot|
    Severity: Minor
    Found in plugins/wiki.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 wiki has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

          def wiki(wiki_type, *args)
            # Create a table options hash
            tbl_opts = {}
            # Set some default options for the table hash
            tbl_opts[:hosts] = []
    Severity: Minor
    Found in plugins/wiki.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 wiki has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def wiki(wiki_type, *args)
            # Create a table options hash
            tbl_opts = {}
            # Set some default options for the table hash
            tbl_opts[:hosts] = []
    Severity: Major
    Found in plugins/wiki.rb - About 2 hrs to fix

      Method services_to_table has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

            def services_to_table(opts = {})
              tbl = Rex::Text::Table.new({ 'Columns' => ['host', 'port', 'proto', 'name', 'state', 'info'] })
              tbl.header = 'Services'
              tbl.headeri = opts[:heading_size]
              framework.db.services.each do |service|
      Severity: Minor
      Found in plugins/wiki.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 to_mediawiki has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

              def to_mediawiki
                str = prefix.dup
                # Print the header if there is one. Use headeri to determine wiki
                # headline level. Mediawiki does headlines a bit backwards so that
                # the header level isn't limited. This results in the need to 'flip'
      Severity: Minor
      Found in plugins/wiki.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 creds_to_table has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def creds_to_table(opts = {})
              tbl = Rex::Text::Table.new({ 'Columns' => ['host', 'port', 'user', 'pass', 'type', 'proof', 'active?'] })
              tbl.header = 'Credentials'
              tbl.headeri = opts[:heading_size]
              framework.db.creds.each do |cred|
      Severity: Minor
      Found in plugins/wiki.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 hosts_to_table has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def hosts_to_table(opts = {})
              tbl = Rex::Text::Table.new({ 'Columns' => ['address', 'mac', 'name', 'os_name', 'os_flavor', 'os_sp', 'purpose', 'info', 'comments'] })
              tbl.header = 'Hosts'
              tbl.headeri = opts[:heading_size]
              framework.db.hosts.each do |host|
      Severity: Minor
      Found in plugins/wiki.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 to_dokuwiki has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

              def to_dokuwiki
                str = prefix.dup
                # Print the header if there is one. Use headeri to determine wiki paragraph level
                if header
                  level = '=' * headeri
      Severity: Minor
      Found in plugins/wiki.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 add_mediawiki_to_rex has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def add_mediawiki_to_rex
            Rex::Text::Table.class_eval do
              def to_mediawiki
                str = prefix.dup
                # Print the header if there is one. Use headeri to determine wiki
      Severity: Minor
      Found in plugins/wiki.rb - About 1 hr to fix

        Method loot_to_table has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def loot_to_table(opts = {})
                tbl = Rex::Text::Table.new({ 'Columns' => ['host', 'service', 'type', 'name', 'content', 'info', 'path'] })
                tbl.header = 'Loot'
                tbl.headeri = opts[:heading_size]
                framework.db.loots.each do |loot|
        Severity: Minor
        Found in plugins/wiki.rb - About 1 hr to fix

          Method hosts_to_table has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def hosts_to_table(opts = {})
                  tbl = Rex::Text::Table.new({ 'Columns' => ['address', 'mac', 'name', 'os_name', 'os_flavor', 'os_sp', 'purpose', 'info', 'comments'] })
                  tbl.header = 'Hosts'
                  tbl.headeri = opts[:heading_size]
                  framework.db.hosts.each do |host|
          Severity: Minor
          Found in plugins/wiki.rb - About 1 hr to fix

            Method vulns_to_table has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def vulns_to_table(opts = {})
                    tbl = Rex::Text::Table.new({ 'Columns' => ['Title', 'Host', 'Port', 'Info', 'Detail Count', 'Attempt Count', 'Exploited At', 'Updated At'] })
                    tbl.header = 'Vulns'
                    tbl.headeri = opts[:heading_size]
                    framework.db.vulns.each do |vuln|
            Severity: Minor
            Found in plugins/wiki.rb - About 1 hr to fix

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

                    def creds_to_table(opts = {})
                      tbl = Rex::Text::Table.new({ 'Columns' => ['host', 'port', 'user', 'pass', 'type', 'proof', 'active?'] })
                      tbl.header = 'Credentials'
                      tbl.headeri = opts[:heading_size]
                      framework.db.creds.each do |cred|
              Severity: Minor
              Found in plugins/wiki.rb - About 1 hr to fix

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

                      def services_to_table(opts = {})
                        tbl = Rex::Text::Table.new({ 'Columns' => ['host', 'port', 'proto', 'name', 'state', 'info'] })
                        tbl.header = 'Services'
                        tbl.headeri = opts[:heading_size]
                        framework.db.services.each do |service|
                Severity: Minor
                Found in plugins/wiki.rb - About 1 hr to fix

                  There are no issues that match your filters.

                  Category
                  Status