prey/prey-node-client

View on GitHub

Showing 551 of 551 total issues

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

    if (err) {
      const error = err;
      error.code = 5;
      error.name = errorFactoryReset.find((x) => x.code === error.code).message;
      return cb(error);
Severity: Major
Found in lib/agent/actions/factoryreset/index.js and 1 other location - About 1 hr to fix
lib/agent/actions/fullwipe/index.js on lines 80..85

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

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 opts = {
        path: file.path,
        user: file.user,
        name: file.name,
        size: file.size,
Severity: Major
Found in lib/agent/actions/fileretrieval/index.js and 1 other location - About 1 hr to fix
lib/agent/actions/fileretrieval/upload.js on lines 31..39

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

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 options = {
    path: argv[PATH],
    user: argv[USER],
    name: argv[NAME],
    size: argv[SIZE],
Severity: Major
Found in lib/agent/actions/fileretrieval/upload.js and 1 other location - About 1 hr to fix
lib/agent/actions/fileretrieval/index.js on lines 50..58

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

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 configureScreenshotUserData = () => {
  screenshotUtilData.appPath = `${__dirname}/../../../utils/Prey.app`;
  screenshotUtilData.screenshotDir = '/tmp';
  screenshotUtilData.tmpScreenshot = `${screenshotUtilData.screenshotDir}/screenshot.jpg`;
};
Severity: Major
Found in lib/agent/providers/screenshot/mac/index.js and 1 other location - About 1 hr to fix
lib/agent/providers/webcam/mac/index.js on lines 46..50

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

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

function as_user(options, cb) {
  const { user } = options;
  const { bin } = options;
  const { type } = options;
  const { opts } = options;
Severity: Minor
Found in lib/system/index.js - About 1 hr to fix

    Function get_battery_status has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.get_battery_status = function(cb) {
    
      var keys = 'Availability,BatteryStatus,EstimatedChargeRemaining,EstimatedRunTime';
    
      var get_state = function(num) {
    Severity: Minor
    Found in lib/agent/providers/indicators/windows.js - About 1 hr to fix

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

      exports.start = function(id, opts, cb) {
        var os_name = os.platform().replace('darwin', 'mac').replace('win32', 'windows');
      
        if (os_name != 'windows')
          return cb(new Error('Action only allowed on Windows 1O'));
      Severity: Minor
      Found in lib/agent/actions/diskencryption/index.js - About 1 hr to fix

        Function link has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        exports.link = (data, cb) => {
          if (!data || Object.keys(data).length == 0)
            return cb(errors.arguments('Empty data.'));
        
          if (keys.get().device)
        Severity: Minor
        Found in lib/agent/control-panel/api/devices.js - 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

        Function eachFileOrDirectory has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        var eachFileOrDirectory = function(directory, fileHandler, completeHandler) {
          var filesToCheck = 0;
          // var checkedFiles = [];
          // var checkedStats = [];
        
        
        Severity: Minor
        Found in lib/agent/providers/files/finder.js - 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

        Function parse has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        exports.parse = function (body) {
          let c;
          let matches;
        
          if ((matches = body.match(/^help\s?(\w+)?/))) c = ['help', matches[1]];
        Severity: Minor
        Found in lib/agent/commands.js - 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

        Function unprocessable has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        exports.unprocessable = function(errors) {
          if (typeof errors == 'object') {
            var arr = [];
            for (var key in errors) {
              var err_key;
        Severity: Minor
        Found in lib/agent/control-panel/api/errors.js - 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

        Function request has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        const request = function () {
          if (current_request) {
            logger.debug('Already running request');
            return;
          }
        Severity: Minor
        Found in lib/agent/control-panel/long-polling/index.js - 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

        Function RemoteTerminal has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        var RemoteTerminal = function(options) {
        
          var self = this;
          var options = options || {};
        
        
        Severity: Minor
        Found in lib/agent/actions/remote-terminal/index.js - 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

        Function start has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        exports.start = function(id, opts, cb) {
          var os_name = os.platform().replace('darwin', 'mac').replace('win32', 'windows');
        
          if (os_name != 'windows')
            return cb(new Error('Action only allowed on Windows 1O'));
        Severity: Minor
        Found in lib/agent/actions/diskencryption/index.js - 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

        Function toPrecisionFixed has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        var toPrecisionFixed = function(number, precision) {
          if (isNaN(number)) return 'NaN';
          var numb = number < 0 ? -number : number;  // can't take log of -ve number...
          var sign = number < 0 ? '-' : '';
        
        
        Severity: Minor
        Found in lib/agent/triggers/location/lib/latlng.js - 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

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

        exp.get_vendor_name = (cb) => {
          si.system((stdoutsi) => {
            if (!stdoutsi || !stdoutsi.manufacturer) return cb(null, '');
            return cb(null, stdoutsi.manufacturer);
          });
        Severity: Major
        Found in lib/agent/providers/hardware/index.js and 1 other location - About 1 hr to fix
        lib/agent/providers/hardware/index.js on lines 35..40

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

        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

        exp.get_model_name = (cb) => {
          si.system((stdoutsi) => {
            if (!stdoutsi || !stdoutsi.model) return cb(null, '');
            return cb(null, stdoutsi.model);
          });
        Severity: Major
        Found in lib/agent/providers/hardware/index.js and 1 other location - About 1 hr to fix
        lib/agent/providers/hardware/index.js on lines 42..47

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

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

        exp.get_connection_status = function (cb) {
          const data = config.all();
          const configData = data;
          const proxy = configData.try_proxy;
          const protocol = configData['control-panel.protocol'];
        Severity: Minor
        Found in lib/agent/providers/network/index.js - About 1 hr to fix

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

          const takePicture = (cb) => {
            // eslint-disable-next-line consistent-return
            child = run_as_logged_user(`open -n ${pictureUtilData.appPath}`, ['--args', '-picture'], (err) => {
              if (err) return cb(err);
              cb();
          Severity: Major
          Found in lib/agent/providers/webcam/mac/index.js and 1 other location - About 1 hr to fix
          lib/agent/providers/screenshot/mac/index.js on lines 67..73

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

          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 takeScreenshot = (cb) => {
            // eslint-disable-next-line consistent-return
            child = run_as_logged_user(`open -n ${screenshotUtilData.appPath}`, ['--args', '-screenshot'], (err) => {
              if (err) return cb(err);
              cb();
          Severity: Major
          Found in lib/agent/providers/screenshot/mac/index.js and 1 other location - About 1 hr to fix
          lib/agent/providers/webcam/mac/index.js on lines 58..64

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

          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

          Severity
          Category
          Status
          Source
          Language