prey/prey-node-client

View on GitHub

Showing 551 of 551 total issues

Function __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def __init__(self):

    button_text = "Close"
    title = args.title

Severity: Minor
Found in lib/agent/actions/alert/linux/flash.py - 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

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

      storage.do('set', { type: 'keys', id: 'restarts_preyconf', data: { value: parseInt(stored, 10).toString() } }, (errSetting) => {
        if (errSetting) {
          logger.error(`Error while setting restarts_preyconf: ${errSetting}`);
          return callback(errSetting, null);
        }
Severity: Minor
Found in lib/agent/utils/prey-configuration/validationpreyconf.js and 1 other location - About 45 mins to fix
lib/agent/utils/prey-configuration/validationpreyconf.js on lines 69..75

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

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

  const cpuInfo = {
    model: cpus[0].model.trim(),
    speed: cpus[0].speed,
    cores: cpus.length,
  };
Severity: Minor
Found in lib/agent/providers/hardware/index.js and 1 other location - About 45 mins to fix
lib/system/mac/index.js on lines 114..118

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

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

        storage.do('set', { type: 'keys', id: 'restarts_preyconf', data: { value: '1' } }, (errSetting) => {
          if (errSetting) {
            logger.error(`Error while setting restarts_preyconf: ${errSetting}`);
            return callback(errSetting, null);
          }
Severity: Minor
Found in lib/agent/utils/prey-configuration/validationpreyconf.js and 1 other location - About 45 mins to fix
lib/agent/utils/prey-configuration/validationpreyconf.js on lines 36..42

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

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

  if (!keys.get().api || !keys.get().device)
    return cb(errors.get('MISSING_KEY'));
Severity: Major
Found in lib/agent/control-panel/api/devices.js and 3 other locations - About 40 mins to fix
lib/agent/control-panel/api/devices.js on lines 65..66
lib/agent/control-panel/api/devices.js on lines 103..104
lib/agent/token.js on lines 13..13

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

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

  if (!keys.get().api || !keys.get().device)
    return cb(errors.get('MISSING_KEY'));
Severity: Major
Found in lib/agent/control-panel/api/devices.js and 3 other locations - About 40 mins to fix
lib/agent/control-panel/api/devices.js on lines 48..49
lib/agent/control-panel/api/devices.js on lines 103..104
lib/agent/token.js on lines 13..13

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

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

  if (!keys.get().api || !keys.get().device)
    return cb(errors.get('MISSING_KEY'));
Severity: Major
Found in lib/agent/control-panel/api/devices.js and 3 other locations - About 40 mins to fix
lib/agent/control-panel/api/devices.js on lines 48..49
lib/agent/control-panel/api/devices.js on lines 65..66
lib/agent/token.js on lines 13..13

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

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

  if (!keys.get().api || !keys.get().device) return cb(errors.get('MISSING_KEY'));
Severity: Major
Found in lib/agent/token.js and 3 other locations - About 40 mins to fix
lib/agent/control-panel/api/devices.js on lines 48..49
lib/agent/control-panel/api/devices.js on lines 65..66
lib/agent/control-panel/api/devices.js on lines 103..104

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

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

Consider simplifying this complex logical expression.
Open

  if (data.os_name == 'windows' && gte(os.release().trim(), "10.0.0") &&
      data.os_edition && editions.includes(data.os_edition) &&
      data.winsvc_version && gte(data.winsvc_version, "2.0.0"))
      return true;
Severity: Major
Found in lib/system/windows/index.js - About 40 mins to fix

    Consider simplifying this complex logical expression.
    Open

        } else if ((body && body.key) || (body && body.user && body.user.key)) {
          cb(null, set(body.key || body.user.key));
        } else {
          cb(errors.unknown(resp));
        }
    Severity: Major
    Found in lib/agent/control-panel/api/accounts.js - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

        } else if (info.days_of_week && info.hour) {
          // At least the days and hour
      
          try {
            const rule = new schedule.RecurrenceRule();
      Severity: Major
      Found in lib/agent/actions/triggers/index.js - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

          if (!dataToVerify || !dataFromDb
          || (typeof dataToVerify) !== 'object' || (typeof dataFromDb) !== 'object'
          || Object.keys(dataToVerify).length === 0
          || Object.keys(dataFromDb).length === 0) { return callback(false); }
        Severity: Major
        Found in lib/agent/utils/prey-configuration/preyconf.js - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

              if ((val !== 'false' && val !== 'off' && key.includes('wipe_')) && (val === 'on' || val === 'true' || validDirs(val))) {
                const method = key.replace('wipe_', ''); // just 'cookies'
                if (typeof wipe[method] === 'function') list.push(method);
              }
          Severity: Major
          Found in lib/agent/actions/wipe/index.js - About 40 mins to fix

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

                if (Object.prototype.hasOwnProperty.call(responseData, 'accuracy')) responseData.accuracy = parseFloat(responseData.accuracy).toFixed(6);
            Severity: Minor
            Found in lib/agent/actions/request_permission/index.js and 1 other location - About 40 mins to fix
            lib/agent/providers/geo/darwin/index.js on lines 14..14

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

            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.start = function(options, callback) {
              this.terminal = new RemoteTerminal(options);
              this.terminal.start(callback);
            };
            Severity: Minor
            Found in lib/agent/actions/remote-terminal/index.js and 1 other location - About 40 mins to fix
            lib/agent/actions/remote-desktop/index.js on lines 128..131

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

            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 (Object.prototype.hasOwnProperty.call(responseData, 'accuracy')) responseData.accuracy = parseFloat(responseData.accuracy).toFixed(6);
            Severity: Minor
            Found in lib/agent/providers/geo/darwin/index.js and 1 other location - About 40 mins to fix
            lib/agent/actions/request_permission/index.js on lines 15..15

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

            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.start = function(options, callback) {
                this.desktop = new RemoteDesktop(options);
                this.desktop.start(callback);
            };
            Severity: Minor
            Found in lib/agent/actions/remote-desktop/index.js and 1 other location - About 40 mins to fix
            lib/agent/actions/remote-terminal/index.js on lines 99..102

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

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

            var store = function (type, id, name, opts, cb) {
            Severity: Minor
            Found in lib/agent/commands.js - About 35 mins to fix

              Function set_proxy_and_send has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              const set_proxy_and_send = function (method, path, data, opts, cb) {
              Severity: Minor
              Found in lib/agent/control-panel/api/request.js - About 35 mins to fix

                Function request has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                exports.request = function request(method, url, data, opts, cb) {
                Severity: Minor
                Found in lib/agent/transports/http/index.js - About 35 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language