rapid7/metasploit-framework

View on GitHub
modules/auxiliary/scanner/ssh/ssh_version.rb

Summary

Maintainability
C
1 day
Test Coverage

Method check_encryption has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def check_encryption(server_data)
    table = []

    encryption_checks = {
      'arcfour' => ['https://datatracker.ietf.org/doc/html/rfc8758#name-iana-considerations'],
Severity: Minor
Found in modules/auxiliary/scanner/ssh/ssh_version.rb - About 1 hr to fix

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

      def check_kex(server_data)
        table = []
        kex_checks = {
          'gss-group1-sha1-*' => ['https://datatracker.ietf.org/doc/html/rfc8732#name-deprecated-algorithms'],
          'gss-group14-sha1-gss-gex-sha1-*' => ['https://datatracker.ietf.org/doc/html/rfc8732#name-deprecated-algorithms'],
    Severity: Minor
    Found in modules/auxiliary/scanner/ssh/ssh_version.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 run_host has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def run_host(target_host)
        ::Timeout.timeout(timeout) do
          transport = Net::SSH::Transport::Session.new(target_host, { port: rport })
    
          server_data = transport.algorithms.instance_variable_get(:@server_data)
    Severity: Minor
    Found in modules/auxiliary/scanner/ssh/ssh_version.rb - About 1 hr to fix

      Method check_kex has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def check_kex(server_data)
          table = []
          kex_checks = {
            'gss-group1-sha1-*' => ['https://datatracker.ietf.org/doc/html/rfc8732#name-deprecated-algorithms'],
            'gss-group14-sha1-gss-gex-sha1-*' => ['https://datatracker.ietf.org/doc/html/rfc8732#name-deprecated-algorithms'],
      Severity: Minor
      Found in modules/auxiliary/scanner/ssh/ssh_version.rb - About 1 hr to fix

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

          def check_hmac(server_data)
            table = []
        
            hmac_checks = {
              'hmac-sha2-512-96' => ['https://github.com/net-ssh/net-ssh?tab=readme-ov-file#message-authentication-code-algorithms'],
        Severity: Minor
        Found in modules/auxiliary/scanner/ssh/ssh_version.rb - About 1 hr to fix

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

            def check_host_key(server_data)
              table = []
          
              host_key_checks = {
                %w[
          Severity: Minor
          Found in modules/auxiliary/scanner/ssh/ssh_version.rb - About 1 hr to fix

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

              def perform_recog(ident)
                table = []
                recog_info = []
                if /^SSH-\d+\.\d+-(.*)$/ =~ ident
                  recog_match = Recog::Nizer.match('ssh.banner', ::Regexp.last_match(1))
            Severity: Minor
            Found in modules/auxiliary/scanner/ssh/ssh_version.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 check_host_key has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def check_host_key(server_data)
                table = []
            
                host_key_checks = {
                  %w[
            Severity: Minor
            Found in modules/auxiliary/scanner/ssh/ssh_version.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

            There are no issues that match your filters.

            Category
            Status