hackedteam/rcs-db

View on GitHub

Showing 612 of 612 total issues

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

  def analyze_scout_v3(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 273..297

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

Method next_entry has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def next_entry
    injector = ::Injector.find(@params['injector_id'])
    
    base = rand(10)
    progressive = 0
Severity: Major
Found in lib/rcs-db/tasks/injector.rb - About 2 hrs to fix

    Method export has 63 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def export(evidence, opts)
            # expand the sytles in the dest dir
            FileTask.expand_styles do |name, content|
              yield 'stream', name, {content: content}
            end
    Severity: Major
    Found in lib/rcs-db/tasks/evidence.rb - About 2 hrs to fix

      Method new_entity has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def new_entity(entity)
            ::Alert.where(:enabled => true, :action => 'ENTITY').each do |alert|
              # skip non matching entities
              next unless match_path(alert, entity)
      
      
      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 stream_one_chunk has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

            def stream_one_chunk
              loop do
                break if @connection.closed?
                unless @grid_io.eof?
                  if @connection.get_outbound_data_size > BACKPRESSURE_LEVEL
      Severity: Minor
      Found in lib/rcs-db/em_streamer.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 new_sync has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def new_sync(agent)
            ::Alert.where(:enabled => true, :action => 'SYNC').each do |alert|
              # skip non matching agents
              next unless match_path(alert, agent)
      
      
      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 generate_certificates_anon has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        def generate_certificates_anon
          trace :info, "Generating anon ssl certificates..."
      
          # ensure dir is present
          FileUtils.mkdir_p File.join($execution_directory, CERT_DIR)
      Severity: Minor
      Found in lib/rcs-db/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 create has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        def create
          require_auth_level :tech
          require_auth_level :tech_factories
      
          # need a path to put the factory
      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 upgrade has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        def upgrade
          require_auth_level :server, :sys
      
          mongoid_query do
            collector = Collector.find(@params['_id'])
      Severity: Minor
      Found in lib/rcs-db/rest/collector.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 18 (exceeds 5 allowed). Consider refactoring.
      Open

        def run(options)
      
          # config file parsing
          return 1 unless RCS::DB::Config.instance.load_from_file
      
      
      Severity: Minor
      Found in lib/rcs-worker/backlog.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 cleanup_storage has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def cleanup_storage
          count = 0
          db = DB.instance
      
          total_size =  db.db_stats['dataSize']
      Severity: Major
      Found in lib/rcs-db/migration.rb - About 2 hrs to fix

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

          def self.decode(v, length)
            #decode v into a string of len bytes
        
            long_value = 0
            v.chars.to_a.reverse.each_with_index do |c, i|
        Severity: Major
        Found in scripts/coins/wdump.rb and 1 other location - About 2 hrs to fix
        scripts/coins/b58encode.rb on lines 42..76

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

        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 self.decode(v, length)
            #decode v into a string of len bytes
        
            long_value = 0
        
        
        Severity: Major
        Found in scripts/coins/b58encode.rb and 1 other location - About 2 hrs to fix
        scripts/coins/wdump.rb on lines 39..65

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

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

          def prepare_response(connection, request)
        
            @request = request
            @connection = connection
            @response = EM::DelegatedHttpResponse.new @connection
        Severity: Major
        Found in lib/rcs-db/rest_response.rb - About 2 hrs to fix

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

            def generate(params)
              trace :debug, "Build: generate: #{params}"
          
              names = {}
              funcnames = []
          Severity: Major
          Found in lib/rcs-db/build/iso.rb - About 2 hrs to fix

            Method extract_chat has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.extract_chat(ev)
                data = []
            
                # "peer" attribute was present before 9.0.0
                # than has been replaced by "from" and "rcpt"
            Severity: Minor
            Found in lib/rcs-aggregator/peer.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_position_aggregate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.process_position_aggregate entity, aggregate
                position = aggregate.position
                position_ary = [position[:longitude], position[:latitude]]
            
                operation_id = entity.path.first
            Severity: Minor
            Found in lib/rcs-intelligence/processor.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 pack has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

              def pack(params)
                trace :debug, "Build: pack: #{params}"
            
                case params['type']
                  when 'remote'
            Severity: Minor
            Found in lib/rcs-db/build/blackberry.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 keywordize_position has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.keywordize_position(data, note)
                kw = SortedSet.new
            
                kw += data['latitude'].to_s.keywords unless data['latitude'].nil?
                kw += data['longitude'].to_s.keywords unless data['longitude'].nil?
            Severity: Minor
            Found in lib/rcs-db/indexer.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 17 (exceeds 5 allowed). Consider refactoring.
            Open

                  def run(options)
                    run_with_rescue do
                      # initialize random number generator
                      srand(Time.now.to_i)
            
            
            Severity: Minor
            Found in lib/rcs-db/db.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