prey/prey-node-client

View on GitHub

Showing 312 of 527 total issues

Function linkDevice has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const linkDevice = (cb) => {
  getDeviceData((err, deviceData) => {
    const data = deviceData;
    if (err) return cb(err);

Severity: Minor
Found in lib/agent/control-panel/setup.js - About 45 mins 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 8 (exceeds 5 allowed). Consider refactoring.
Open

exports.start = function (opts, cb) {
  hooks.on('connected', () => {
    network.get_active_access_point((err, ap) => {
      if (was_disconnected) {
        logger.info(`Connection achieved! ${ap ? ap.ssid || '' : ''}`);
Severity: Minor
Found in lib/agent/triggers/auto-connect/index.js - About 45 mins 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

Avoid deeply nested control flow statements.
Open

              if (reqPreyConf[count].possiblevalues) {
                if (reqPreyConf[count].value && !reqPreyConf[count].value.test(line)) {
                  somethingWrong = true;
                  dataToFix[reqPreyConf[count].name] = false;
                }
Severity: Major
Found in lib/agent/utils/prey-configuration/preyconf.js - About 45 mins to fix

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

    exports.start = (id, opts, cb) => {
      const done = (err = null) => {
        if (err) return cb(err);
        if (!emitter) emitter = new Emitter();
        cb(err, emitter);
    Severity: Minor
    Found in lib/agent/actions/osquery/index.js - About 45 mins 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 __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def __init__(self):
    
        button_text = "Close"
        title = args.title
    
    
    Severity: Minor
    Found in lib/agent/actions/alert/linux/flash.py - About 45 mins 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 __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self):
    
            button_text = "Close"
            title = args.title
    
    
    Severity: Minor
    Found in lib/agent/actions/alert/linux/flash3.py - About 45 mins 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

    Consider simplifying this complex logical expression.
    Open

        } else if ((body && body.key) || (body && body.user && body.user.key)) {
          cb(null, set(body.key || body.user.key));
        } else {
          cb(errors.unknown(resp));
        }
    Severity: Major
    Found in lib/agent/control-panel/api/accounts.js - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

        if (data.os_name == 'windows' && gte(os.release().trim(), "10.0.0") &&
            data.os_edition && editions.includes(data.os_edition) &&
            data.winsvc_version && gte(data.winsvc_version, "2.0.0"))
            return true;
      Severity: Major
      Found in lib/system/windows/index.js - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

            if ((val !== 'false' && val !== 'off' && key.includes('wipe_')) && (val === 'on' || val === 'true' || validDirs(val))) {
              const method = key.replace('wipe_', ''); // just 'cookies'
              if (typeof wipe[method] === 'function') list.push(method);
            }
        Severity: Major
        Found in lib/agent/actions/wipe/index.js - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

            if (!dataToVerify || !dataFromDb
            || (typeof dataToVerify) !== 'object' || (typeof dataFromDb) !== 'object'
            || Object.keys(dataToVerify).length === 0
            || Object.keys(dataFromDb).length === 0) { return callback(false); }
          Severity: Major
          Found in lib/agent/utils/prey-configuration/preyconf.js - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

              } else if (info.days_of_week && info.hour) {
                // At least the days and hour
            
                try {
                  let rule = new schedule.RecurrenceRule();
            Severity: Major
            Found in lib/agent/actions/triggers/index.js - About 40 mins to fix

              Function trigger_running has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              var trigger_running = function (type, trigger, name, opts, emitter) {
              Severity: Minor
              Found in lib/agent/triggers.js - About 35 mins to fix

                Function set_proxy_and_send has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                const set_proxy_and_send = function (method, path, data, opts, cb) {
                Severity: Minor
                Found in lib/agent/control-panel/api/request.js - About 35 mins to fix

                  Function store has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  var store = function (type, id, name, opts, cb) {
                  Severity: Minor
                  Found in lib/agent/commands.js - About 35 mins to fix

                    Function drawRadio has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      def drawRadio(self, title, default, tag, width, height):
                    Severity: Minor
                    Found in lib/conf/gui/mac/PreyConfig.app/Contents/MacOS/prey-config.py - About 35 mins to fix

                      Function drawInput has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        def drawInput(self, type, id, title, x, y):
                      Severity: Minor
                      Found in lib/conf/gui/mac/PreyConfig.app/Contents/MacOS/prey-config.py - About 35 mins to fix

                        Function start has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        const start = function (type, id, name, opts, cb) {
                        Severity: Minor
                        Found in lib/agent/actions.js - About 35 mins to fix

                          Function request has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          exports.request = function request(method, url, data, opts, cb) {
                          Severity: Minor
                          Found in lib/agent/transports/http/index.js - About 35 mins to fix

                            Function isAirportWorking has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                            const isAirportWorking = (cb) => {
                              sudo(airportCmd, ['-s'], (err, stdout, stderr) => {
                                if (err) {
                                  logger.error(err);
                                  return cb(false);
                            Severity: Minor
                            Found in lib/agent/providers/network/mac.js - About 35 mins 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 show_and_exit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                            var show_and_exit = function(force) {
                            
                              var args     = [],
                                  gui_path = join(__dirname, os_name, 'prey-config');
                            
                            
                            Severity: Minor
                            Found in lib/conf/gui/index.js - About 35 mins 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

                            Severity
                            Category
                            Status
                            Source
                            Language