haraka/haraka-plugin-dkim

View on GitHub

Showing 60 of 60 total issues

Function handle_buf has a Cognitive Complexity of 82 (exceeds 5 allowed). Consider refactoring.
Open

  handle_buf(buf) {
    const self = this
    // Abort any further processing if the headers
    // did not contain any DKIM-Signature fields.
    if (this._in_body && this._no_signatures_found) {
Severity: Minor
Found in lib/dkim.js - About 1 day 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 dkim.js has 635 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict'

const crypto = require('crypto')
const dns = require('dns')
const { Stream } = require('stream')
Severity: Major
Found in lib/dkim.js - About 1 day to fix

    Function constructor has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
    Open

      constructor(header, header_idx, cb, opts) {
        this.cb = cb
        this.sig = header
        this.sig_md5 = md5(header)
        this.run_cb = false
    Severity: Minor
    Found in lib/dkim.js - About 7 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 has 142 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      end() {
        if (this.run_cb) return
    
        const bh = this.bh.digest('base64')
        this.debug(`${this.identity}: bodyhash=${this.fields.bh} computed=${bh}`)
    Severity: Major
    Found in lib/dkim.js - About 5 hrs to fix

      Function handle_buf has 122 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        handle_buf(buf) {
          const self = this
          // Abort any further processing if the headers
          // did not contain any DKIM-Signature fields.
          if (this._in_body && this._no_signatures_found) {
      Severity: Major
      Found in lib/dkim.js - About 4 hrs to fix

        Function constructor has 119 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          constructor(header, header_idx, cb, opts) {
            this.cb = cb
            this.sig = header
            this.sig_md5 = md5(header)
            this.run_cb = false
        Severity: Major
        Found in lib/dkim.js - About 4 hrs to fix

          Function end has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

            end() {
              if (this.run_cb) return
          
              const bh = this.bh.digest('base64')
              this.debug(`${this.identity}: bodyhash=${this.fields.bh} computed=${bh}`)
          Severity: Minor
          Found in lib/dkim.js - About 3 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 index.js has 275 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          'use strict'
          
          const fs = require('fs')
          const path = require('path')
          
          
          Severity: Minor
          Found in index.js - About 2 hrs to fix

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

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

            exports.dkim_verify = function (next, connection) {
              if (!this.cfg.verify.enabled) return next()
            
              const txn = connection?.transaction
              if (!txn) return next()
            Severity: Minor
            Found in 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 get_sender_domain has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

            exports.get_sender_domain = function (connection) {
              const txn = connection?.transaction
              if (!txn) return
            
              // fallback: use Envelope FROM when header parsing fails
            Severity: Minor
            Found in 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 get_sign_properties has 54 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            exports.get_sign_properties = function (connection, done) {
              if (!connection.transaction) return
            
              const domain = this.get_sender_domain(connection)
            
            
            Severity: Major
            Found in index.js - About 2 hrs to fix

              Function get_sender_domain has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              exports.get_sender_domain = function (connection) {
                const txn = connection?.transaction
                if (!txn) return
              
                // fallback: use Envelope FROM when header parsing fails
              Severity: Minor
              Found in index.js - About 1 hr to fix

                Function dkim_verify has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                exports.dkim_verify = function (next, connection) {
                  if (!this.cfg.verify.enabled) return next()
                
                  const txn = connection?.transaction
                  if (!txn) return next()
                Severity: Minor
                Found in index.js - About 1 hr to fix

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

                    static canonicalize(bufin) {
                      const tmp = []
                      const len = bufin.length
                      let last_chunk_idx = 0
                      let idx_wsp = 0
                  Severity: Minor
                  Found in lib/dkim.js - About 1 hr to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

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

                    write(buf) {
                      /*
                       ** BODY (simple canonicalization)
                       */
                  
                  
                  Severity: Minor
                  Found in lib/dkim.js - About 1 hr to fix

                    Function end has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      end(buf) {
                        this.writable = false
                    
                        // Add trailing CRLF if we have data left over
                        if (this.buffer.ar.length) {
                    Severity: Minor
                    Found in lib/dkim.js - About 1 hr to fix

                      Function callback has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          function callback(err, result) {
                            self.pending--
                            if (result) {
                              const results = {
                                identity: result.identity,
                      Severity: Minor
                      Found in lib/dkim.js - About 1 hr to fix

                        Function verifier has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            (err, result, results) => {
                              if (err) {
                                txn.results.add(this, { err })
                                return next()
                              }
                        Severity: Minor
                        Found in index.js - About 1 hr to fix

                          Function canonicalize has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            static canonicalize(bufin) {
                              const tmp = []
                              const len = bufin.length
                              let last_chunk_idx = 0
                              let idx_wsp = 0
                          Severity: Minor
                          Found in lib/dkim.js - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language