prey/prey-node-client

View on GitHub

Showing 527 of 527 total issues

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

  def validate_existing_user_fields(self):
    if self.text('existing_email') == '':
      self.show_alert(_("Empty email!"), _("Please type in your email."))
      return False
    if self.text('existing_password') == '':
Severity: Major
Found in lib/conf/gui/linux/prey-config.py and 1 other location - About 4 hrs to fix
lib/conf/gui/linux/prey-config3.py on lines 99..107

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

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

Function get_firmware_info has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

exports.get_firmware_info = (callback) => {
  let data = {};
  const fetch = (key, section, value) => {
    wmic.get_value(section, value, null, (err, resp) => {
      let res = resp;
Severity: Minor
Found in lib/agent/providers/hardware/windows.js - 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

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

      if (columns[0] !== '' && columns[columns.length] !== '<defunct>'){

        var process = {
          status: columns[0],
          user:   columns[1],
Severity: Major
Found in lib/agent/providers/processes/mac.js and 1 other location - About 4 hrs to fix
lib/agent/providers/processes/linux.js on lines 16..32

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

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

      if (columns[0] != '' && columns[0] != 'STAT' && columns[columns.length] != '<defunct>'){

        var process = {
          status: columns[0],
          user:   columns[1],
Severity: Major
Found in lib/agent/providers/processes/linux.js and 1 other location - About 4 hrs to fix
lib/agent/providers/processes/mac.js on lines 16..32

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

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 preyconf.js has 340 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const fs = require('fs');
const { join } = require('path');
const configPath = require('../../../common').system.paths.config;
const logger = require('../../common').logger.prefix('preyconf');
const storage = require('../storage');
Severity: Minor
Found in lib/agent/utils/prey-configuration/preyconf.js - About 4 hrs to fix

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

        def get_existing_user(self, show_devices):
            email = self.text("existing_email")
            password = self.text("existing_password")
            password = re.escape(password)
    
    
    Severity: Major
    Found in lib/conf/gui/linux/prey-config3.py and 1 other location - About 4 hrs to fix
    lib/conf/gui/linux/prey-config.py on lines 289..295

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

    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 get_existing_user(self, show_devices):
        email    = self.text('existing_email')
        password = self.text('existing_password')
        password = re.escape(password)
    
    
    Severity: Major
    Found in lib/conf/gui/linux/prey-config.py and 1 other location - About 4 hrs to fix
    lib/conf/gui/linux/prey-config3.py on lines 323..329

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

    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

    Function activate has 101 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.activate = (trigger) => {
      try {
        var index = trigger.automation_events.findIndex(
            (obj) => obj.type === 'exact_time' || obj.type === 'repeat_time'
          ),
    Severity: Major
    Found in lib/agent/actions/triggers/index.js - About 4 hrs to fix

      File storage.js has 334 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      var fs = require('fs'),
        async = require('async'),
        join = require('path').join,
        sqlite3 = require('sqlite3').verbose(),
        //logger  = require('../common').logger.prefix('storage'),
      Severity: Minor
      Found in lib/agent/utils/storage.js - About 4 hrs to fix

        Function start has 100 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        exports.start = (id, options, cb) => {
          const opts = options || {};
          const token = opts.token || null;
          // const confirm = opts.confirm === 'ireallyknowwhatiamdoing';
          const items = validTypes(opts);
        Severity: Major
        Found in lib/agent/actions/wipe/index.js - About 4 hrs to fix

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

          exports.get_remaining_storage = function(callback) {
          
            exec("df -kh / | tail -1", function(err, stdout){
              if (err) return callback(err);
          
          
          Severity: Major
          Found in lib/agent/providers/indicators/linux.js and 1 other location - About 4 hrs to fix
          lib/agent/providers/indicators/mac.js on lines 38..53

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

          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

          exports.get_remaining_storage = function(callback) {
          
            exec("df -kh / | tail -1", function(err, stdout){
              if (err) return callback(err);
          
          
          Severity: Major
          Found in lib/agent/providers/indicators/mac.js and 1 other location - About 4 hrs to fix
          lib/agent/providers/indicators/linux.js on lines 82..97

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

          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

          Function start has 98 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          exports.start = (id, opts, cb) => {
            const osName = os.platform().replace('darwin', 'mac').replace('win32', 'windows');
            if (osName !== 'windows') {
              const error = new Error('Action only allowed on Windows 1O');
              error.code = 3;
          Severity: Major
          Found in lib/agent/actions/fullwipe/index.js - About 3 hrs to fix

            Function getPreyUserVersions has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
            Open

            const getPreyUserVersions = (preyUserVersion, cb) => {
              const successHandler = (foundVersion) => {
                if (foundVersion) {
                  compareVersionsDaemon(foundVersion, preyUserVersion, cb);
                } else {
            Severity: Minor
            Found in lib/conf/tasks/prey_owl.js - 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

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

                      exports.responses_queue = actions.map((element) => ({
                        reply_id: `${element.action_id}`,
                        type: 'response',
                        out: element.out,
                        error: element.error,
            Severity: Major
            Found in lib/agent/control-panel/websockets/index.js and 1 other location - About 3 hrs to fix
            lib/agent/control-panel/websockets/index.js on lines 336..346

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

            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

                      exports.responses_queue.push({
                        reply_id: `${actions.action_id}`,
                        type: 'response',
                        out: actions.out,
                        error: actions.error,
            Severity: Major
            Found in lib/agent/control-panel/websockets/index.js and 1 other location - About 3 hrs to fix
            lib/agent/control-panel/websockets/index.js on lines 324..334

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

            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

            PreyConfigurator has 31 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class PreyConfigurator(object):
            
              ################################################
              # helper functions
              ################################################
            Severity: Minor
            Found in lib/conf/gui/linux/prey-config.py - About 3 hrs to fix

              PreyConfigurator has 31 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class PreyConfigurator(object):
              
                  ################################################
                  # helper functions
                  ################################################
              Severity: Minor
              Found in lib/conf/gui/linux/prey-config3.py - About 3 hrs to fix

                Function get_firmware_info has 93 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                exports.get_firmware_info = (callback) => {
                  let data = {};
                  const fetch = (key, section, value) => {
                    wmic.get_value(section, value, null, (err, resp) => {
                      let res = resp;
                Severity: Major
                Found in lib/agent/providers/hardware/windows.js - About 3 hrs to fix

                  Function perform has 93 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  exports.perform = function (command, persist = 1) {
                    if (!command) return handle_error(new Error('No command received'));
                  
                    if (typeof command.options == 'string') {
                      try {
                  Severity: Major
                  Found in lib/agent/commands.js - About 3 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language