prey/prey-node-client

View on GitHub

Showing 312 of 527 total issues

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

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

    Function getPreyUserVersions has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

    const getPreyUserVersions = (preyUserVersion, cb) => {
      const successHandler = (foundVersion) => {
        if (foundVersion) {
          compareVersionsDaemon(foundVersion, preyUserVersion, cb);
        } else {
    Severity: Minor
    Found in lib/conf/tasks/prey_owl.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

    PreyConfigurator has 31 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class PreyConfigurator(object):
    
      ################################################
      # helper functions
      ################################################
    Severity: Minor
    Found in lib/conf/gui/linux/prey-config.py - About 3 hrs to fix

      PreyConfigurator has 31 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class PreyConfigurator(object):
      
          ################################################
          # helper functions
          ################################################
      Severity: Minor
      Found in lib/conf/gui/linux/prey-config3.py - About 3 hrs to fix

        Function get_firmware_info has 93 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        exports.get_firmware_info = (callback) => {
          let data = {};
          const fetch = (key, section, value) => {
            wmic.get_value(section, value, null, (err, resp) => {
              let res = resp;
        Severity: Major
        Found in lib/agent/providers/hardware/windows.js - About 3 hrs to fix

          Function perform has 93 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          exports.perform = function (command, persist = 1) {
            if (!command) return handle_error(new Error('No command received'));
          
            if (typeof command.options == 'string') {
              try {
          Severity: Major
          Found in lib/agent/commands.js - About 3 hrs to fix

            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

              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

                      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

                        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

                          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 __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

                                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

                                  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
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language