prey/prey-node-client

View on GitHub

Showing 323 of 551 total issues

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

const getLocation = (cb) => {
  // eslint-disable-next-line consistent-return
  system.get_os_version((_err, version) => {
    if (version && greaterOrEqual(version, '10.6.0')) {
      socket.writeMessage(nameArray[0], (err, data) => {
Severity: Minor
Found in lib/agent/providers/geo/darwin/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 validate_new_user_fields has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def validate_new_user_fields(self, name, email, terms, age, passwd, passwd2 = None):
Severity: Minor
Found in lib/conf/gui/mac/PreyConfig.app/Contents/MacOS/prey-config.py - 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 reactToCheckLocationPerms has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const reactToCheckLocationPerms = (data) => {
      permissionFile.setData('nativeLocation', data[1].result, () => {
        network.isWifiPermissionActive((output) => {
          permissionFile.setData('wifiLocation', stringBooleanOrEmpty(output), () => {
            // eslint-disable-next-line max-len
    Severity: Minor
    Found in lib/agent/socket/listeners.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 sync has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.sync = (success, id, err, triggersSync, storedSync, cb) => {
        let triggers = [...triggersSync];
        const stored = [...storedSync];
        const watching = [];
      
      
      Severity: Minor
      Found in lib/agent/actions/triggers/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 requestNativePermission has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      const requestNativePermission = (cb) => {
        if (osName.localeCompare('mac') !== 0) return cb(new Error('Action only allowed on MacOS'));
        // eslint-disable-next-line consistent-return
        socket.writeMessage(nameArray[1], () => {
          const permissionNative = permissionFile.getData('nativeLocation');
      Severity: Minor
      Found in lib/agent/actions/request_permission/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 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

      Avoid deeply nested control flow statements.
      Open

                  if (preyConfDataToWrite) {
                    dataToInsert = preyConfDataToWrite[reqPreyConf[count].name] ? preyConfDataToWrite[reqPreyConf[count].name] : '';
                  } else {
                    dataToInsert = reqPreyConf[count].default
                    || ((typeof reqPreyConf[count].default === 'boolean') && reqPreyConf[count].default === false) ? reqPreyConf[count].default : '';
      Severity: Major
      Found in lib/agent/utils/prey-configuration/preyconf.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    if (line.match(reqPreyConf[count].value)) {
                      if (reqPreyConf[count].word === 'api_key') {
                        apiKeyValue = true;
                      } else if (reqPreyConf[count].word === 'device_key') {
                        deviceKeyValue = true;
        Severity: Major
        Found in lib/agent/utils/prey-configuration/preyconf.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                      if (match) {
                        const value = match[1];
                        const matchValue = reqPreyConf[count].possiblevalues.exec(value);
                        if (matchValue) {
                          preyConfData[reqPreyConf[count].name] = value;
          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 = 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

            Function drawImage has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def drawImage(self, file, width, height, x, y, view):
            Severity: Minor
            Found in lib/conf/gui/mac/PreyConfig.app/Contents/MacOS/prey-config.py - About 45 mins to fix

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

              exports.start = (opts, cb) => {
                hooks.on('mac_address_changed', () => {
                  fetchLocation('mac-address');
                });
              
              
              Severity: Minor
              Found in lib/agent/triggers/location/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/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

              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

              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

                    } 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

                    } else if (info.days_of_week && info.hour) {
                      // At least the days and hour
                  
                      try {
                        const rule = new schedule.RecurrenceRule();
                  Severity: Major
                  Found in lib/agent/actions/triggers/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
                      Severity
                      Category
                      Status
                      Source
                      Language