prey/prey-node-client

View on GitHub

Showing 527 of 527 total issues

Function set_up_hooks has 74 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function set_up_hooks() {
  if (Object.keys(event_triggers).length == 0) return;

  Object.keys(event_triggers).forEach((event) => {
    hooks.on(event.split('-')[0], (info) => {
Severity: Major
Found in lib/agent/actions/triggers/index.js - About 2 hrs to fix

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

    exports.delete_profile = function(ssid, cb) {
      var discard = function() {
        var cmd = `networksetup -removepreferredwirelessnetwork ${net_interface} "${ssid}"`;
        run_as_user(cmd, [], function(err) {
          return cb && cb(err);
    Severity: Major
    Found in lib/agent/triggers/auto-connect/mac.js and 1 other location - About 2 hrs to fix
    lib/agent/triggers/auto-connect/mac.js on lines 38..46

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

    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.create_profile = function(ssid, cb) {
      var create = function() {
        var cmd = `networksetup -addpreferredwirelessnetworkatindex ${net_interface} "${ssid}" 0 open`;
        run_as_user(cmd, [], function(err) {
          return cb && cb(err);
    Severity: Major
    Found in lib/agent/triggers/auto-connect/mac.js and 1 other location - About 2 hrs to fix
    lib/agent/triggers/auto-connect/mac.js on lines 48..56

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

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

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

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

          if (processing) {
            if (!exports.scheduled) {
              exports.scheduled = true;
              setTimeout(() => {
                exports.scheduled = false;
      Severity: Major
      Found in lib/agent/providers/encryption-keys/index.js and 1 other location - About 2 hrs to fix
      lib/agent/providers/encryption-status/index.js on lines 32..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 92.

      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

          if (processing) {
            if (!exports.scheduled) {
              exports.scheduled = true;
              setTimeout(() => {
                exports.scheduled = false;
      Severity: Major
      Found in lib/agent/providers/encryption-status/index.js and 1 other location - About 2 hrs to fix
      lib/agent/providers/encryption-keys/index.js on lines 32..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 92.

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

      var RemoteDesktop = function(options){
      
          var self = this;
          var options = options || {};
      
      
      Severity: Major
      Found in lib/agent/actions/remote-desktop/index.js - About 2 hrs to fix

        Function correctPreyConfCallback has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

        const correctPreyConfCallback = (callback) => {
          // eslint-disable-next-line consistent-return
          getDataDb('preyconf', (err, data) => {
            if (err || !data) {
              // eslint-disable-next-line consistent-return
        Severity: Minor
        Found in lib/agent/utils/prey-configuration/validationpreyconf.js - About 2 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

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

        exports.start = function(id, options, cb) {
          var error,
              self     = this,
              returned = 0;
        
        
        Severity: Minor
        Found in lib/agent/actions/alarm/index.js - About 2 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

          setData = (key, value, cb) => {
            this.preyConfiguration[key] = value;
            saveDataToDb(this.preyConfiguration, (error) => {
              if (error) logger.info(`Error while setting prey config: ${error}`);
              if (cb && typeof cb === 'function') cb();
        Severity: Major
        Found in lib/utils/configfile.js and 1 other location - About 2 hrs to fix
        lib/utils/configfile.js on lines 120..126

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

        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

          try {
            storage.do('query', { type: 'keys', column: 'id', data: whatToGet }, (err, stored) => {
              if (err) {
                return callback(err, null);
              }
        Severity: Major
        Found in lib/agent/utils/prey-configuration/preyconf.js and 1 other location - About 2 hrs to fix
        lib/utils/configutil.js on lines 10..22

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

        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

          try {
            storage.do('query', { type: 'keys', column: 'id', data: whatToGet }, (err, stored) => {
              if (err) {
                return callback(err, null);
              }
        Severity: Major
        Found in lib/utils/configutil.js and 1 other location - About 2 hrs to fix
        lib/agent/utils/prey-configuration/preyconf.js on lines 292..305

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

        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.preyConfiguration[key] = value;
            saveDataToDb(this.preyConfiguration, (error) => {
              if (error) logger.info(`Error while setting prey config: ${error}`);
              if (cb && typeof cb === 'function') cb();
        Severity: Major
        Found in lib/utils/configfile.js and 1 other location - About 2 hrs to fix
        lib/utils/configfile.js on lines 112..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 90.

        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 ensure_visible(self, widget, event):
            widget_name = widget.get_name()
            internal_height = self.get('control_panel_options').get_size()[1]
            widget_posn = widget.allocation.y
            widget_height = widget.allocation.height
        Severity: Major
        Found in lib/conf/gui/linux/prey-config.py and 1 other location - About 2 hrs to fix
        lib/conf/gui/linux/prey-config3.py on lines 251..256

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

        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 ensure_visible(self, widget, event):
                widget_name = widget.get_name()
                internal_height = self.get("control_panel_options").get_size()[1]
                widget_posn = widget.allocation.y
                widget_height = widget.allocation.height
        Severity: Major
        Found in lib/conf/gui/linux/prey-config3.py and 1 other location - About 2 hrs to fix
        lib/conf/gui/linux/prey-config.py on lines 234..239

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

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

        exports.activate_event = (trigger) => {
          try {
            var event_index = trigger.automation_events.findIndex(
              (obj) => events_list.indexOf(obj.type) > -1
            );
        Severity: Major
        Found in lib/agent/actions/triggers/index.js - About 2 hrs to fix

          Function update_client has 66 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const update_client = function (new_version, cb) {
            let child;
            let error;
            const out = [];
            const versions_path = system.paths.versions;
          Severity: Major
          Found in lib/agent/updater.js - About 2 hrs to fix

            Function get_tree has 66 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports.get_tree = function(options, cb) {
            
              var dir = options.path;
            
              // We need to run the tree walker script personifying
            Severity: Major
            Found in lib/agent/providers/files/index.js - About 2 hrs to fix

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

                  def error_or_exit(self):
                      if self.result == 0:
                          return self.exit_ok()
                      #      self.run_prey()
                      #      if self.result == 0:
              Severity: Major
              Found in lib/conf/gui/linux/prey-config3.py and 1 other location - About 2 hrs to fix
              lib/conf/gui/linux/prey-config.py on lines 318..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 57.

              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 error_or_exit(self):
                  if self.result == 0:
                    return self.exit_ok()
              #      self.run_prey()
              #      if self.result == 0:
              Severity: Major
              Found in lib/conf/gui/linux/prey-config.py and 1 other location - About 2 hrs to fix
              lib/conf/gui/linux/prey-config3.py on lines 352..363

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

              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