rapid7/metasploit-aggregator

View on GitHub

Showing 31 of 31 total issues

File packet.rb has 474 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'openssl'
require 'rex/text'

module Metasploit
  module Aggregator
Severity: Minor
Found in ruby/lib/metasploit/aggregator/tlv/packet.rb - About 7 hrs to fix

    File aggregator.rb has 421 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'socket'
    require 'openssl'
    require 'thread'
    require 'securerandom'
    
    
    Severity: Minor
    Found in ruby/lib/metasploit/aggregator.rb - About 6 hrs to fix

      Method process_tlv has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

            def process_tlv
              while true
                begin
                  request, payload = @tlv_queue.pop
                  if request.body && request.body.length > 0
      Severity: Minor
      Found in ruby/lib/metasploit/aggregator/session_detail_service.rb - About 5 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 process has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

            def process(responses)
              requests = EnumeratorQueue.new(self)
              uuid = nil
      
              requestingThread = Thread.new do
      Severity: Minor
      Found in ruby/lib/metasploit/aggregator.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 process_requests has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def process_requests
      
                while true do
                  begin
                    request_task = @queue.pop
      Severity: Minor
      Found in ruby/lib/metasploit/aggregator/http/responder.rb - About 1 hr to fix

        Method process_requests has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

                def process_requests
        
                  while true do
                    begin
                      request_task = @queue.pop
        Severity: Minor
        Found in ruby/lib/metasploit/aggregator/http/responder.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 process_tlv has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def process_tlv
                while true
                  begin
                    request, payload = @tlv_queue.pop
                    if request.body && request.body.length > 0
        Severity: Minor
        Found in ruby/lib/metasploit/aggregator/session_detail_service.rb - About 1 hr to fix

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

                  def self.get_data(connection, guaranteed_length)
                    checked_first = has_length = guaranteed_length
                    content_length = 0
                    request_lines = []
          
          
          Severity: Minor
          Found in ruby/lib/metasploit/aggregator/http/responder.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 from_r has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

                  def from_r(raw)
                    self.value  = nil
          
                    length, self.type = raw.unpack("NN");
          
          
          Severity: Minor
          Found in ruby/lib/metasploit/aggregator/tlv/packet.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 inspect has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def inspect
                    utype = type ^ TLV_META_TYPE_COMPRESSED
                    group = false
                    meta = case (utype & TLV_META_MASK)
                             when TLV_META_TYPE_STRING; "STRING"
          Severity: Minor
          Found in ruby/lib/metasploit/aggregator/tlv/packet.rb - About 1 hr to fix

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

                  def process(responses)
                    requests = EnumeratorQueue.new(self)
                    uuid = nil
            
                    requestingThread = Thread.new do
            Severity: Minor
            Found in ruby/lib/metasploit/aggregator.rb - About 1 hr to fix

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

                      def from_r(raw)
                        self.value  = nil
              
                        length, self.type = raw.unpack("NN");
              
              
              Severity: Minor
              Found in ruby/lib/metasploit/aggregator/tlv/packet.rb - About 1 hr to fix

                Method to_r has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                        def to_r
                          # Forcibly convert to ASCII-8BIT encoding
                          raw = value.to_s.unpack("C*").pack("C*")
                
                          if (self.type & TLV_META_TYPE_STRING == TLV_META_TYPE_STRING)
                Severity: Minor
                Found in ruby/lib/metasploit/aggregator/tlv/packet.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 inspect has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                        def inspect
                          utype = type ^ TLV_META_TYPE_COMPRESSED
                          group = false
                          meta = case (utype & TLV_META_MASK)
                                   when TLV_META_TYPE_STRING; "STRING"
                Severity: Minor
                Found in ruby/lib/metasploit/aggregator/tlv/packet.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 connection_details has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                      def connection_details(payload)
                        detail_map = {}
                        details = @details_cache.session_details(payload)
                        unless details.nil?
                          details.each_pair do |key, value|
                Severity: Minor
                Found in ruby/lib/metasploit/aggregator/connection_manager.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 reverse_route has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                      def reverse_route(uuid)
                        # this method is not ready for prime time yet as will not
                        # support multiple sessions properly, either need unique Queue
                        # for each session which can be identified on reverse or need
                        # pipeline request order to ensure all results are posted in order only
                Severity: Minor
                Found in ruby/lib/metasploit/aggregator/router.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 eval_tlv_enc has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                      def eval_tlv_enc(request)
                        # this is really expensive as we have to process every
                        # piece of information presented from the console to eval for enc requests
                        response = nil
                        begin
                Severity: Minor
                Found in ruby/lib/metasploit/aggregator/session_detail_service.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 flush_stale_sessions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                      def flush_stale_sessions
                        @forwarder_mutex.synchronize do
                          stale_sessions = []
                          @response_queues.each_pair do |payload, queue|
                            unless (queue.time + CONNECTION_TIMEOUT) > Time.now
                Severity: Minor
                Found in ruby/lib/metasploit/aggregator/forwarder.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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                        def initialize(type, value = nil, compress=false)
                          @type     = type
                          @compress = compress
                
                          if (value != nil)
                Severity: Minor
                Found in ruby/lib/metasploit/aggregator/tlv/packet.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 forward has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                      def forward(connection)
                        #forward input requests
                        request_obj = Metasploit::Aggregator::Http::SslResponder.get_data(connection, false)
                        uri = Metasploit::Aggregator::Http::Request.parse_uri(request_obj)
                        @forwarder_mutex.synchronize do
                Severity: Minor
                Found in ruby/lib/metasploit/aggregator/https_forwarder.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