prey/prey-node-client

View on GitHub

Showing 323 of 551 total issues

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

    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

      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

          Function __init__ has 63 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/flash.py - About 2 hrs to fix

            File index.js has 271 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            const needle = require('needle');
            const Emitter = require('events').EventEmitter;
            const https = require('https');
            
            const common = require('../../common');
            Severity: Minor
            Found in lib/agent/control-panel/long-polling/index.js - About 2 hrs to fix

              Function createServer has 62 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const createServer = (cb) => {
                if (osName === 'linux') return cb(new Error('Service only available for mac and windows'));
              
                checkService((valid) => {
                  if (!valid) return cb(new Error('Windows Service not compatible'));
              Severity: Major
              Found in lib/agent/control-panel/websockets/server.js - About 2 hrs to fix

                Function fetchLocation has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const fetchLocation = (typeFetch, callback) => {
                  if (callback && typeof callback === 'function') locCallbacks.push(callback);
                  if (checking) return;
                
                  const fireCallbacks = (err, coords) => {
                Severity: Major
                Found in lib/agent/triggers/location/index.js - About 2 hrs to fix

                  Function directoryTreeToObj has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  var directoryTreeToObj = function(dir, current_depth, depth, done) {
                    var resultsDir  = [],
                        resultsFile = [];
                  
                    if (os_name == 'windows') dir = dir + '\\';
                  Severity: Major
                  Found in lib/agent/providers/files/tree.js - About 2 hrs to fix

                    Function as_user has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function as_user(options, cb) {
                      const { user } = options;
                      const { bin } = options;
                      const { type } = options;
                      const { opts } = options;
                    Severity: Minor
                    Found in lib/system/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

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

                    exports.start = function(id, opts, cb) {
                      var opts    = opts || {},
                          message = opts.message || opts.alert_message,
                          title   = opts.title,
                          level   = opts.level || 'info',
                    Severity: Minor
                    Found in lib/agent/actions/alert/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

                    Function attach_listeners has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      function attach_listeners(request) {
                        request.on('data', function(data) {
                          logger.info("Data received!");
                    
                          try {
                    Severity: Major
                    Found in lib/conf/long-polling.js - About 2 hrs to fix

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

                      exports.start = function(id, opts, cb) {
                        var opts    = opts || {},
                            message = opts.message || opts.alert_message,
                            title   = opts.title,
                            level   = opts.level || 'info',
                      Severity: Major
                      Found in lib/agent/actions/alert/index.js - About 2 hrs to fix

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

                        exports.start = function (id, options, cb) {
                          const url = `${UPLOAD_SERVER}?uploadID=${options.file_id}`;
                          // Make a call to get the last byte processed by the upload server
                          // in order to resume the upload from that position.
                          needle.request('get', url, null, (err, res) => {
                        Severity: Major
                        Found in lib/agent/actions/fileretrieval/index.js - About 2 hrs to fix

                          Function sync has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          exports.sync = function(id, geofences, cb) {
                            exports.watching = [];
                          
                            if(!geofences || geofences.length == 0) 
                              done(id, cb);
                          Severity: Major
                          Found in lib/agent/actions/geofencing/index.js - About 2 hrs to fix

                            Function createConnectionSocket has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const createConnectionSocket = (messageToSendSocket, cb) => {
                              try {
                                const existsFile = fs.existsSync(socketFile);
                                if (!existsFile) {
                                  logger.error('The socket file does not exist');
                            Severity: Major
                            Found in lib/agent/socket/index.js - About 2 hrs to fix

                              Function check has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              exports.check = function (id, target, opts, cb) {
                                function done(err) {
                                  if (cb && typeof cb === 'function') return cb && cb(err);
                                }
                              
                              
                              Severity: Major
                              Found in lib/agent/updater.js - About 2 hrs to fix

                                Function spawn has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  const spawn = () => {
                                    const wipeOpts = [
                                      '-token', opts.token,
                                      cloud.toString(),
                                      directories.toString(),
                                Severity: Major
                                Found in lib/agent/actions/wipe/index.js - About 2 hrs to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language