prey/prey-node-client

View on GitHub

Showing 551 of 551 total issues

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

var get = exports.get = function(name, extra) {

  var args = arguments,
      cb,
      options;
Severity: Minor
Found in lib/agent/providers.js - About 2 hrs to fix

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

        exports.find_logged_user(function(err, logged_user) {
          if (err) cb(null, non_root[0]);
    
          if (non_root.indexOf(logged_user) != -1)
            return cb(null, logged_user);
    Severity: Major
    Found in lib/system/linux/index.js and 1 other location - About 2 hrs to fix
    lib/system/mac/index.js on lines 55..62

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

    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

        exports.find_logged_user(function(err, logged_user) {
          if (err) cb(null, non_root[0]);
    
          if (non_root.indexOf(logged_user) != -1)
            return cb(null, logged_user);
    Severity: Major
    Found in lib/system/mac/index.js and 1 other location - About 2 hrs to fix
    lib/system/linux/index.js on lines 61..68

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

    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

    GeocoordinateSatelliteData = (function () {
      var cls = function GeocoordinateSatelliteData() {
        this.horizontalDilutionOfPrecision = new Number();
        this.positionDilutionOfPrecision = new Number();
        this.verticalDilutionOfPrecision = new Number();
    lib/agent/providers/geo/win32/windows.devices.geolocation/lib/NodeRT_Windows_Devices_Geolocation.d.js on lines 2..9
    lib/agent/providers/geo/win32/windows.devices.geolocation/lib/NodeRT_Windows_Devices_Geolocation.d.js on lines 53..62

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

    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

    BasicGeoposition = (function () {
      var cls = function BasicGeoposition() {
          this.latitude = new Number();
          this.longitude = new Number();
          this.altitude = new Number();
    lib/agent/providers/geo/win32/windows.devices.geolocation/lib/NodeRT_Windows_Devices_Geolocation.d.js on lines 53..62
    lib/agent/providers/geo/win32/windows.devices.geolocation/lib/NodeRT_Windows_Devices_Geolocation.d.js on lines 99..108

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

    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

    IGeoshape = (function () {
      var cls = function IGeoshape() {
        this.altitudeReferenceSystem = new AltitudeReferenceSystem();
        this.geoshapeType = new GeoshapeType();
        this.spatialReferenceId = new Number();
    lib/agent/providers/geo/win32/windows.devices.geolocation/lib/NodeRT_Windows_Devices_Geolocation.d.js on lines 2..9
    lib/agent/providers/geo/win32/windows.devices.geolocation/lib/NodeRT_Windows_Devices_Geolocation.d.js on lines 99..108

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

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

    exports.open_config = (deviceKey, cb) => {
      const protocol = config.getData('control-panel.protocol');
      const host = config.getData('control-panel.host');
      let panelHost;
      switch (host) {
    Severity: Minor
    Found in lib/agent/control-panel/secure.js - About 1 hr to fix

      Function start has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exports.start = function(id, options, cb) {
        var error,
            self     = this,
            returned = 0;
      
      
      Severity: Minor
      Found in lib/agent/actions/alarm/index.js - About 1 hr to fix

        Function get_connection_status has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        exp.get_connection_status = function (cb) {
          const data = config.all();
          const configData = data;
          const proxy = configData.try_proxy;
          const protocol = configData['control-panel.protocol'];
        Severity: Minor
        Found in lib/agent/providers/network/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

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

            def parse_error(self, line):
                if line.find("been taken") != -1:
                    return "Email has been taken. Seems you already signed up!"
                elif line.find("Unexpected status code: 401") != -1:
                    return "Invalid account credentials. Please try again."
        Severity: Major
        Found in lib/conf/gui/linux/prey-config3.py and 1 other location - About 1 hr to fix
        lib/conf/gui/linux/prey-config.py on lines 310..316

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

        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 parse_error(self, line):
            if line.find('been taken') != -1:
              return 'Email has been taken. Seems you already signed up!'
            elif line.find('Unexpected status code: 401') != -1:
              return 'Invalid account credentials. Please try again.'
        Severity: Major
        Found in lib/conf/gui/linux/prey-config.py and 1 other location - About 1 hr to fix
        lib/conf/gui/linux/prey-config3.py on lines 344..350

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

        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 watch_action_events = (events, emitter) => {
          events.forEach((eventName) => {
            emitter.on(eventName, (data) => {
              hooks.trigger('event', eventName, data);
              hooks.trigger(eventName, data);
        Severity: Major
        Found in lib/agent/actions.js and 1 other location - About 1 hr to fix
        lib/agent/triggers.js on lines 53..60

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

        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 watchTriggersEvents = (events, emitter) => {
          events.forEach((eventName) => {
            emitter.on(eventName, (data) => {
              hooks.trigger('event', eventName, data);
              hooks.trigger(eventName, data);
        Severity: Major
        Found in lib/agent/triggers.js and 1 other location - About 1 hr to fix
        lib/agent/actions.js on lines 17..24

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

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

        const readWithoutVerification = (cb) => {
          const extractedData = {};
          let nameBefore = '';
          let content = '';
          try {
        Severity: Minor
        Found in lib/agent/utils/prey-configuration/preyconf.js - About 1 hr to fix

          Function getPreyUserVersions has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const getPreyUserVersions = (preyUserVersion, cb) => {
            const successHandler = (foundVersion) => {
              if (foundVersion) {
                compareVersionsDaemon(foundVersion, preyUserVersion, cb);
              } else {
          Severity: Minor
          Found in lib/conf/tasks/prey_owl.js - About 1 hr to fix

            Function generate_keys has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            exports.generate_keys = (cb) => {
              storage.do('all', { type: 'keys' }, (err, values) => {
                if (err || !values) { return cb(new Error('Error reading stored security keys')); }
            
                // Read stored keys if they exists
            Severity: Minor
            Found in lib/agent/control-panel/secure.js - About 1 hr to fix

              Function verifyPreyConfData has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const verifyPreyConfData = (doNotVerifyApiDeviceKey = false) => {
                const dataToFix = {};
                let somethingWrong = false;
                resetDefaultValues();
                let content = '';
              Severity: Minor
              Found in lib/agent/utils/prey-configuration/preyconf.js - About 1 hr to fix

                Function collectFiles has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const collectFiles = (outputFile, cb) => {
                  const output = fs.createWriteStream(outputFile);
                  const archive = archiver('zip', {
                    zlib: { level: 9 },
                  });
                Severity: Minor
                Found in lib/agent/actions/logretrieval/index.js - About 1 hr to fix

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

                        if (err) {
                          const error = err;
                          error.code = 5;
                          error.name = errorFullwipe.find((x) => x.code === error.code).message;
                          return cb(error);
                  Severity: Major
                  Found in lib/agent/actions/fullwipe/index.js and 1 other location - About 1 hr to fix
                  lib/agent/actions/factoryreset/index.js on lines 71..76

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

                  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 configurePictureUserData = () => {
                    pictureUtilData.appPath = `${__dirname}/../../../utils/Prey.app`;
                    pictureUtilData.pictureDir = '/tmp';
                    pictureUtilData.tmpPicture = `${pictureUtilData.pictureDir}/picture.jpg`;
                  };
                  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 44..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 71.

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language