prey/prey-node-client

View on GitHub

Showing 323 of 551 total issues

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

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

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

    exp.track_hardware_changes = (dataTrack) => {
      const removeKeysFromObjectImmutable = (obj, keys) => Object.keys(obj).reduce((acc, key) => {
        if (!keys.includes(key)) {
          acc[key] = obj[key];
        }
    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 setUpHooks has a Cognitive Complexity of 58 (exceeds 5 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: Minor
    Found in lib/agent/actions/triggers/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

    File index.js has 545 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: Major
    Found in lib/agent/control-panel/websockets/index.js - About 1 day to fix

      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

      Function start has 180 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 7 hrs to fix

        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

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

          exports.activate = (trigger) => {
            let index;
            let info;
            let opts;
            try {
          Severity: Minor
          Found in lib/agent/actions/triggers/index.js - About 6 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

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

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

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

                  exports.sync = (success, id, err, triggersSync, storedSync, cb) => {
                    let triggers = [...triggersSync];
                    const stored = [...storedSync];
                    const watching = [];
                  
                  
                  Severity: Major
                  Found in lib/agent/actions/triggers/index.js - About 5 hrs to fix

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

                    exports.perform = function (command) {
                      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 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

                    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

                      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