prey/prey-node-client

View on GitHub

Showing 551 of 551 total issues

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

  if (osName !== 'windows') {
    const error = new Error('Action only allowed on Windows 1O');
    error.code = 3;
    error.name = errorFactoryReset.find((x) => x.code === error.code).message;
    return cb(error);
Severity: Major
Found in lib/agent/actions/factoryreset/index.js and 1 other location - About 2 hrs to fix
lib/agent/actions/fullwipe/index.js on lines 30..35

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

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

File index.js has 258 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const os = require('os');
const { join } = require('path');
const setup = require('./setup');
const sender = require('./sender');
const secure = require('./secure');
Severity: Minor
Found in lib/agent/control-panel/index.js - About 2 hrs to fix

    Function send has 54 lines of code (exceeds 25 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: Major
    Found in lib/agent/control-panel/api/request.js - About 2 hrs to fix

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

        this.parse = function(listener) {
      
          var operetta = this, parameter;
      
          var sing = function(argument, data) {
      Severity: Major
      Found in lib/conf/utils/operetta.js - About 2 hrs to fix

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

              return correctPreyConf(null, (errorCorrectPreyConf) => {
                if (errorCorrectPreyConf) return callback();
                // eslint-disable-next-line consistent-return
                getRestartsPreyconf((errRestartPreyConf, dataRestart) => {
                  if (errRestartPreyConf || !dataRestart) {
        Severity: Major
        Found in lib/agent/utils/prey-configuration/validationpreyconf.js and 1 other location - About 2 hrs to fix
        lib/agent/utils/prey-configuration/validationpreyconf.js on lines 115..127

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

        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

              correctPreyConf(jsonData, (errorCorrectPreyConf) => {
                if (errorCorrectPreyConf) return callback();
                // eslint-disable-next-line consistent-return
                getRestartsPreyconf((errRestartPreyConf, dataRestart) => {
                  if (errRestartPreyConf || !dataRestart) {
        Severity: Major
        Found in lib/agent/utils/prey-configuration/validationpreyconf.js and 1 other location - About 2 hrs to fix
        lib/agent/utils/prey-configuration/validationpreyconf.js on lines 94..106

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

        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 authorize has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        exports.authorize = function (opts, cb) {
          if (!opts || !opts.username || !opts.password) { throw (errors.arguments('No credentials passed!')); }
        
          if (keys.get().api) { throw (errors.get('API_KEY_SET')); }
        
        
        Severity: Minor
        Found in lib/agent/control-panel/api/accounts.js - About 2 hrs 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 sync has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        const sync = () => {
          api.devices.get.status((err, response) => {
            const result = response && response.body;
            if (!result || (response && response.statusCode > 300)) { return logger.warn('Unable to sync settings.'); }
        
        
        Severity: Minor
        Found in lib/agent/control-panel/index.js - About 2 hrs 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 16 (exceeds 5 allowed). Consider refactoring.
        Open

        exports.start = function (id, options, cb) {
          const osName = os.platform().replace('darwin', 'mac').replace('win32', 'windows');
        
          if (osName !== 'windows') {
            const error = new Error('Action only allowed on Windows 1O');
        Severity: Minor
        Found in lib/agent/actions/factoryreset/index.js - About 2 hrs 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 16 (exceeds 5 allowed). Consider refactoring.
        Open

        exports.start = (id, options, cb) => {
          const opts = options || {};
          const token = opts.token || null;
          // const confirm = opts.confirm === 'ireallyknowwhatiamdoing';
          const items = validTypes(opts);
        Severity: Minor
        Found in lib/agent/actions/wipe/index.js - About 2 hrs 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 16 (exceeds 5 allowed). Consider refactoring.
        Open

        exports.start = (id, opts, cb) => {
          const osName = os.platform().replace('darwin', 'mac').replace('win32', 'windows');
          if (osName !== 'windows') {
            const error = new Error('Action only allowed on Windows 1O');
            error.code = 3;
        Severity: Minor
        Found in lib/agent/actions/fullwipe/index.js - About 2 hrs 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

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

            if args.level == 'warning' or args.level == 'warn':
              bg_color = red
              if title == 'Important':
                title = 'Warning'
            else:
        Severity: Major
        Found in lib/agent/actions/alert/linux/flash.py and 1 other location - About 2 hrs to fix
        lib/agent/actions/alert/linux/flash3.py on lines 152..157

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

        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

                if args.level == "warning" or args.level == "warn":
                    bg_color = red
                    if title == "Important":
                        title = "Warning"
                else:
        Severity: Major
        Found in lib/agent/actions/alert/linux/flash3.py and 1 other location - About 2 hrs to fix
        lib/agent/actions/alert/linux/flash.py on lines 137..142

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

        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

          def validate_email(self, email_field):
            if not self.valid_email_regex(self.text(email_field)):
              self.show_alert(_("Invalid email"), _("Please make sure the email address you typed is valid."))
              return False
        
        
        Severity: Major
        Found in lib/conf/gui/linux/prey-config.py and 1 other location - About 2 hrs to fix
        lib/conf/gui/linux/prey-config3.py on lines 80..88

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

        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

          def validate_password(self, password_field):
            if len(self.text(password_field)) < 6:
              self.show_alert(_("Bad password"), _("Password should contain at least 6 chars."))
              return False
        
        
        Severity: Major
        Found in lib/conf/gui/linux/prey-config.py and 1 other location - About 2 hrs to fix
        lib/conf/gui/linux/prey-config3.py on lines 90..97

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

        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

            def validate_password(self, password_field):
                if len(self.text(password_field)) < 6:
                    self.show_alert(
                        _("Bad password"), _("Password should contain at least 6 chars.")
                    )
        Severity: Major
        Found in lib/conf/gui/linux/prey-config3.py and 1 other location - About 2 hrs to fix
        lib/conf/gui/linux/prey-config.py on lines 86..91

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

        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

            def validate_email(self, email_field):
                if not self.valid_email_regex(self.text(email_field)):
                    self.show_alert(
                        _("Invalid email"),
                        _("Please make sure the email address you typed is valid."),
        Severity: Major
        Found in lib/conf/gui/linux/prey-config3.py and 1 other location - About 2 hrs to fix
        lib/conf/gui/linux/prey-config.py on lines 79..84

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

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

        exports.get_picture = function(main_callback){
        
          var picture_file = temp_path('picture.' + process.pid + '.jpg'),
              tmp_path     = '/tmp',
              size         = '640x480',
        Severity: Major
        Found in lib/agent/providers/webcam/linux/index.js - About 2 hrs to fix

          File prey-config.py has 253 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          #!/usr/bin/env python
          ################################################
          # Prey Configurator for Linux
          # By Tomas Pollak
          # (c) 2012-2014 - Fork Ltd. (usefork.com)
          Severity: Minor
          Found in lib/conf/gui/linux/prey-config.py - About 2 hrs to fix

            Function parse_access_points_list_netsh has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            exports.parse_access_points_list_netsh = (out) => {
              // eslint-disable-next-line prefer-const
              let list = [];
              const blocks = out.split(/\nSSID \d{1,2}\s:/);
            
            
            Severity: Minor
            Found in lib/agent/providers/network/windows.js - About 2 hrs to fix
              Severity
              Category
              Status
              Source
              Language