prey/prey-node-client

View on GitHub

Showing 323 of 551 total issues

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

var RemoteTerminal = function(options) {

  var self = this;
  var options = options || {};

Severity: Major
Found in lib/agent/actions/remote-terminal/index.js - About 2 hrs to fix

    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

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

    const fetchLocation = (typeFetch, callback) => {
      if (callback && typeof callback === 'function') locCallbacks.push(callback);
      if (checking) return;
    
      const fireCallbacks = (err, coords) => {
    Severity: Minor
    Found in lib/agent/triggers/location/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

    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 setUpHooks has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const setUpHooks = () => {
        if (Object.keys(eventTriggers).length === 0) return;
      
        Object.keys(eventTriggers).forEach((event) => {
          hooks.on(event.split('-')[0], (info) => {
      Severity: Major
      Found in lib/agent/actions/triggers/index.js - About 2 hrs to fix

        Function activate_event has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        exports.activate_event = (trigger) => {
          let eventIndex;
          try {
            eventIndex = trigger.automation_events.findIndex((obj) => eventsList.indexOf(obj.type) > -1);
          } catch (e) {
        Severity: Major
        Found in lib/agent/actions/triggers/index.js - About 2 hrs to fix

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

          const os = require('os');
          const { join } = require('path');
          const setup = require('./setup');
          const sender = require('./sender');
          const secure = require('./secure');
          Severity: Minor
          Found in lib/agent/control-panel/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 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 = 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 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 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 open_config has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        exports.open_config = (deviceKey, cb) => {
                          const protocol = config.getData('control-panel.protocol');
                          const host = config.getData('control-panel.host');
                          let panelHost;
                          switch (host) {
                        Severity: Minor
                        Found in lib/agent/control-panel/secure.js - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language