prey/prey-node-client

View on GitHub

Showing 551 of 551 total issues

Function check has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

exports.check = function (id, target, opts, cb) {
  function done(err) {
    if (cb && typeof cb === 'function') return cb && cb(err);
  }

Severity: Minor
Found in lib/agent/updater.js - About 1 hr 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_access_points_list has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

exports.get_access_points_list = function(callback, attempt) {

  get_first_wireless_interface(function(err, wifi_device) {
    if (err || !wifi_device)
      return callback(new Error(err || 'No wireless adapter found.'));
Severity: Minor
Found in lib/agent/providers/network/linux.js - About 1 hr 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 12 (exceeds 5 allowed). Consider refactoring.
Open

exports.get_battery_status = function(cb) {

  var keys = 'Availability,BatteryStatus,EstimatedChargeRemaining,EstimatedRunTime';

  var get_state = function(num) {
Severity: Minor
Found in lib/agent/providers/indicators/windows.js - About 1 hr 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_active_access_point has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

exports.get_active_access_point = function(callback) {
  // There's not enough information using the command related to the current AP, so we need to consult the AP list.
  // TODO: Optimize the AP list command usage.
  exports.get_active_access_point_mac((err, ap_mac) => {
    if (err || !ap_mac) return callback(err || new Error('No active access point found.'));
Severity: Minor
Found in lib/agent/providers/network/linux.js - About 1 hr 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 toUnix has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

const toUnix = (dateData) => {
  let date = dateData;
  let newDate;
  try {
    if (/^\d+$/.test(date)) {
Severity: Minor
Found in lib/agent/actions/triggers/index.js - About 1 hr 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 read has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

exports.read = function(file, cb) {

  fs.stat(file, function(err, stat){
    if (err) // not there probably
      return cb(err);
Severity: Minor
Found in lib/agent/utils/pidfile.js - About 1 hr 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 preyConfReconf has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

const preyConfReconf = () => {
  getDataFromShouldPreyCFile((_err, shouldPreyCFile) => {
    if (shouldPreyCFile && shouldPreyCFile.localeCompare('true') === 0) {
      setTimeout(correctDataTimedOut, 1000 * 60 * 5);
      setInterval(correctDataTimedOut, 1000 * 60 * 30);
Severity: Minor
Found in lib/agent/index.js - About 1 hr 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 LatLon has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

var LatLon = function(lat, lon, rad) {
  if (typeof(rad) == 'undefined') rad = 6371;  // earth's mean radius in km
  // only accept numbers or valid numeric strings
  this._lat = typeof(lat)=='number' ? lat : typeof(lat)=='string' && lat.trim()!='' ? +lat : NaN;
  this._lon = typeof(lon)=='number' ? lon : typeof(lon)=='string' && lon.trim()!='' ? +lon : NaN;
Severity: Minor
Found in lib/agent/triggers/location/lib/latlng.js - About 1 hr 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 eachFileOrDirectory has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var eachFileOrDirectory = function(directory, fileHandler, completeHandler) {
  var filesToCheck = 0;
  // var checkedFiles = [];
  // var checkedStats = [];

Severity: Minor
Found in lib/agent/providers/files/finder.js - About 1 hr to fix

    Function get_active_access_point has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.get_active_access_point = (callback) => {
      if (release >= 6.0) {
        // eslint-disable-next-line consistent-return
        exec('netsh wlan show interfaces', { timeout: 5000 }, (error, stdout) => {
          if (error) return callback(error);
    Severity: Minor
    Found in lib/agent/providers/network/windows.js - About 1 hr to fix

      Function dataToSavePreyConf has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const dataToSavePreyConf = () => {
        let allFileContents = '';
        try {
          allFileContents = getFileContent(exports.preyConfPath);
          if (allFileContents === '') {
      Severity: Minor
      Found in lib/agent/utils/prey-configuration/preyconf.js - About 1 hr to fix

        Function verificationPreyConfiguration has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const verificationPreyConfiguration = (callback) => {
          try {
            clearIntervalDbPreyConf();
            saveDataVerify(() => {});
            dbPreyConfInterval = setIntervalDbPreyConf();
        Severity: Minor
        Found in lib/agent/utils/prey-configuration/validationpreyconf.js - About 1 hr to fix

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          module.exports.get_users_list = function(cb) {
            exec(cmd, function(err, stdout) {
              cb(err, stdout.split("\n").slice(0, -1));
            });
          };
          Severity: Major
          Found in lib/agent/providers/users/mac.js and 2 other locations - About 1 hr to fix
          lib/agent/providers/users/linux.js on lines 12..16
          lib/agent/providers/users/windows.js on lines 12..16

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 63.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          exports.deleteOsquery = (cb) => {
            exec(`${paths.current}/bin/trinity --uninstall`, () => {
              if (cb && typeof cb !== 'undefined') cb();
            });
          };
          Severity: Major
          Found in lib/conf/tasks/os/mac.js and 1 other location - About 1 hr to fix
          lib/conf/tasks/os/windows.js on lines 109..113

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 63.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          exports.deleteOsquery = (cb) => {
            exec(`${paths.current}\\bin\\trinity --uninstall`, () => {
              if (cb && typeof cb !== 'undefined') cb();
            });
          };
          Severity: Major
          Found in lib/conf/tasks/os/windows.js and 1 other location - About 1 hr to fix
          lib/conf/tasks/os/mac.js on lines 17..21

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 63.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          module.exports.get_users_list = function(cb) {
            exec(cmd, function(err, stdout) {
              cb(err, stdout.split("\n").slice(0, -1));
            });
          };
          Severity: Major
          Found in lib/agent/providers/users/linux.js and 2 other locations - About 1 hr to fix
          lib/agent/providers/users/mac.js on lines 12..16
          lib/agent/providers/users/windows.js on lines 12..16

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 63.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          module.exports.get_users_list = function(cb) {
            exec(cmd, function(err, stdout) {
              cb(err, stdout.split("\n").slice(1, -2));
            });
          };
          Severity: Major
          Found in lib/agent/providers/users/windows.js and 2 other locations - About 1 hr to fix
          lib/agent/providers/users/linux.js on lines 12..16
          lib/agent/providers/users/mac.js on lines 12..16

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 63.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Function parse has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          exports.parse = function (body) {
            let c;
            let matches;
          
            if ((matches = body.match(/^help\s?(\w+)?/))) c = ['help', matches[1]];
          Severity: Minor
          Found in lib/agent/commands.js - About 1 hr to fix

            Function get_active_nodes_list has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            exports.get_active_nodes_list = function(callback){
            
              var nodes = [], skip = ['WORKGROUP', '..__MSBROWSE__.'];
            
              network.get_active_network_interface(function(err, nic) {
            Severity: Minor
            Found in lib/agent/providers/lan/linux.js - About 1 hr to fix

              Function exports has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports = function(cmd, args, opts, cb) {
              
                var opts = opts || {};
              
                // set detached so that when running from an already-detached process we don't
              Severity: Minor
              Found in lib/conf/utils/run_synced.js - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language