hackedteam/rcs-collector

View on GitHub

Showing 209 of 209 total issues

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

  def new_downloads(bid)
    begin
      ret = rest_call('GET', "/agent/downloads/#{bid}")

      down = {}
Severity: Minor
Found in lib/rcs-collector/db_rest.rb and 1 other location - About 55 mins to fix
lib/rcs-collector/db_rest.rb on lines 508..522

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

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 new_exec(bid)
    begin
      ret = rest_call('GET', "/agent/exec/#{bid}")

      commands = {}
Severity: Minor
Found in lib/rcs-collector/db_rest.rb and 1 other location - About 55 mins to fix
lib/rcs-collector/db_rest.rb on lines 432..446

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

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

Method protocol_send_command has a Cognitive Complexity of 9 (exceeds 5 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 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

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

  def sync_timeout(session)
    begin
      content = {:bid => session[:bid], :instance => session[:instance], :cookie => session[:cookie], :sync_stat => session[:sync_stat]}
      return rest_call('POST', '/evidence/timeout', content.to_json)
    rescue Exception => e
Severity: Minor
Found in lib/rcs-collector/db_rest.rb and 1 other location - About 55 mins to fix
lib/rcs-collector/db_rest.rb on lines 163..170

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

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 sync_end(session)
    begin
      content = {:bid => session[:bid], :instance => session[:instance], :cookie => session[:cookie], :sync_stat => session[:sync_stat]}
      return rest_call('POST', '/evidence/stop', content.to_json)
    rescue Exception => e
Severity: Minor
Found in lib/rcs-collector/db_rest.rb and 1 other location - About 55 mins to fix
lib/rcs-collector/db_rest.rb on lines 153..160

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

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 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 update_status has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def update_status(component, ip, status, message, stats, type, version)
Severity: Major
Found in lib/rcs-collector/db.rb - About 50 mins to fix

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

      def self.new_upgrade?(bid)
        return false unless File.exist?(CACHE_FILE)
    
        begin
          db = SQLite.open CACHE_FILE
    Severity: Major
    Found in lib/rcs-collector/db_cache.rb and 5 other locations - About 45 mins to fix
    lib/rcs-collector/db_cache.rb on lines 287..299
    lib/rcs-collector/db_cache.rb on lines 346..358
    lib/rcs-collector/db_cache.rb on lines 508..520
    lib/rcs-collector/db_cache.rb on lines 573..585
    lib/rcs-collector/db_cache.rb on lines 638..650

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

    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 6 locations. Consider refactoring.
    Open

      def self.new_conf?(bid)
        return false unless File.exist?(CACHE_FILE)
    
        begin
          db = SQLite.open CACHE_FILE
    Severity: Major
    Found in lib/rcs-collector/db_cache.rb and 5 other locations - About 45 mins to fix
    lib/rcs-collector/db_cache.rb on lines 346..358
    lib/rcs-collector/db_cache.rb on lines 420..432
    lib/rcs-collector/db_cache.rb on lines 508..520
    lib/rcs-collector/db_cache.rb on lines 573..585
    lib/rcs-collector/db_cache.rb on lines 638..650

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

    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 6 locations. Consider refactoring.
    Open

      def self.new_uploads?(bid)
        return false unless File.exist?(CACHE_FILE)
    
        begin
          db = SQLite.open CACHE_FILE
    Severity: Major
    Found in lib/rcs-collector/db_cache.rb and 5 other locations - About 45 mins to fix
    lib/rcs-collector/db_cache.rb on lines 287..299
    lib/rcs-collector/db_cache.rb on lines 420..432
    lib/rcs-collector/db_cache.rb on lines 508..520
    lib/rcs-collector/db_cache.rb on lines 573..585
    lib/rcs-collector/db_cache.rb on lines 638..650

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

    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 6 locations. Consider refactoring.
    Open

      def self.new_filesystems?(bid)
        return false unless File.exist?(CACHE_FILE)
    
        begin
          db = SQLite.open CACHE_FILE
    Severity: Major
    Found in lib/rcs-collector/db_cache.rb and 5 other locations - About 45 mins to fix
    lib/rcs-collector/db_cache.rb on lines 287..299
    lib/rcs-collector/db_cache.rb on lines 346..358
    lib/rcs-collector/db_cache.rb on lines 420..432
    lib/rcs-collector/db_cache.rb on lines 508..520
    lib/rcs-collector/db_cache.rb on lines 638..650

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

    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 6 locations. Consider refactoring.
    Open

      def self.new_exec?(bid)
        return false unless File.exist?(CACHE_FILE)
    
        begin
          db = SQLite.open CACHE_FILE
    Severity: Major
    Found in lib/rcs-collector/db_cache.rb and 5 other locations - About 45 mins to fix
    lib/rcs-collector/db_cache.rb on lines 287..299
    lib/rcs-collector/db_cache.rb on lines 346..358
    lib/rcs-collector/db_cache.rb on lines 420..432
    lib/rcs-collector/db_cache.rb on lines 508..520
    lib/rcs-collector/db_cache.rb on lines 573..585

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

    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 6 locations. Consider refactoring.
    Open

      def self.new_downloads?(bid)
        return false unless File.exist?(CACHE_FILE)
    
        begin
          db = SQLite.open CACHE_FILE
    Severity: Major
    Found in lib/rcs-collector/db_cache.rb and 5 other locations - About 45 mins to fix
    lib/rcs-collector/db_cache.rb on lines 287..299
    lib/rcs-collector/db_cache.rb on lines 346..358
    lib/rcs-collector/db_cache.rb on lines 420..432
    lib/rcs-collector/db_cache.rb on lines 573..585
    lib/rcs-collector/db_cache.rb on lines 638..650

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

    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 sync_start has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def sync_start(session, version, user, device, source, time)
    Severity: Minor
    Found in lib/rcs-collector/db_rest.rb - About 45 mins to fix

      Method commands has a Cognitive Complexity of 8 (exceeds 5 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 45 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 new_exec? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def new_exec?(bid)
          # check if we have any exec in the cache
          # probably and old one not yet sent
          return true if DBCache.new_exec? bid
          # cannot reach the db, return false
      Severity: Minor
      Found in lib/rcs-collector/db.rb - About 45 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 sync_start has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def sync_start(session, version, user, device, source, time)
      Severity: Minor
      Found in lib/rcs-collector/evidence_manager.rb - About 45 mins to fix
        Severity
        Category
        Status
        Source
        Language