rapid7/metasploit-framework

View on GitHub

Showing 21,886 of 21,886 total issues

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

      if ec['fn'] == 'get_config'
        brocade_config_eater(host, port, cmd_out.strip)
      else
        cmd_loc = store_loot("brocade.#{ec['fn']}",
                             'text/plain',
Severity: Minor
Found in modules/post/networking/gather/enum_brocade.rb and 1 other location - About 35 mins to fix
modules/post/networking/gather/enum_mikrotik.rb on lines 75..84

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

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

opts = Rex::Parser::Arguments.new(
  "-h" => [ false, "Help menu." ],
  "-s" => [ false, "Sort by Author instead of Module Type."],
  "-r" => [ false, "Reverse Sort"],
  "-f" => [ true, "Filter based on Module Type [#{filters.map{|f|f.capitalize}.join(", ")}] (Default = All)."],
Severity: Minor
Found in tools/modules/module_author.rb and 1 other location - About 35 mins to fix
tools/modules/module_license.rb on lines 50..56

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

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

      update_info(
        info,
        'Name' => 'NTDS Grabber',
        'Description' => %q{
          This module uses a powershell script to obtain a copy of the ntds,dit SAM and SYSTEM files on a domain controller.
Severity: Minor
Found in modules/post/windows/gather/ntds_grabber.rb and 1 other location - About 35 mins to fix
modules/post/windows/manage/archmigrate.rb on lines 14..37

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

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

Function getTGT has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def getTGT(self):
        domain, _, TGT, _ = CCache.parseFile(self.__domain)
        if TGT is not None:
            return TGT

Severity: Minor
Found in modules/auxiliary/gather/get_user_spns.py - 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

Function get_users has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def get_users(user_file, in_q, max_threads):
    """Thread worker function. Load candidate usernames from file into input queue."""
    with open(user_file, "r") as f:
        for line in f:
            if SHUTDOWN_EVENT.is_set():
Severity: Minor
Found in modules/auxiliary/gather/office365userenum.py - 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

Function zip has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function zip(src, dst)
{
    var shell = new ActiveXObject('Shell.Application');
    var fso = new ActiveXObject('Scripting.FileSystemObject');

Severity: Minor
Found in data/post/zip/zip.js - 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

Function valid_login has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def valid_login(host, rport, username, password):
    payload = {
        "jsonrpc": "2.0", "id": 0, "method": "call", "params": ["0" * 32, "session", "login",
                                                                {
                                                                    "username": username,
Severity: Minor
Found in modules/auxiliary/scanner/http/onion_omega2_login.py - 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_nessus_scan_stop_all has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def cmd_nessus_scan_stop_all(*args)
        scan_ids = Array.new
        if args[0] == '-h'
          print_status('nessus_scan_stop_all')
          print_status('Example:> nessus_scan_stop_all')
Severity: Minor
Found in plugins/nessus.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 parse_args_http has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def parse_args_http(args = [], _type = 'http')
        opt_parser = Rex::Parser::Arguments.new(
          '-0' => [ false, 'Use HTTP 1.0' ],
          '-1' => [ false, 'Use TLSv1 (SSL)' ],
          '-2' => [ false, 'Use SSLv2 (SSL)' ],
Severity: Minor
Found in plugins/request.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_nessus_template_list has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def cmd_nessus_template_list(*args)
        search_term = nil
        while (arg = args.shift)
          case arg
          when '-h', '--help'
Severity: Minor
Found in plugins/nessus.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

Function extract_symbol_value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def extract_symbol_value(self, symbol_name):
        encoded_name = symbol_name.encode()
        dynamic_symbol = self.extract_section_by_name(DYNAMIC_SYMBOL)
        dynamic_string = self.extract_section_by_name(DYNAMIC_STRING)
        symbol_entry_size = 24 if self.architecture == 64 else 16
Severity: Minor
Found in data/exploits/CVE-2023-4911/cve_2023_4911.py - 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 on_socket_created has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def on_socket_created(_comm, sock, param)
        # Ignore local listening sockets
        return if !sock.peerhost

        if ((sock.peerhost != '0.0.0.0') && sock.peerport)
Severity: Minor
Found in plugins/db_tracker.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

Function der2me has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def der2me(d):
    if d[0] != bt(pack('B', 0x30)):
        return (None, None)
    _, o = rs(d, 1)
    while o < len(d):
Severity: Minor
Found in data/meterpreter/python/met_rsa.py - 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_nessus_db_scan has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def cmd_nessus_db_scan(*args)
        if args[0] == '-h'
          print_status('nessus_db_scan <policy ID> <scan name> <scan description>')
          print_status('Creates a scan based on all the hosts listed in db_hosts.')
          print_status('Use nessus_policy_list to list all available policies with their corresponding policy IDs')
Severity: Minor
Found in plugins/nessus.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_besecure_version has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def cmd_besecure_version
        req = Net::HTTP::Post.new('/json.cgi', { 'Host' => @hostname })
        req.set_form_data({ 'apikey' => @apikey, 'primary' => 'interface' })

        if @debug
Severity: Minor
Found in plugins/besecure.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 verify_migration has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def verify_migration(sid)
        return unless config[:automigrate]
        return if state[sid][:migrated]

        sess = framework.sessions[sid]
Severity: Minor
Found in plugins/beholder.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 view_modules has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def view_modules
        indent = '     '

        wmaptype = %i[
          wmap_ssl
Severity: Minor
Found in plugins/wmap.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 delete_sites has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def delete_sites(wmap_index)
        idx = 0
        to_del = {}
        # Rebuild the index from wmap_sites -l
        framework.db.hosts.each do |bdhost|
Severity: Minor
Found in plugins/wmap.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

Severity
Category
Status
Source
Language