prey/prey-node-client

View on GitHub

Showing 323 of 551 total issues

Function remote has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

exports.remote = function(values, cb) {

  var wants_version = values.version;
  var destination   = values['-d'] || paths.versions;

Severity: Minor
Found in lib/conf/install.js - About 55 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 use has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

exports.use = function (obj) {
  for (const key in obj) {
    if (defaults.hasOwnProperty(key)) {
      if (key == 'protocol' && ['http', 'https'].indexOf(obj[key]) === -1) {
        logger.error(`Invalid protocol: ${obj[key]}`);
Severity: Minor
Found in lib/agent/control-panel/api/request.js - About 55 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 send has a Cognitive Complexity of 9 (exceeds 5 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: Minor
Found in lib/agent/control-panel/api/request.js - About 55 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 createServer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

const createServer = (cb) => {
  if (osName === 'linux') return cb(new Error('Service only available for mac and windows'));

  checkService((valid) => {
    if (!valid) return cb(new Error('Windows Service not compatible'));
Severity: Minor
Found in lib/agent/control-panel/websockets/server.js - About 55 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 notifyAck has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

exports.notifyAck = (ackId, type, id, sent, retries = 0) => {
  if (retries >= retriesMaxAck) {
    removeAckFromArray(ackId);
    return;
  }
Severity: Minor
Found in lib/agent/control-panel/websockets/index.js - About 55 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 9 (exceeds 5 allowed). Consider refactoring.
Open

exports.start = (id, _opts, cb) => {
  cb();
  api.devices.get.status((err, response) => {
    if (err) return;
    const result = response && response.body;
Severity: Minor
Found in lib/agent/actions/sync_settings/index.js - About 55 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 checkRules has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

const checkRules = (rule) => {
  if (rule.second && (rule.second < 0 || rule.second > 60)) return false;
  if (rule.minute && (rule.minute < 0 || rule.minute > 60)) return false;
  if (rule.hour && (rule.hour < 0 || rule.hour > 24)) return false;
  if (rule.dayOfWeek.some((elem) => elem > 6 || elem < 0)) return false;
Severity: Minor
Found in lib/agent/actions/triggers/index.js - About 55 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 all has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

storage_fns.all = (opts, cb) => {
  init(opts.type, null, (err, db) => {
    if (err) return cb(err);
    db_comm.all(queries.SELECT(opts.type), function (err, rows) {
      if (err) {
Severity: Minor
Found in lib/agent/utils/storage.js - About 55 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 add_label has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def add_label(self, text, font_name, font_size, x, y, width, height):
Severity: Major
Found in lib/agent/actions/alert/darwin/flash.py - About 50 mins to fix

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

    function as(user_type, type, bin, args, opts, cb) {
    Severity: Minor
    Found in lib/system/index.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                        if (errSetting) logger.error(`Error while setting shouldPreyCFile: ${errSetting}`);
      Severity: Major
      Found in lib/utils/configfile.js - About 45 mins to fix

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

        exports.get_osquery_running = (cb) => {
          exec('ps aux | grep "/opt/osquery/lib/osquery.app/Contents/MacOS/osqueryd --flagfile=/private/var/prey/osquery.flags" | grep "^root" | awk \'{print $2}\' | tr -d \'\\n\'', (err, stdout, stderr) => {
            if (err) return cb(null, false, 'osquery_running');
            if (stderr) return cb(null, false, 'osquery_running');
            const matchResult = stdout.match(/\d+/);
        Severity: Minor
        Found in lib/agent/providers/hardware/mac.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 (!stdoutsiBattery || !stdoutsiBattery.hasBattery) {
                              data.device_type = 'Desktop';
                              callback(null, data);
                            } else {
                              data.device_type = 'Laptop';
        Severity: Major
        Found in lib/agent/providers/hardware/windows.js - About 45 mins to fix

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

          exports.post_missing = (opt, cb) => {
            if (!keys.get().api || !keys.get().device)
              return cb(errors.get('MISSING_KEY'));
          
            if (opt == null || typeof opt != 'boolean')
          Severity: Minor
          Found in lib/agent/control-panel/api/devices.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 (a) {
                        analyze(a, options.slice(parseInt(i) + 1));
                        break;
          
                      } else { 
          Severity: Major
          Found in lib/conf/utils/operetta.js - About 45 mins to fix

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

            exports.install = function (cb) {
              var next = function (err) {
                // EBUSY error is when file is being run. that shouldn't happen normally
                // but for the purposes of setting up the daemon, it doesn't really matter.
                if (err && err.code !== 'EBUSY') return cb(err);
            Severity: Minor
            Found in lib/conf/tasks/daemon.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 accessPointsFn has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            const accessPointsFn = (cmd, args, cb) => {
              if (common.os_release >= '12.0') {
                sudo(cmd, args, (err, stdout, stderr) => {
                  if (stderr) logger.error(stderr);
                  return cb(err, stdout);
            Severity: Minor
            Found in lib/agent/providers/network/mac.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 get_battery_status has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            exports.get_battery_status = function(callback){
            
              exec('pmset -g batt', function(err, stdout){
                if (err) return callback(err);
            
            
            Severity: Minor
            Found in lib/agent/providers/indicators/mac.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 notify_action has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            exports.notify_action = function (status, id, name, opts, err, out) {
            Severity: Minor
            Found in lib/agent/control-panel/sender.js - About 45 mins to fix

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

              const send = function (attempt, method, path, data, options, cb) {
              Severity: Minor
              Found in lib/agent/control-panel/api/request.js - About 45 mins to fix
                Severity
                Category
                Status
                Source
                Language