prey/prey-node-client

View on GitHub

Showing 323 of 551 total issues

Function get_outbound_connections_list has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.get_outbound_connections_list = function(callback) {

  var connections = [],
      command = 'netstat -ano';

Severity: Minor
Found in lib/agent/providers/connections/windows.js - About 1 hr to fix

    Function versionPromise has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const versionPromise = new Promise((resolve, reject) => {
        exec(exports.cmdExistInstallPreyUser, (_parentError, parentStdout) => {
          if (parentStdout && parentStdout.trim() !== '') {
            exec(exports.cmdInstallPreyUserVersion, (error, preyUserVersionInstall) => {
              if (error) {
    Severity: Minor
    Found in lib/conf/tasks/prey_owl.js - About 1 hr to fix

      Function return_status has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function return_status(err, res) {
          function disconnected(err) {
            logger.debug('Device cannot connect to host');
            if (err) {
              logger.error(`Connection error: ${err}`);
      Severity: Minor
      Found in lib/agent/providers/network/index.js - About 1 hr to fix

        Function exports has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function(cmd, opts, cb) {
          var out  = '',
              err  = '',
              args = Array.isArray(cmd) ? cmd : cmd.split(' '),
              bin  = args.shift();
        Severity: Minor
        Found in lib/conf/utils/run.js - About 1 hr to fix

          Function try_connecting_to has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          exports.try_connecting_to = function(list, cb) {
            var array = [];
            list.forEach(function(ap) {
              array.push(
                function(callback) {
          Severity: Minor
          Found in lib/agent/triggers/auto-connect/reconnect.js - About 1 hr to fix

            Function find_logged_user has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            exports.find_logged_user = function(callback) {
              var done = function(err, stdout) {
                if (err) {
                  if (typeof callback !== 'function')
                    return;
            Severity: Minor
            Found in lib/system/windows/index.js - About 1 hr to fix

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

              exports.get_firmware_info = function(callback) {
              
                var get_value = function(output, string) {
                  var regex = new RegExp(string + ": (.*)");
                  var matches = output.toString().match(regex);
              Severity: Minor
              Found in lib/agent/providers/hardware/linux.js - About 1 hr to fix

                Function create_server has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                var create_server = (cb) => {
                  os_name = os.platform().replace('darwin', 'mac').replace('win32', 'windows');
                  if (os_name == 'linux') return cb(new Error('Service only available for mac and windows'));
                
                  check_service((valid) => {
                Severity: Minor
                Found in lib/agent/control-panel/long-polling/server.js - About 1 hr to fix

                  Function get_update_data has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  package.get_update_data = (cb) => {
                    var location  = require('./agent/triggers/location'),
                        data = {public_ip: null, country: null, location: {lat: null, lon: null}},
                        loc = location.current;
                  
                  
                  Severity: Minor
                  Found in lib/package.js - About 1 hr to fix

                    Function check_hostname has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    var check_hostname = () => {
                      if (checking) return;
                      checking = true;
                    
                      var done = (err) => {
                    Severity: Minor
                    Found in lib/agent/triggers/hostname/index.js - About 1 hr to fix

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

                      exports.start = (id, opts, cb) => {
                        const done = (err = null) => {
                          if (err) return cb(err);
                          if (!emitter) emitter = new Emitter();
                          cb(err, emitter);
                      Severity: Minor
                      Found in lib/agent/actions/osquery/index.js - About 1 hr to fix

                        Function get_encryption_status has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                        module.exports.get_encryption_status = function(cb) {
                          logger.info("Getting encryption status");
                          system.get_as_admin_user('encryptStatus', (err, info) => {
                            if (err) return cb(err);
                            if (!Array.isArray(info)) return cb(new Error("Invalid encryption status information"));
                        Severity: Minor
                        Found in lib/agent/providers/encryption-status/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 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                        exports.start = function (cb) {
                        
                          var count,
                            last_err,
                            files_removed = [];
                        Severity: Minor
                        Found in lib/conf/tasks/clear_files_prey_temp.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_access_points_list has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                        exports.parse_access_points_list = function(output) {
                        
                          return output.split(/Cell \d\d - /).splice(1).map(function(block) {
                            var parsed = {};
                        
                        
                        Severity: Minor
                        Found in lib/agent/providers/network/linux.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_process_list has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                        exports.get_process_list = function(callback) {
                        
                          var processes = [],
                              cmd = 'ps axo stat,user,ppid,pid,pcpu,pmem,time,comm | egrep -v " ps|grep"';
                        
                        
                        Severity: Minor
                        Found in lib/agent/providers/processes/mac.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_access_points_list_netsh has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                        exports.parse_access_points_list_netsh = (out) => {
                          // eslint-disable-next-line prefer-const
                          let list = [];
                          const blocks = out.split(/\nSSID \d{1,2}\s:/);
                        
                        
                        Severity: Minor
                        Found in lib/agent/providers/network/windows.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 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                        exports.start = function (cb) {
                        
                          var count,
                            last_err,
                            folders_removed = [];
                        Severity: Minor
                        Found in lib/conf/tasks/clear_folders.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_process_list has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                        exports.get_process_list = function(callback) {
                        
                          var processes = [],
                              cmd = 'ps axo stat,user,ppid,pid,pcpu,pmem,time,comm | egrep -v " ps|grep"';
                        
                        
                        Severity: Minor
                        Found in lib/agent/providers/processes/linux.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_encryption_keys has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                        module.exports.get_encryption_keys = function(cb) {
                          logger.info("Getting encryption keys");
                          system.get_as_admin_user('recoveryKeys', (err, info) => {
                            if (err) return cb(err);
                            if (!Array.isArray(info)) return cb(new Error("Invalid encryption keys information"));
                        Severity: Minor
                        Found in lib/agent/providers/encryption-keys/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 check_service has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                        exports.check_service = function(data, cb) {
                          if (exports.monitoring_service_go) {
                            if (typeof cb !== 'function')
                              return;
                            return cb(null, data);
                        Severity: Minor
                        Found in lib/system/windows/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

                        Severity
                        Category
                        Status
                        Source
                        Language