hackedteam/rcs-db

View on GitHub

Showing 612 of 612 total issues

Method restat has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def restat
    trace :info, "Recalculating stats for #{self._kind} #{self.name}"
    t = Time.now
    case self._kind
      when 'operation'
Severity: Minor
Found in lib/rcs-db/db_objects/item.rb - About 1 hr to fix

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

      def self.run(options)
    
        begin
          c = CoreDeveloper.new
          c.name = options[:name]
    Severity: Minor
    Found in scripts/rcs-core.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 a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def create
        require_auth_level :view
        require_auth_level :view_profiles
    
        return conflict('LICENSE_LIMIT_REACHED') unless LicenseManager.instance.check :intelligence
    Severity: Minor
    Found in lib/rcs-db/rest/entity.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 act! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

          def act!
            # check we have a valid action
            return bad_request if @request[:action].nil?
    
            # make a copy of the params, handy for access and mongoid queries
    Severity: Minor
    Found in lib/rcs-worker/rest.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 process has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def process
    
        self[:wav] = []
    
        return if self[:data][:grid_content].nil?
    Severity: Minor
    Found in lib/rcs-worker/evidence/call.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 upgrade! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def upgrade!(params)
        raise "Cannot determine agent version" if self.version.nil?
    
        # delete any pending upgrade if requested multiple time
        self.upgrade_requests.destroy_all if self.upgradable
    Severity: Minor
    Found in lib/rcs-db/db_objects/item.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 run has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

          def run
            raise MissingAgentError.new("Unable to run instance worker #{@agent_uid}, agent is missing or closed") unless agent?
    
            trace(:info, "[#{@agent_uid}] Evidence processing started for agent #{agent.name}")
    
    
    Severity: Minor
    Found in lib/rcs-worker/instance_worker.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 generate has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def generate(params)
        trace :debug, "Build: generate: #{params}"
    
        # force demo if the RMI is in demo
        params['binary']['demo'] = true if LicenseManager.instance.limits[:rmi][1]
    Severity: Minor
    Found in lib/rcs-db/build/wap.rb - About 1 hr to fix

      Method run! has 38 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: Minor
      Found in lib/rcs-db/status.rb - About 1 hr to fix

        Method filter_for_partial_backup has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.filter_for_partial_backup(params)
        
            # extract the id from the string
            id = Moped::BSON::ObjectId.from_string(params[:what][-24..-1])
        
        
        Severity: Minor
        Found in lib/rcs-db/backup.rb - About 1 hr to fix

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

            def update
              require_auth_level :sys
              require_auth_level :sys_injectors
          
              mongoid_query do
          Severity: Major
          Found in lib/rcs-db/rest/injector.rb and 1 other location - About 1 hr to fix
          lib/rcs-db/rest/collector.rb on lines 74..90

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

          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 update
              require_auth_level :sys
              require_auth_level :sys_frontend
          
              mongoid_query do
          Severity: Major
          Found in lib/rcs-db/rest/collector.rb and 1 other location - About 1 hr to fix
          lib/rcs-db/rest/injector.rb on lines 50..66

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

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

            def burn_one_license(type, platform)
          
              # check if the platform can be used
              unless @limits[:agents][platform][0]
                trace :warn, "You don't have a license for #{platform.to_s}. Queuing agent..."
          Severity: Minor
          Found in lib/rcs-db/license.rb - About 1 hr to fix

            Method offload_move_evidence has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.offload_move_evidence(params)
                old_target = ::Item.find(params[:old_target_id])
                target = ::Item.find(params[:target_id])
                agent = ::Item.find(params[:agent_id])
            
            
            Severity: Minor
            Found in lib/rcs-db/db_objects/evidence.rb - About 1 hr to fix

              Method most_contacted has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def self.most_contacted(target_id, params)
                  start = Time.now
                  most_contacted_types = [:chat, :mail, :sms, :mms, :facebook,
                                          :gmail, :skype, :bbm, :whatsapp, :msn, :adium,
                                          :viber, :outlook, :wechat, :line, :phone]
              Severity: Minor
              Found in lib/rcs-db/db_objects/aggregate.rb - About 1 hr to fix

                Method melt has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def melt(params)
                    trace :debug, "Build: melting: #{params}"
                
                    # open the install.sh dropper and patch the value of the files to be installed
                    file = File.open(path('install.sh'), 'rb+')
                Severity: Minor
                Found in lib/rcs-db/build/ios.rb - About 1 hr to fix

                  Method setup has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def setup(port = 443)
                  
                      # main EventMachine loop
                      begin
                  
                  
                  Severity: Minor
                  Found in lib/rcs-db/events.rb - About 1 hr to fix

                    Method add_limits has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def add_limits(limit)
                    
                        @limits[:magic] = limit[:check]
                    
                        @limits[:type] = limit[:type]
                    Severity: Minor
                    Found in lib/rcs-db/license.rb - About 1 hr to fix

                      Method destroy_callback has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def destroy_callback
                          # remove the item form any dashboard or recent
                          ::User.all.each {|u| u.delete_item(self._id)}
                          # remove the item form the alerts
                          ::Alert.all.each {|a| a.delete_if_item(self._id)}
                      Severity: Minor
                      Found in lib/rcs-db/db_objects/item.rb - About 1 hr to fix

                        Method extract_call has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def self.extract_call(ev)
                            data = []
                            versus = ev.data['incoming'] == 1 ? :in : :out
                            hash = {:time => ev.da, :versus => versus, :type => ev.data['program'].downcase.to_sym, :size => ev.data['duration'].to_i}
                            bidirectional = hash[:type] == :skype
                        Severity: Minor
                        Found in lib/rcs-aggregator/peer.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

                        Severity
                        Category
                        Status
                        Source
                        Language