prey/prey-node-client

View on GitHub

Showing 312 of 527 total issues

Function send_update_event has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var send_update_event = (type, status, old_version, new_version, attempt, error, cb) => {
  const config = require('./utils/configfile');
  var shared = require('./conf/shared');

  shared.keys.verify_current(function(err) {
Severity: Minor
Found in lib/package.js - About 1 hr to fix

    Function osQueryModeData has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const osQueryModeData = (opts, done) => {
      let args = null;
      const data = {
        key: 'device-key',
        token: 'token',
    Severity: Minor
    Found in lib/agent/actions/osquery/index.js - About 1 hr to fix

      Function setUpVersion has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const setUpVersion = function (version, cb) {
        const finish = () => {
          log(`Setting permissions on ${paths.current}`);
          exports.chmodr(paths.current, 0o755, function (err) {
            if (err) return cb(err);
      Severity: Minor
      Found in lib/conf/tasks/index.js - About 1 hr to fix

        Function load_hooks has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function load_hooks() {
          storage.do('query', { type: 'keys', column: 'id', data: 'last_connection' }, (err, stored) => {
            if (err) logger.info('Error getting the last connection data');
            if (stored && stored.length > 0) {
              last_stored = stored[0];
        Severity: Minor
        Found in lib/agent/control-panel/long-polling/index.js - About 1 hr to fix

          Function get_process_list has 26 lines of code (exceeds 25 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

            Function parse_access_points_list has 26 lines of code (exceeds 25 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

              Function get_process_list has 26 lines of code (exceeds 25 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

                Function get_ram_module_list has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                exports.get_ram_module_list = (cb) => {
                  const list = [];
                  const file = join(__dirname, 'ramcheck.vbs');
                
                  // eslint-disable-next-line consistent-return
                Severity: Minor
                Found in lib/agent/providers/hardware/windows.js - About 1 hr to fix

                  Function to_unix has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function to_unix(date) {
                    var new_date;
                    try {
                      if (/^\d+$/.test(date)) {
                        var year = parseInt(date.slice(0, 4)),
                  Severity: Minor
                  Found in lib/agent/actions/triggers/index.js - About 1 hr to fix

                    Function get has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const get = (reportName, options, callback) => {
                      let cb;
                      let optionsGet;
                      if (typeof options === 'function') {
                        cb = options;
                    Severity: Minor
                    Found in lib/agent/reports.js - About 1 hr to fix

                      Function run has 26 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

                        Consider simplifying this complex logical expression.
                        Open

                            if (reportName === 'specs' && osName === 'windows' && gte(system.os_release, '10.0.0')
                              && data.os_edition && editions.includes(data.os_edition)
                              && data.winsvc_version && gte(data.winsvc_version, '2.0.0')) {
                              providers.get('tpm_module', (err, output) => {
                                if (!err) data.tpm_module = output;
                        Severity: Major
                        Found in lib/agent/reports.js - About 1 hr to fix

                          Function bind has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                          Operetta.prototype.bind = function(args, description, listener, type) {
                            if (args) {
                              var operetta  = this;
                          
                              if (args.constructor !== Array)
                          Severity: Minor
                          Found in lib/conf/utils/operetta.js - About 55 mins 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 use has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                          exports.use = function (obj) {
                            for (const key in obj) {
                              if (defaults.hasOwnProperty(key)) {
                                if (key == 'protocol' && ['http', 'https'].indexOf(obj[key]) === -1) {
                                  logger.error(`Invalid protocol: ${obj[key]}`);
                          Severity: Minor
                          Found in lib/agent/control-panel/api/request.js - About 55 mins 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_for_update has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                          const check_for_update = function (cb) {
                            config.load(() => {
                              if (!exports.check_enabled || exports.upgrading) {
                                if (cb && typeof cb === 'function') return cb();
                                return;
                          Severity: Minor
                          Found in lib/agent/updater.js - About 55 mins 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_active_access_point_mac has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                          exports.get_active_access_point_mac = (callback) => {
                            if (release >= 6.0) {
                              // eslint-disable-next-line consistent-return
                              exec('netsh wlan show interfaces', (err, stdout) => {
                                if (err) return callback(err);
                          Severity: Minor
                          Found in lib/agent/providers/network/windows.js - About 55 mins 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 notifyAck has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                          exports.notifyAck = (ackId, type, id, sent, retries = 0) => {
                            if (retries >= retriesMaxAck) {
                              removeAckFromArray(ackId);
                              return;
                            }
                          Severity: Minor
                          Found in lib/agent/control-panel/websockets/index.js - About 55 mins 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 remote has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                          exports.remote = function(values, cb) {
                          
                            var wants_version = values.version;
                            var destination   = values['-d'] || paths.versions;
                          
                          
                          Severity: Minor
                          Found in lib/conf/install.js - About 55 mins 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 send has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                          const send = function (attempt, method, path, data, options, cb) {
                            if (!defaults.client) {
                              const err = new Error('No HTTP client set!');
                              if (cb) return cb(err);
                              return err;
                          Severity: Minor
                          Found in lib/agent/control-panel/api/request.js - About 55 mins 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 create_server has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                          const create_server = (cb) => {
                            if (osName === 'linux') return cb(new Error('Service only available for mac and windows'));
                          
                            check_service((valid) => {
                              if (!valid) return cb(new Error('Windows Service not compatible'));
                          Severity: Minor
                          Found in lib/agent/control-panel/websockets/server.js - About 55 mins 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