prey/prey-node-client

View on GitHub

Showing 527 of 527 total issues

Function sendData has 92 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const sendData = (list, cb) => {
  logger.debug('Sending AP data to location service');
  if (!(list && Array.isArray(list) && list.length > 1)) return cb(new Error('No access points found.'));
  list.sort((a, b) => a.signal_strength - b.signal_strength);
  // eslint-disable-next-line no-bitwise
Severity: Major
Found in lib/agent/providers/geo/strategies.js - About 3 hrs to fix

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

            self.call_prey_config(
                "account signup",
                '-n "'
                + name
                + '" -e "'
    Severity: Major
    Found in lib/conf/gui/linux/prey-config3.py and 1 other location - About 3 hrs to fix
    lib/conf/gui/linux/prey-config.py on lines 286..286

    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

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

        self.call_prey_config('account signup', '-n "' + name + '" -e "' + email + '" -p ' + password + ' -t "' + terms + '" -a "' + age +'"')
    Severity: Major
    Found in lib/conf/gui/linux/prey-config.py and 1 other location - About 3 hrs to fix
    lib/conf/gui/linux/prey-config3.py on lines 307..319

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

    exp.track_hardware_changes = (dataTrack) => {
      const data = dataTrack;
      if (data.tpm_module) delete data.tpm_module;
      if (data.os_edition) delete data.os_edition;
      if (data.winsvc_version) delete data.winsvc_version;
    Severity: Major
    Found in lib/agent/providers/hardware/index.js - About 3 hrs to fix

      Function recover_db has 90 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var recover_db = function (db, cb) {
        var get_tables = (cb) => {
          db.all(queries.TABLES(), (err, data) => {
            let tables = data.map((x) => x.name);
            tables = tables.filter((x) => {
      Severity: Major
      Found in lib/agent/utils/storage.js - About 3 hrs to fix

        Function request has 87 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var request = function() {
          var status_code,
              request_start,
              response_delay,
              resp_timeout;
        Severity: Major
        Found in lib/conf/long-polling.js - About 3 hrs to fix

          File commands.js has 309 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          var common = require('./common');
          var hooks = require('./hooks');
          var actions = require('./actions');
          var triggers = require('./triggers');
          var providers = require('./providers');
          Severity: Minor
          Found in lib/agent/commands.js - About 3 hrs to fix

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

            var check_server_down = (cb) => {
              exec(server_commands[os_name].scan, (err, pid) => {
                if (err || !pid) return cb(new Error('No other local server found, we are clear.'));
                if (pid) {
                  logger.info("Localhost server on same port found.. killing it!")
            Severity: Major
            Found in lib/agent/control-panel/long-polling/server.js and 1 other location - About 3 hrs to fix
            lib/agent/control-panel/websockets/server.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 102.

            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 check_server_down = (cb) => {
              exec(server_commands[osName].scan, (err, pid) => {
                if (err || !pid) return cb(new Error('No other local server found, we are clear.'));
                if (pid) {
                  logger.info('Localhost server on same port found.. killing it!');
            Severity: Major
            Found in lib/agent/control-panel/websockets/server.js and 1 other location - About 3 hrs to fix
            lib/agent/control-panel/long-polling/server.js on lines 37..45

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

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

              function attach_listeners(request) {
                request.on('data', (data) => {
                  if (Buffer.isBuffer(data)) { //
                    if (data.toString() == '\n' || data.toString() == '') return;
                    try {
            Severity: Major
            Found in lib/agent/control-panel/long-polling/index.js - About 3 hrs to fix

              Function notify_action has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
              Open

              exports.notify_action = function (status, id, name, opts, err, out) {
                if (name === 'geofencing' || name === 'triggers') return; // geofencing and triggers needs to send custom notification
              
                let body = {
                  command: 'start',
              Severity: Minor
              Found in lib/agent/control-panel/sender.js - About 3 hrs to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function check_battery_status has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
              Open

              var check_battery_status = (first) => {
              
                providers.get('battery_status', (err, current) => {
                  if (err || !emitter) return;
              
              
              Severity: Minor
              Found in lib/agent/triggers/power/index.js - About 3 hrs to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

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

                  if (stored && stored.length > 0) {
                    // eslint-disable-next-line prefer-destructuring
                    lastStored = stored[0];
                    lastConnection = lastStored;
                  } else {
              Severity: Major
              Found in lib/agent/control-panel/websockets/index.js and 1 other location - About 3 hrs to fix
              lib/agent/control-panel/long-polling/index.js on lines 254..264

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

              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 (stored && stored.length > 0) {
                    last_stored = stored[0];
                    last_connection = last_stored;
                  } else {
                    // Just the first time the client starts
              Severity: Major
              Found in lib/agent/control-panel/long-polling/index.js and 1 other location - About 3 hrs to fix
              lib/agent/control-panel/websockets/index.js on lines 229..240

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

              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 run_command(self, cmd):
                  args = shlex.split(cmd)
                  proc = Popen(args, stdout=PIPE, shell=False)
                  self.out = proc.communicate()[0]
                  self.result = proc.returncode
              Severity: Major
              Found in lib/conf/gui/linux/prey-config.py and 1 other location - About 3 hrs to fix
              lib/conf/gui/linux/prey-config3.py on lines 337..342

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

              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 run_command(self, cmd):
                      args = shlex.split(cmd)
                      proc = Popen(args, stdout=PIPE, shell=False)
                      self.out = proc.communicate()[0]
                      self.result = proc.returncode
              Severity: Major
              Found in lib/conf/gui/linux/prey-config3.py and 1 other location - About 3 hrs to fix
              lib/conf/gui/linux/prey-config.py on lines 303..308

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

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              File prey-config3.py has 295 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              #!/usr/bin/env python3
              ################################################
              # Prey Configurator for Linux
              # By Tomas Pollak
              # (c) 2012-2014 - Fork Ltd. (usefork.com)
              Severity: Minor
              Found in lib/conf/gui/linux/prey-config3.py - About 3 hrs to fix

                Function notify_action has 77 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                exports.notify_action = (status, id, action, opts, err, out, time, respId, retries = 0) => {
                  if (!id || id === 'report' || action === 'triggers' || action === 'geofencing') return;
                  if (retries >= retriesMax) {
                    storage.do('del', { type: 'responses', id: respId });
                    exports.responses_queue = exports.responses_queue.filter((x) => x.id !== respId);
                Severity: Major
                Found in lib/agent/control-panel/websockets/index.js - About 3 hrs to fix

                  Function __init__ has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def __init__(self):
                  
                          button_text = "Close"
                          title = args.title
                  
                  
                  Severity: Major
                  Found in lib/agent/actions/alert/linux/flash3.py - About 3 hrs to fix

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

                    var Operetta = function(args, scope) {
                      if (args) {
                        this.args = args;
                      } else {
                        if (process.argv[0].match(/node(\.exe)?$/))
                    Severity: Major
                    Found in lib/conf/utils/operetta.js - About 2 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language