hackedteam/rcs-collector

View on GitHub

Showing 119 of 209 total issues

Class RESTController has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

class RESTController
  include RCS::Tracer

  STATUS_OK = 200
  STATUS_REDIRECT = 302
Severity: Minor
Found in lib/rcs-collector/rest.rb - About 2 hrs to fix

    Class EvidenceManager has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class EvidenceManager
      include Singleton
      include RCS::Tracer
    
      REPO_DIR = Dir.pwd + '/evidence'
    Severity: Minor
    Found in lib/rcs-collector/evidence_manager.rb - About 2 hrs to fix

      Method http_get_file has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def http_get_file(headers, uri, delete=true)
      
          # retrieve the Operating System and app specific extension of the requester
          os, ext = http_get_os(headers)
      
      
      Severity: Minor
      Found in lib/rcs-collector/http_controller.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 prepare_response has a Cognitive Complexity of 16 (exceeds 5 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 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 authenticate_scout has a Cognitive Complexity of 16 (exceeds 5 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: Minor
      Found in lib/rcs-collector/sync_protocol.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 migrate_sqlite_scout_column has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def migrate_sqlite_scout_column
              dbs_path = File.expand_path("../../../evidence", __FILE__)
      
              return unless Dir.exists?(dbs_path)
      
      
      Severity: Minor
      Found in lib/rcs-collector/migration.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 49 lines of code (exceeds 25 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 1 hr to fix

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

          def act!
            @request[:action] = @request[:method].to_s.downcase.to_sym
        
            # check we have a valid action
            return bad_request unless public_methods(false).include?(@request[:action])
        Severity: Minor
        Found in lib/rcs-collector/rest.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 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
                        Severity
                        Category
                        Status
                        Source
                        Language