msimerson/Haraka

View on GitHub

Showing 655 of 655 total issues

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

'use strict';

const fs          = require('fs');
const path        = require('path');

Severity: Minor
Found in outbound/index.js - About 2 hrs to fix

    Function setupClient has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        static setupClient (self) {
            const ip = self.client.remoteAddress;
            if (!ip) {
                self.logdebug('setupClient got no IP address for this connection!');
                self.client.destroy();
    Severity: Major
    Found in connection.js - About 2 hrs to fix

      Consider simplifying this complex logical expression.
      Open

          if (config.rabbitmq) {
              options.host = config.rabbitmq.server_ip || '127.0.0.1';
              options.port = config.rabbitmq.server_port || '5672';
              options.login = config.rabbitmq.user || 'guest';
              options.password = config.rabbitmq.password || 'guest';
      Severity: Critical
      Found in plugins/queue/rabbitmq.js - About 2 hrs to fix

        Function bounce_spf has 66 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        exports.bounce_spf = function (next, connection) {
            if (!this.cfg.check.bounce_spf) return next();
            if (!this.has_null_sender(connection)) return next();
        
            const txn = connection?.transaction;
        Severity: Major
        Found in plugins/bounce.js - About 2 hrs to fix

          Function hook_deny has 66 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          exports.hook_deny = function (next, connection, params) {
              /* params
              ** [0] = plugin return value (DENY or DENYSOFT)
              ** [1] = plugin return message
              */
          Severity: Major
          Found in plugins/delay_deny.js - About 2 hrs to fix

            File logger.js has 276 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            'use strict';
            // Log class
            
            const util      = require('util');
            const tty       = require('tty');
            Severity: Minor
            Found in logger.js - About 2 hrs to fix

              Function add_dot_stuffing_and_ensure_crlf_newlines has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  add_dot_stuffing_and_ensure_crlf_newlines (data) {
                      if (!data.length) return data;
                      if (!Buffer.isBuffer(data)) data = Buffer.from(data);
              
                      // Make a new buffer big enough to hold two bytes for every one input
              Severity: Minor
              Found in transaction.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 write has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  write (buf) {
                      /*
                      ** BODY (simple canonicalization)
                      */
              
              
              Severity: Minor
              Found in plugins/dkim_sign.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 end_data has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  end_data (cb) {
                      if (!this.found_hb_sep && this.header_lines.length) {
                          // Headers not parsed yet - must be a busted email
                          // Strategy: Find the first line that doesn't look like a header.
                          // Treat anything before that as headers, anything after as body.
              Severity: Minor
              Found in transaction.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 add_data has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  add_data (line) {
                      if (typeof line === 'string') { // This shouldn't ever happen.
                          line = Buffer.from(line, this.encoding);
                      }
                      // is this the end of headers line?
              Severity: Minor
              Found in transaction.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

              File smtp_forward.js has 274 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              'use strict';
              // Forward to an SMTP server
              // Opens the connection to the ongoing SMTP server at queue time
              // and passes back any errors seen on the ongoing server to the
              // originating server.
              Severity: Minor
              Found in plugins/queue/smtp_forward.js - About 2 hrs to fix

                Function queue_forward has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                exports.queue_forward = function (next, connection) {
                    const plugin = this;
                    const txn = connection?.transaction;
                
                    const cfg = plugin.get_config(connection);
                Severity: Major
                Found in plugins/queue/smtp_forward.js - About 2 hrs to fix

                  Function hook_rcpt_ok has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  exports.hook_rcpt_ok = function (next, connection, rcpt) {
                  
                      if (this.should_skip_check(connection)) return next();
                      if (this.was_whitelisted_in_session(connection)) {
                          this.logdebug(connection, 'host already whitelisted in this session');
                  Severity: Major
                  Found in plugins/greylist.js - About 2 hrs to fix

                    Function get_certs_dir has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    exports.get_certs_dir = (tlsDir, done) => {
                    
                        this.config.getDir(tlsDir, {}, (iterErr, files) => {
                            if (iterErr) return done(iterErr);
                    
                    
                    Severity: Major
                    Found in tls_socket.js - About 2 hrs to fix

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

                                      try {
                                          re = new RegExp(element.substr(1, element.length-2),'i');
                                          new_skip_list.push(re);
                                      }
                                      catch (e) {
                      Severity: Major
                      Found in plugins/clamd.js and 1 other location - About 2 hrs to fix
                      plugins/clamd.js on lines 22..28

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

                      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

                                  else if (rcpt_to.dsn_code) {
                                      if (/^5/.exec(rcpt_to.dsn_code)) {
                                          dsn_action = 'failed';
                                      }
                                      else if (/^4/.exec(rcpt_to.dsn_code)) {
                      Severity: Major
                      Found in outbound/hmail.js and 1 other location - About 2 hrs to fix
                      outbound/hmail.js on lines 1171..1181

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

                      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

                                          try {
                                              re = new RegExp(element.substr(2, element.length-2),'i');
                                              new_skip_list_exclude.push(re);
                                          }
                                          catch (e) {
                      Severity: Major
                      Found in plugins/clamd.js and 1 other location - About 2 hrs to fix
                      plugins/clamd.js on lines 44..50

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

                      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

                                  else if (rcpt_to.dsn_smtp_code) {
                                      if (/^5/.exec(rcpt_to.dsn_smtp_code)) {
                                          dsn_action = 'failed';
                                      }
                                      else if (/^4/.exec(rcpt_to.dsn_smtp_code)) {
                      Severity: Major
                      Found in outbound/hmail.js and 1 other location - About 2 hrs to fix
                      outbound/hmail.js on lines 1160..1181

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

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

                      exports.hook_data_post = function (next, connection) {
                          const plugin = this;
                          const cfg = this.config.get('esets.ini');
                      
                          // Write message to temporary file
                      Severity: Minor
                      Found in plugins/esets.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 check_user has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                      exports.check_user = function (next, connection, credentials, method) {
                          const plugin = this;
                          connection.notes.authenticating = false;
                          if (!(credentials[0] && credentials[1])) {
                              connection.respond(504, 'Invalid AUTH string', () => {
                      Severity: Minor
                      Found in plugins/auth/auth_base.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

                      Severity
                      Category
                      Status
                      Source
                      Language