prey/prey-node-client

View on GitHub

Showing 313 of 528 total issues

Function get_active_access_point has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

exports.get_active_access_point = (callback) => {
  exports.isWifiPermissionActive((itWorks) => {
    if (itWorks) {
      const processActiveAp = (stdout) => {
        if (stdout.includes('AirPort: Off') || !stdout.includes('SSID')) {
Severity: Minor
Found in lib/agent/providers/network/mac.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 gather has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

const gather = (reportName, list, cb) => {
  const data = {};
  let gathered = false;
  let count = list.length;
  let listReports = [...list];
Severity: Minor
Found in lib/agent/reports.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

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

"use strict";
//////////////////////////////////////////
// Prey Node.js Windows Client Functions
// (c) 2011 - Fork Ltd.
// by Tomas Pollak - http://forkhq.com
Severity: Minor
Found in lib/system/windows/index.js - About 2 hrs to fix

    Function send has 54 lines of code (exceeds 25 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: Major
    Found in lib/agent/control-panel/api/request.js - About 2 hrs to fix

      Function createConnectionSocket has 54 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 parse has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          this.parse = function(listener) {
        
            var operetta = this, parameter;
        
            var sing = function(argument, data) {
        Severity: Major
        Found in lib/conf/utils/operetta.js - About 2 hrs to fix

          Function authorize has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          exports.authorize = function (opts, cb) {
            if (!opts || !opts.username || !opts.password) { throw (errors.arguments('No credentials passed!')); }
          
            if (keys.get().api) { throw (errors.get('API_KEY_SET')); }
          
          
          Severity: Minor
          Found in lib/agent/control-panel/api/accounts.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 sync has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          const sync = () => {
            api.devices.get.status((err, response) => {
              const result = response && response.body;
              if (!result || (response && response.statusCode > 300)) { return logger.warn('Unable to sync settings.'); }
          
          
          Severity: Minor
          Found in lib/agent/control-panel/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 16 (exceeds 5 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: Minor
          Found in lib/agent/actions/fullwipe/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 16 (exceeds 5 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: Minor
          Found in lib/agent/actions/factoryreset/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 16 (exceeds 5 allowed). Consider refactoring.
          Open

          exports.start = (id, options, cb) => {
            const opts = options || {};
            const token = opts.token || null;
            // const confirm = opts.confirm === 'ireallyknowwhatiamdoing';
            const items = validTypes(opts);
          Severity: Minor
          Found in lib/agent/actions/wipe/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 get_picture has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          exports.get_picture = function(main_callback){
          
            var picture_file = temp_path('picture.' + process.pid + '.jpg'),
                tmp_path     = '/tmp',
                size         = '640x480',
          Severity: Major
          Found in lib/agent/providers/webcam/linux/index.js - About 2 hrs to fix

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

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

              Function parse_access_points_list_netsh has 50 lines of code (exceeds 25 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 2 hrs to fix

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

                var get = exports.get = function(name, extra) {
                
                  var args = arguments,
                      cb,
                      options;
                Severity: Minor
                Found in lib/agent/providers.js - About 2 hrs to fix

                  Function start has 48 lines of code (exceeds 25 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 1 hr to fix

                    Function get_connection_status has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                    exp.get_connection_status = function (cb) {
                      const data = config.all();
                      const configData = data;
                      const proxy = configData.try_proxy;
                      const protocol = configData['control-panel.protocol'];
                    Severity: Minor
                    Found in lib/agent/providers/network/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 fetchLocation has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const fetchLocation = (typeFetch, callback) => {
                      if (callback) locCallbacks.push(callback);
                      if (checking) return;
                    
                      const fireCallbacks = (err, coords) => {
                    Severity: Minor
                    Found in lib/agent/triggers/location/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 readWithoutVerification has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const readWithoutVerification = (cb) => {
                      const extractedData = {};
                      let nameBefore = '';
                      let content = '';
                      try {
                    Severity: Minor
                    Found in lib/agent/utils/prey-configuration/preyconf.js - About 1 hr to fix

                      Function generate_keys has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      exports.generate_keys = (cb) => {
                        storage.do('all', { type: 'keys' }, (err, values) => {
                          if (err || !values) { return cb(new Error('Error reading stored security keys')); }
                      
                          // Read stored keys if they exists
                      Severity: Minor
                      Found in lib/agent/control-panel/secure.js - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language