hackedteam/rcs-collector

View on GitHub

Showing 209 of 209 total issues

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

  def self.authenticate_elite(peer, uri, content, anon_version)
    trace :info, "[#{peer}] Authentication required for (#{content.length.to_s} bytes)..."

    # integrity check (104 byte of data, 112 padded)
    # consider random extra data to disguise the protocol
Severity: Minor
Found in lib/rcs-collector/sync_protocol.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 perform has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

      def perform
        # if the database connection has gone
        # try to re-login to the database again
        unless DB.instance.connected?
          trace :debug, "heartbeat: try to reconnect to rcs-db"
Severity: Minor
Found in lib/rcs-collector/heartbeat.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 protocol_send_command has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def protocol_send_command(command)
        # retrieve the receiver anon
        receiver = @anonymizers.select{|x| x['_id'].eql? command['anon']}.first
        raise "Cannot send to unknown anon [#{command['anon']}]" unless receiver

Severity: Minor
Found in lib/rcs-controller/protocol_parser.rb - About 1 hr to fix

    Method command_id has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def command_id(peer, session, message)
    
        # agent version
        version = message.slice!(0..3).unpack('I').first
    
    
    Severity: Minor
    Found in lib/rcs-collector/sync_commands.rb - About 1 hr to fix

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

        def run
          # infinite loop for working
          loop do
            # pass the control to other threads
            sleep 1
      Severity: Minor
      Found in lib/rcs-carrier/evidence_transfer.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 has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def run
          # infinite loop for working
          loop do
            # pass the control to other threads
            sleep 1
      Severity: Minor
      Found in lib/rcs-carrier/evidence_transfer.rb - About 1 hr to fix

        Method cache_init has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def cache_init
            # if the db is available, clear the cache and populate it again
            if @available
              # get the global signature (per customer) for all the agents
              bck_sig = db_rest_call :agent_signature
        Severity: Minor
        Found in lib/rcs-collector/db.rb - About 1 hr to fix

          Method prepare_response has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def prepare_response(connection, request)
          
              @request = request
              @connection = connection
              @response = EM::DelegatedHttpResponse.new @connection
          Severity: Minor
          Found in lib/rcs-collector/rest_response.rb - About 1 hr to fix

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

              def load_from_file
                trace :info, "Loading configuration file..."
                conf_file = File.join Dir.pwd, CONF_DIR, CONF_FILE
            
                # load the config in the @global hash
            Severity: Minor
            Found in lib/rcs-collector/config.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 create_repository has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def create_repository(session)
                # ensure the repository directory is present
                Dir::mkdir(REPO_DIR) if not File.directory?(REPO_DIR)
            
                trace :info, "Creating repository for [#{session[:ident]}_#{session[:instance]}]"
            Severity: Minor
            Found in lib/rcs-collector/evidence_manager.rb - About 1 hr to fix

              Method commands has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def self.commands(peer, cookie, content)
                  # retrieve the session
                  session = SessionManager.instance.get cookie
              
                  # invalid session
              Severity: Minor
              Found in lib/rcs-collector/sync_protocol.rb - About 1 hr to fix

                Method process_http_request has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def process_http_request
                
                    # get the peer of the communication
                    # if direct or thru an anonymizer
                    peer = http_get_forwarded_peer(@http)
                Severity: Minor
                Found in lib/rcs-collector/events.rb - About 1 hr to fix

                  Method http_get_os has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def http_get_os(headers)
                      # extract the user-agent
                      user_agent = headers[:user_agent]
                  
                      return 'unknown', '' if user_agent.nil?
                  Severity: Minor
                  Found in lib/rcs-collector/http_controller.rb - About 1 hr to fix

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

                      def print_total
                        puts "Total Statistics from: #{@stats[:total][:start]}"
                    
                        table_width = 0
                        @stats[:total].each_key do |k|
                    Severity: Minor
                    Found in lib/rcs-collector/statistics.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 print_total has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def print_total
                        puts "Total Statistics from: #{@stats[:total][:start]}"
                    
                        table_width = 0
                        @stats[:total].each_key do |k|
                    Severity: Minor
                    Found in lib/rcs-carrier/statistics.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 http_put_file has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def http_put_file(uri, content)
                        begin
                          path = Dir.pwd + PUBLIC_DIR
                    
                          # split the path in all the subdir and the filename
                    Severity: Minor
                    Found in lib/rcs-collector/http_controller.rb - About 1 hr to fix

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

                            EvidenceManager.instance.store_evidence session, size, message
                      
                            # remember the statistics for input evidence
                            StatsManager.instance.add ev_input: 1, ev_input_size: size
                      
                      
                      Severity: Major
                      Found in lib/rcs-collector/sync_commands.rb and 1 other location - About 1 hr to fix
                      lib/rcs-collector/sync_commands.rb on lines 360..370

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

                      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

                              EvidenceManager.instance.store_evidence session, size, evidence
                      
                              # remember the statistics for input evidence
                              StatsManager.instance.add ev_input: 1, ev_input_size: size
                      
                      
                      Severity: Major
                      Found in lib/rcs-collector/sync_commands.rb and 1 other location - About 1 hr to fix
                      lib/rcs-collector/sync_commands.rb on lines 325..335

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

                      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

                          if user_agent['BlackBerry']    
                            major = 4
                            minor = 5
                            ver_tuple = user_agent.scan(/\/(\d+)\.(\d+)\.\d+/).flatten
                            major, minor = ver_tuple unless ver_tuple.empty?
                      Severity: Major
                      Found in lib/rcs-collector/http_controller.rb and 1 other location - About 1 hr to fix
                      lib/rcs-collector/http_controller.rb on lines 319..331

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

                      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

                          if user_agent['Android']
                            major = 4
                            minor = 0
                            ver_tuple = user_agent.scan(/Android (\d+)\.(\d+)/).flatten
                            major, minor = ver_tuple unless ver_tuple.empty?
                      Severity: Major
                      Found in lib/rcs-collector/http_controller.rb and 1 other location - About 1 hr to fix
                      lib/rcs-collector/http_controller.rb on lines 304..316

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

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language