prey/prey-node-client

View on GitHub

Showing 311 of 524 total issues

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

'use strict';

var schedule = require('node-schedule');
var EventEmitter = require('events').EventEmitter;
var logger = require('./../../common').logger.prefix('triggers');
Severity: Major
Found in lib/agent/actions/triggers/index.js - About 1 day to fix

    Function track_hardware_changes has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
    Open

    exp.track_hardware_changes = (dataTrack) => {
      const data = dataTrack;
      if (data.tpm_module) delete data.tpm_module;
      if (data.os_edition) delete data.os_edition;
      if (data.winsvc_version) delete data.winsvc_version;
    Severity: Minor
    Found in lib/agent/providers/hardware/index.js - About 1 day 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 Operetta has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
    Open

    var Operetta = function(args, scope) {
      if (args) {
        this.args = args;
      } else {
        if (process.argv[0].match(/node(\.exe)?$/))
    Severity: Minor
    Found in lib/conf/utils/operetta.js - About 1 day 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 474 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* eslint-disable indent */
    // eslint-disable-next-line import/no-extraneous-dependencies
    const WebSocket = require('ws');
    // eslint-disable-next-line import/no-extraneous-dependencies
    const HttpsProxyAgent = require('https-proxy-agent');
    Severity: Minor
    Found in lib/agent/control-panel/websockets/index.js - About 7 hrs to fix

      Function activate has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.activate = (trigger) => {
        try {
          var index = trigger.automation_events.findIndex(
              (obj) => obj.type === 'exact_time' || obj.type === 'repeat_time'
            ),
      Severity: Minor
      Found in lib/agent/actions/triggers/index.js - About 7 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 package.js has 443 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      const fs              = require('fs');
      const path            = require('path');
      const needle          = require('needle');
      const createHash      = require('crypto').createHash;
      const rmdir           = require('rimraf');
      Severity: Minor
      Found in lib/package.js - About 6 hrs to fix

        ConfigDelegate has 47 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class ConfigDelegate(NSObject):
        
          def windowWillClose_(self, sender):
            self.terminate(sender)
        
        
        Severity: Minor
        Found in lib/conf/gui/mac/PreyConfig.app/Contents/MacOS/prey-config.py - About 6 hrs to fix

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

          var start = function(cb) {
            ensureAndCreateDb((err)=>{
              if (err) return process.exit(1);
              const config = require('../utils/configfile');
              config.load(() => {
          Severity: Major
          Found in lib/conf/cli.js - About 6 hrs to fix

            Function request has 155 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const request = function () {
              if (current_request) {
                logger.debug('Already running request');
                return;
              }
            Severity: Major
            Found in lib/agent/control-panel/long-polling/index.js - About 6 hrs to fix

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

              #!/usr/bin/python
              # coding: utf-8
              
              ############################
              # Prey OSX Configurator
              Severity: Minor
              Found in lib/conf/gui/mac/PreyConfig.app/Contents/MacOS/prey-config.py - About 6 hrs to fix

                Function perform has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                Open

                exports.perform = function (command, persist = 1) {
                  if (!command) return handle_error(new Error('No command received'));
                
                  if (typeof command.options == 'string') {
                    try {
                Severity: Minor
                Found in lib/agent/commands.js - About 5 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 notify_action has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                Open

                exports.notify_action = (status, id, action, opts, err, out, time, respId, retries = 0) => {
                  if (!id || id === 'report' || action === 'triggers' || action === 'geofencing') return;
                  if (retries >= retriesMax) {
                    storage.do('del', { type: 'responses', id: respId });
                    exports.responses_queue = exports.responses_queue.filter((x) => x.id !== respId);
                Severity: Minor
                Found in lib/agent/control-panel/websockets/index.js - About 5 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 testExistingConfigurations has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
                Open

                const testExistingConfigurations = (cb) => {
                  exec(exports.existsNewPath, (_error, stdout) => {
                    if (stdout && stdout.trim() !== '') {
                      // look for old .plist and remove it
                      // eslint-disable-next-line consistent-return
                Severity: Minor
                Found in lib/conf/tasks/prey_owl.js - About 5 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 startWebsocket has 130 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                exports.startWebsocket = () => {
                  clearAndResetIntervals();
                  notifyActionInterval = setInterval(retryQueuedResponses, 5000); // <-revisar el tiempo
                  notifyAckInterval = setInterval(retryAckResponses, 4 * 1000);
                  getStatusInterval = setInterval(getStatusByInterval, 5 * 60 * 1000);
                Severity: Major
                Found in lib/agent/control-panel/websockets/index.js - About 5 hrs to fix

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

                  exports.sync = (id, err, triggers, stored, cb) => {
                    var watching = [];
                  
                    if (err) {
                      logger.error('error starting async: ' + err);
                  Severity: Major
                  Found in lib/agent/actions/triggers/index.js - About 4 hrs to fix

                    Function get_firmware_info has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                    Open

                    exports.get_firmware_info = (callback) => {
                      let data = {};
                      const fetch = (key, section, value) => {
                        wmic.get_value(section, value, null, (err, resp) => {
                          let res = resp;
                    Severity: Minor
                    Found in lib/agent/providers/hardware/windows.js - About 4 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 preyconf.js has 340 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    const fs = require('fs');
                    const { join } = require('path');
                    const configPath = require('../../../common').system.paths.config;
                    const logger = require('../../common').logger.prefix('preyconf');
                    const storage = require('../storage');
                    Severity: Minor
                    Found in lib/agent/utils/prey-configuration/preyconf.js - About 4 hrs to fix

                      Function activate has 101 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      exports.activate = (trigger) => {
                        try {
                          var index = trigger.automation_events.findIndex(
                              (obj) => obj.type === 'exact_time' || obj.type === 'repeat_time'
                            ),
                      Severity: Major
                      Found in lib/agent/actions/triggers/index.js - About 4 hrs to fix

                        File storage.js has 334 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        var fs = require('fs'),
                          async = require('async'),
                          join = require('path').join,
                          sqlite3 = require('sqlite3').verbose(),
                          //logger  = require('../common').logger.prefix('storage'),
                        Severity: Minor
                        Found in lib/agent/utils/storage.js - About 4 hrs to fix

                          Function start has 100 lines of code (exceeds 25 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: Major
                          Found in lib/agent/actions/wipe/index.js - About 4 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language