hackedteam/rcs-collector

View on GitHub

Showing 119 of 209 total issues

File db_rest.rb has 539 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rcs-common/trace'
require 'rcs-common/cgi'

# system
require 'net/http'
Severity: Major
Found in lib/rcs-collector/db_rest.rb - About 1 day to fix

    File db_cache.rb has 507 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require_relative 'sqlite'
    
    # from RCS::Common
    require 'rcs-common/trace'
    
    
    Severity: Major
    Found in lib/rcs-collector/db_cache.rb - About 1 day to fix

      Class DB has 49 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class DB
        include Singleton
        include RCS::Tracer
      
        ACTIVE_AGENT = 0
      Severity: Minor
      Found in lib/rcs-collector/db.rb - About 6 hrs to fix

        Class DB_rest has 48 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class DB_rest
          include RCS::Tracer
        
          def initialize(host)
            @host, @port = host.split(':')
        Severity: Minor
        Found in lib/rcs-collector/db_rest.rb - About 6 hrs to fix

          Method cache_init has a Cognitive Complexity of 38 (exceeds 5 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 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

          Class DBCache has 41 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class DBCache
            extend RCS::Tracer
          
            CACHE_FILE = Dir.pwd + '/config/cache.db'
          
          
          Severity: Minor
          Found in lib/rcs-collector/db_cache.rb - About 5 hrs to fix

            File evidence_manager.rb has 382 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require 'fileutils'
            require_relative 'sqlite'
            
            # from RCS::Common
            require 'rcs-common/trace'
            Severity: Minor
            Found in lib/rcs-collector/evidence_manager.rb - About 5 hrs to fix

              File db.rb has 381 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require_relative 'config.rb'
              require_relative 'db_rest.rb'
              require_relative 'db_cache.rb'
              require_relative 'my_ip.rb'
              
              
              Severity: Minor
              Found in lib/rcs-collector/db.rb - About 5 hrs to fix

                Method process_http_request has a Cognitive Complexity of 30 (exceeds 5 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 4 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 stream_one_chunk has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                Open

                      def stream_one_chunk
                        loop do
                          break if @connection.closed?
                          if @file_io.pos < @size
                            if @connection.get_outbound_data_size > BACKPRESSURE_LEVEL
                Severity: Minor
                Found in lib/rcs-collector/em_streamer.rb - About 4 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 authenticate_scout has 91 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def self.authenticate_scout(peer, uri, content, anon_version)
                    trace :info, "[#{peer}] Authentication scout required for (#{content.length.to_s} bytes)..."
                
                    begin
                      # remove the base64 container
                Severity: Major
                Found in lib/rcs-collector/sync_protocol.rb - About 3 hrs to fix

                  Method http_get_os has a Cognitive Complexity of 23 (exceeds 5 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 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 authenticate_elite has 77 lines of code (exceeds 25 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: Major
                  Found in lib/rcs-collector/sync_protocol.rb - About 3 hrs to fix

                    File http_controller.rb has 285 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    require_relative 'sync_protocol'
                    
                    require 'rcs-common/mime'
                    require 'rcs-common/crypt'
                    
                    
                    Severity: Minor
                    Found in lib/rcs-collector/http_controller.rb - About 2 hrs to fix

                      Method run! has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def self.run!(*argv)
                          # reopen the class and declare any empty trace method
                          # if called from command line, we don't have the trace facility
                          self.class_eval do
                            def trace(level, message)
                      Severity: Major
                      Found in lib/rcs-collector/config.rb - About 2 hrs to fix

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

                          def run(options)
                            if options[:alt_log]
                              logfilepath = File.expand_path("../../../log/rcs-collector-config.log", __FILE__)
                        
                              @logger = Log4r::Logger.new("migration").tap do |logger|
                        Severity: Minor
                        Found in lib/rcs-collector/config.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 run has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def run(options)
                        
                            # delete all the instance with zero evidence pending and not in progress
                            if options[:purge] then
                              instances.each do |e|
                        Severity: Minor
                        Found in lib/rcs-collector/evidence_manager.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

                        File sync_commands.rb has 264 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        require_relative 'db.rb'
                        require_relative 'sessions.rb'
                        require_relative 'evidence_manager.rb'
                        
                        # from RCS::Common
                        Severity: Minor
                        Found in lib/rcs-collector/sync_commands.rb - About 2 hrs to fix

                          Method run has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def run(options)
                          
                              # delete all the instance with zero evidence pending and not in progress
                              if options[:purge] then
                                instances.each do |e|
                          Severity: Major
                          Found in lib/rcs-collector/evidence_manager.rb - About 2 hrs to fix

                            File sync_protocol.rb has 259 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            require_relative 'sessions'
                            require_relative 'db'
                            require_relative 'sync_commands'
                            
                            # from RCS::Common
                            Severity: Minor
                            Found in lib/rcs-collector/sync_protocol.rb - About 2 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language