hackedteam/rcs-collector

View on GitHub

Showing 209 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

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

                      def command_exec(peer, session, message)
                        trace :info, "[#{peer}][#{session[:cookie]}] Exec request"
                    
                        # the exec list was already retrieved (if any) during the ident phase
                        # here we get just the content (locally) without asking again to the db
                    Severity: Major
                    Found in lib/rcs-collector/sync_commands.rb and 1 other location - About 2 hrs to fix
                    lib/rcs-collector/sync_commands.rb on lines 259..282

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

                    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

                      def command_download(peer, session, message)
                        trace :info, "[#{peer}][#{session[:cookie]}] Download request"
                    
                        # the download list was already retrieved (if any) during the ident phase
                        # here we get just the content (locally) without asking again to the db
                    Severity: Major
                    Found in lib/rcs-collector/sync_commands.rb and 1 other location - About 2 hrs to fix
                    lib/rcs-collector/sync_commands.rb on lines 429..452

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

                    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

                    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

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

                        def print_total
                          puts "Total Statistics from: #{@stats[:total][:start]}"
                      
                          table_width = 0
                          @stats[:total].each_key do |k|
                      Severity: Major
                      Found in lib/rcs-carrier/statistics.rb and 1 other location - About 2 hrs to fix
                      lib/rcs-collector/statistics.rb on lines 53..80

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

                      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

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

                        def print_total
                          puts "Total Statistics from: #{@stats[:total][:start]}"
                      
                          table_width = 0
                          @stats[:total].each_key do |k|
                      Severity: Major
                      Found in lib/rcs-collector/statistics.rb and 1 other location - About 2 hrs to fix
                      lib/rcs-carrier/statistics.rb on lines 52..79

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

                      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

                      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

                        Severity
                        Category
                        Status
                        Source
                        Language