prey/prey-node-client

View on GitHub

Showing 551 of 551 total issues

Function retryQueuedResponses has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

const retryQueuedResponses = () => {
  if (exports.responses_queue.length === 0) return;

  exports.responses_queue.forEach((respQueued) => {
    exports.notify_action(
Severity: Minor
Found in lib/agent/control-panel/websockets/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 init has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

var init = function (type, path, cb) {
  storage_path = path ? path : storage_path ? storage_path : join(config, 'commands.db');
  backup_path = storage_path;
  var create_db = () => {
    db_comm = new sqlite3.Database(storage_path, function (err) {
Severity: Minor
Found in lib/agent/utils/storage.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 get_os_edition has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.get_os_edition = (callback) => {
  if (os_name != "windows") {
    if (typeof callback !== 'function')
      return;
    return callback(new Error('Only for Windows'));
Severity: Minor
Found in lib/system/windows/index.js - About 1 hr to fix

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

          if (options.proxy) {
            logger.debug('Trying to reconnect without proxy');
            delete options.proxy;
            current_request = needle.get(url, options);
            attach_listeners(current_request);
    Severity: Major
    Found in lib/agent/control-panel/long-polling/index.js and 1 other location - About 1 hr to fix
    lib/conf/long-polling.js on lines 95..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 66.

    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

      setData = (key, value, cb) => {
        this.permissionData[key] = value;
        saveToDbKey(keyValue, this.permissionData, () => {
          if (cb && typeof cb === 'function') cb();
        });
    Severity: Major
    Found in lib/utils/permissionfile.js and 1 other location - About 1 hr to fix
    lib/utils/permissionfile.js on lines 49..54

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

    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 (options.proxy) {
            logger.debug('Trying to reconnect without proxy');
            delete options.proxy;
            current_request = needle.get(url, options);
            attach_listeners(current_request);
    Severity: Major
    Found in lib/conf/long-polling.js and 1 other location - About 1 hr to fix
    lib/agent/control-panel/long-polling/index.js on lines 175..182

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

    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

      update = (key, value, cb) => {
        this.permissionData[key] = value;
        saveToDbKey(keyValue, this.permissionData, () => {
          if (cb && typeof cb === 'function') cb();
        });
    Severity: Major
    Found in lib/utils/permissionfile.js and 1 other location - About 1 hr to fix
    lib/utils/permissionfile.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 66.

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

    exports.reconnect = function(done) {
    
      var network_service,
          airport_name = '',
          providers    = require('./../../agent/providers');
    Severity: Minor
    Found in lib/system/mac/airport.js - About 1 hr to fix

      Function check_zones has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var check_zones = function() {
        if (!location || checking) return;
        checking = true;
      
        zones.forEach(function (zone) {
      Severity: Minor
      Found in lib/agent/triggers/control-zones/index.js - About 1 hr to fix

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

          def valid_email_regex(self, string):
            if len(string) > 7:
              if re.match(EMAIL_REGEX, string) != None:
                return True
            return False
        lib/conf/gui/linux/prey-config.py on lines 73..77

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

        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

            this.tunnel.on('closed', function(err) {
              logger.info('Tunnel closed!');
              if (!opened) callback(err || new Error("Unable to connect."));
        
              self.stop(err);
        Severity: Major
        Found in lib/agent/actions/remote-terminal/index.js and 1 other location - About 1 hr to fix
        lib/agent/actions/remote-desktop/index.js on lines 64..71

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

        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

                this.tunnel.on('closed', function(err){
                    logger.info('Tunnel closed!');
        
                    if (!opened)
                      callback(err || new Error('Unable to connect.'));
        Severity: Major
        Found in lib/agent/actions/remote-desktop/index.js and 1 other location - About 1 hr to fix
        lib/agent/actions/remote-terminal/index.js on lines 54..59

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

        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 valid_email_regex(self, string):
            if len(string) > 7:
              if re.match(EMAIL_REGEX, string) != None:
                return True
            return False
        Severity: Major
        Found in lib/conf/gui/linux/prey-config.py and 1 other location - About 1 hr to fix
        lib/conf/gui/mac/PreyConfig.app/Contents/MacOS/prey-config.py on lines 360..364

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

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

        exports.get_status = (cb) => {
          if (exports.status) {
            return cb(null, exports.status);
          }
          if (!timeoutGetStatus) {
        Severity: Minor
        Found in lib/agent/triggers/status/index.js - About 1 hr to fix

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

          exports.start = function(opts, cb) {
            hooks.on('geofencing_start', function(fences) {
              if (!fences) return;
          
              zones = fences;
          Severity: Minor
          Found in lib/agent/triggers/control-zones/index.js - About 1 hr to fix

            Function retrieve_file_as_user has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const retrieve_file_as_user = function (options, cb) {
              if (os_name == 'windows') {
                path_arg = path.resolve(options.path);
                name_arg = path.resolve(options.name);
              } else {
            Severity: Minor
            Found in lib/agent/actions/fileretrieval/index.js - About 1 hr to fix

              Function run has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const run = () => {
                if (running) return;
                running = true;
              
                // eslint-disable-next-line consistent-return
              Severity: Minor
              Found in lib/agent/index.js - About 1 hr to fix

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

                  child.stderr.on('data', function(data) {
                    err += data;
                    if (opts.stderr && opts.stderr.writable)
                      opts.stderr.write(data);
                  });
                Severity: Major
                Found in lib/conf/utils/run.js and 1 other location - About 1 hr to fix
                lib/conf/utils/run.js on lines 39..43

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

                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

                  child.stdout.on('data', function(data) {
                    out += data;
                    if (opts.stdout && opts.stdout.writable)
                      opts.stdout.write(data);
                  });
                Severity: Major
                Found in lib/conf/utils/run.js and 1 other location - About 1 hr to fix
                lib/conf/utils/run.js on lines 45..49

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

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

                var init = function (type, path, cb) {
                  storage_path = path ? path : storage_path ? storage_path : join(config, 'commands.db');
                  backup_path = storage_path;
                  var create_db = () => {
                    db_comm = new sqlite3.Database(storage_path, function (err) {
                Severity: Minor
                Found in lib/agent/utils/storage.js - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language