hackedteam/rcs-db

View on GitHub

Showing 612 of 612 total issues

Method prepare_response has a Cognitive Complexity of 21 (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-db/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

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

    begin
      # OSX
      temp_zip = Config.instance.temp("%f-%s" % [Time.now, SecureRandom.hex(8)])
      # generate the dropper
      params = {'factory' => {'_id' => rule.action_param},
Severity: Major
Found in lib/rcs-db/tasks/injector.rb and 1 other location - About 2 hrs to fix
lib/rcs-db/tasks/injector.rb on lines 177..202

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

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

    begin
      # LINUX
      temp_zip = Config.instance.temp("%f-%s" % [Time.now, SecureRandom.hex(8)])
      # generate the dropper
      params = {'factory' => {'_id' => rule.action_param},
Severity: Major
Found in lib/rcs-db/tasks/injector.rb and 1 other location - About 2 hrs to fix
lib/rcs-db/tasks/injector.rb on lines 150..175

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

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 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def run(options)

    if options[:reset]
      reset_pass options
      return 0
Severity: Major
Found in lib/rcs-db/config.rb - About 2 hrs to fix

    Class Evidence has 25 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Evidence
      include Mongoid::Document
      include RCS::TargetScoped
      include RCS::DB::Proximity
      include RCS::Tracer
    Severity: Minor
    Found in lib/rcs-db/db_objects/evidence.rb - About 2 hrs to fix

      File entity.rb has 284 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require_relative '../link_manager'
      
      module RCS
      module DB
      
      
      Severity: Minor
      Found in lib/rcs-db/rest/entity.rb - About 2 hrs to fix

        Method add_config has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

          def add_config
            require_auth_level :tech
            require_auth_level :tech_config
        
            mongoid_query do
        Severity: Minor
        Found in lib/rcs-db/rest/agent.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 get_app_info has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

          def get_app_info(file)
            # Read info from original package
        
            fd = File.open(file, "rb")
            raise "Invalid input file" unless fd
        Severity: Minor
        Found in lib/rcs-db/build/symbian.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 rcs-core.rb has 281 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'net/http'
        require 'json'
        require 'open-uri'
        require 'pp'
        require 'cgi'
        Severity: Minor
        Found in scripts/rcs-core.rb - About 2 hrs to fix

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

            def self.positions_flow(ids, from, to, options = {})
              ext = 70*60
          
              t = Time.at(from.to_i)
              from = Time.new(t.year, t.month, t.day, t.hour, t.min, 0).to_i
          Severity: Major
          Found in lib/rcs-db/db_objects/entity.rb - About 2 hrs to fix

            Class Config has 24 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class Config
              include Singleton
              include Tracer
            
              CONF_DIR = 'config'
            Severity: Minor
            Found in lib/rcs-db/config.rb - About 2 hrs to fix

              Class EvidenceController has 24 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class EvidenceController < RESTController
              
                SYNC_IDLE = 0
                SYNC_IN_PROGRESS = 1
                SYNC_TIMEOUTED = 2
              Severity: Minor
              Found in lib/rcs-db/rest/evidence.rb - About 2 hrs to fix

                Method inject_html_flash has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def inject_html_flash(intercept_files, progressive, redirect_user, rule, vector_files)
                    appname = 'FlashSetup-' + progressive.to_s
                    intercept_files << "#{redirect_user["#{rule.ident} #{rule.ident_param}"]} #{rule.action} #{appname} #{rule.resource}"
                
                    begin
                Severity: Major
                Found in lib/rcs-db/tasks/injector.rb - About 2 hrs to fix

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

                      def new_instance(agent)
                        ::Alert.where(:enabled => true, :action => 'INSTANCE').each do |alert|
                  
                          #find its factory
                          factory = ::Item.where({ident: agent.ident, _kind: 'factory'}).first
                  Severity: Minor
                  Found in lib/rcs-db/alert.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 process_queued has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def process_queued(queued)
                        entry = queued.first
                        count = queued.last
                  
                        trace :info, "#{count} alerts to be processed in queue"
                  Severity: Minor
                  Found in lib/rcs-db/alert.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 filesystem has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def filesystem
                      require_auth_level :view
                      require_auth_level :view_filesystem
                  
                      mongoid_query do
                  Severity: Minor
                  Found in lib/rcs-db/rest/evidence.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 frontend has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def frontend
                      collectors = ::Collector.where({type: 'local'}).to_a
                      anons = ::Collector.where({type: 'remote'}).to_a
                      system_status = ::Status.all.to_a
                  
                  
                  Severity: Minor
                  Found in lib/rcs-db/status.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 name_from_handle has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def self.name_from_handle(type, handle, target_id)
                  
                      # use a class cache
                      @@acc_cache ||= LRUCache.new(:ttl => 24.hour)
                  
                  
                  Severity: Minor
                  Found in lib/rcs-db/db_objects/entity.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 common_filter has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def self.common_filter(params)
                  
                      # filtering
                      filter = {}
                      filter = JSON.parse(params['filter']) if params.has_key? 'filter' and params['filter'].is_a? String
                  Severity: Minor
                  Found in lib/rcs-db/db_objects/evidence.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

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

                    def analyze_scout_v2(sample)
                      # Click to start the program
                      marker = "\x43\x00\x6C\x00\x69\x00\x63\x00\x6B\x00\x20\x00\x74\x00\x6F\x00\x20\x00\x73\x00\x74\x00\x61\x00\x72\x00\x74\x00\x20\x00\x74\x00\x68\x00\x65\x00\x20\x00\x70\x00\x72\x00\x6F\x00\x67\x00\x72\x00\x61\x00\x6D\x00\x00\x00\x00\x00" 
                      offset = sample.index(marker) 
                      raise "marker for watermark not found" unless offset
                  Severity: Major
                  Found in scripts/rcs-kill.rb and 1 other location - About 2 hrs to fix
                  scripts/rcs-kill.rb on lines 300..324

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

                  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