prey/prey-node-client

View on GitHub

Showing 551 of 551 total issues

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

    Object.keys(this.permissionData).forEach((key) => {
      if (data[key]) {
        this.permissionData[key] = data[key];
      }
    });
Severity: Major
Found in lib/utils/permissionfile.js and 1 other location - About 1 hr to fix
lib/utils/configfile.js on lines 131..135

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 59.

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

const updateStoredConnection = (newStoredTime) => {
  storage.do('update', {
    type: 'keys', id: 'last_connection', columns: 'value', values: newStoredTime,
  }, (err) => {
    if (err) logger.info('Unable to update the local last connection value');
Severity: Major
Found in lib/agent/control-panel/websockets/index.js and 1 other location - About 1 hr to fix
lib/agent/control-panel/long-polling/index.js on lines 243..249

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 59.

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

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

        storage.do('clear', {type: 'versions'}, (err) => {
          if (err) return cb(new Error("Error deleting update attempts registry: " + err.message));
          return cb && cb(err);
        });
Severity: Major
Found in lib/package.js and 1 other location - About 1 hr to fix
lib/package.js on lines 281..284

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 59.

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

function update_stored_connection(new_stored_time) {
  storage.do('update', {
    type: 'keys', id: 'last_connection', columns: 'value', values: new_stored_time,
  }, (err) => {
    if (err) logger.info('Unable to update the local last connection value');
Severity: Major
Found in lib/agent/control-panel/long-polling/index.js and 1 other location - About 1 hr to fix
lib/agent/control-panel/websockets/index.js on lines 217..223

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 59.

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

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

  storage.do('clear', {type: 'versions'}, (err) => {
    if (err) return cb(new Error("Error deleting update attempts registry: " + err.message));
    return cb && cb(err);
  });
Severity: Major
Found in lib/package.js and 1 other location - About 1 hr to fix
lib/package.js on lines 528..531

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 59.

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

    Object.keys(this.preyConfiguration).forEach((key) => {
      if (data[key]) {
        this.preyConfiguration[key] = data[key];
      }
    });
Severity: Major
Found in lib/utils/configfile.js and 1 other location - About 1 hr to fix
lib/utils/permissionfile.js on lines 57..61

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 59.

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

    values: (data) => {
      return `'${data.id}', '${data.name}', '${data.path}', '${data.size}', '${data.user}', 0, 0`;
    }
Severity: Major
Found in lib/agent/utils/storage.js and 1 other location - About 1 hr to fix
lib/agent/utils/storage.js on lines 62..64

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 59.

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

  setTimeout(() => {
    devices.post_sso_status(data, (err) => {
      if (err) logger.error(`Unable to notify error status: ${err.message}`);
    });
  }, 2000);
Severity: Major
Found in lib/agent/control-panel/secure.js and 1 other location - About 1 hr to fix
lib/agent/control-panel/secure.js on lines 35..39

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 59.

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

    values: (data) => {
      return `'${data.id}', '${data.from}', '${data.to}','${data.attempts}','${data.notified}'`;
    }
Severity: Major
Found in lib/agent/utils/storage.js and 1 other location - About 1 hr to fix
lib/agent/utils/storage.js on lines 38..40

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 59.

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

  setTimeout(() => {
    devices.post_sso_status(data, (err) => {
      if (err) logger.error(`Unable to notify success status: ${err.message}`);
    });
  }, 2000);
Severity: Major
Found in lib/agent/control-panel/secure.js and 1 other location - About 1 hr to fix
lib/agent/control-panel/secure.js on lines 50..54

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 59.

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

  def update_button_and_exit(self):
    self.button.set_label('Message Sent!')
    self.button.set_sensitive(True)
    gobject.timeout_add(1000, self.exit)
Severity: Major
Found in lib/agent/actions/alert/linux/flash.py and 1 other location - About 1 hr to fix
lib/agent/actions/alert/linux/flash3.py on lines 54..57

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 40.

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

    def update_button_and_exit(self):
        self.button.set_label("Message Sent!")
        self.button.set_sensitive(True)
        GLib.timeout_add(1000, self.exit)
Severity: Major
Found in lib/agent/actions/alert/linux/flash3.py and 1 other location - About 1 hr to fix
lib/agent/actions/alert/linux/flash.py on lines 45..48

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 40.

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

exports.get_outbound_connections_list = function(callback) {

  var connections = [],
      command = 'netstat -ano';

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

    Function versionPromise has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const versionPromise = new Promise((resolve, reject) => {
        exec(exports.cmdExistInstallPreyUser, (_parentError, parentStdout) => {
          if (parentStdout && parentStdout.trim() !== '') {
            exec(exports.cmdInstallPreyUserVersion, (error, preyUserVersionInstall) => {
              if (error) {
    Severity: Minor
    Found in lib/conf/tasks/prey_owl.js - About 1 hr to fix

      Function return_status has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function return_status(err, res) {
          function disconnected(err) {
            logger.debug('Device cannot connect to host');
            if (err) {
              logger.error(`Connection error: ${err}`);
      Severity: Minor
      Found in lib/agent/providers/network/index.js - About 1 hr to fix

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

        module.exports = function(cmd, opts, cb) {
          var out  = '',
              err  = '',
              args = Array.isArray(cmd) ? cmd : cmd.split(' '),
              bin  = args.shift();
        Severity: Minor
        Found in lib/conf/utils/run.js - About 1 hr to fix

          Function try_connecting_to has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          exports.try_connecting_to = function(list, cb) {
            var array = [];
            list.forEach(function(ap) {
              array.push(
                function(callback) {
          Severity: Minor
          Found in lib/agent/triggers/auto-connect/reconnect.js - About 1 hr to fix

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

            const done = (err, filePath, cb) => {
              running = false;
              if (timer) clearTimeout(timer);
              if (err) return cb(err);
              cb(null, filePath, 'image/jpeg');
            Severity: Major
            Found in lib/agent/providers/webcam/mac/index.js and 1 other location - About 1 hr to fix
            lib/agent/providers/screenshot/mac/index.js on lines 35..40

            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 58.

            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

            const done = (err, filePath, cb) => {
              running = false;
              if (timer) clearTimeout(timer);
              if (err) return cb(err);
              cb(null, filePath, 'image/jpeg');
            Severity: Major
            Found in lib/agent/providers/screenshot/mac/index.js and 1 other location - About 1 hr to fix
            lib/agent/providers/webcam/mac/index.js on lines 34..39

            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 58.

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

            exports.find_logged_user = function(callback) {
              var done = function(err, stdout) {
                if (err) {
                  if (typeof callback !== 'function')
                    return;
            Severity: Minor
            Found in lib/system/windows/index.js - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language