saltstack/salt

View on GitHub
salt/crypt.py

Summary

Maintainability
F
1 wk
Test Coverage

File crypt.py has 1259 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
The crypt module manages all of the cryptography functions for minions and
masters, encrypting and decrypting payloads, preparing messages, and
authenticating peers
Severity: Major
Found in salt/crypt.py - About 3 days to fix

    Function verify_master has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

        def verify_master(self, payload, master_pub=True):
            '''
            Verify that the master is the same one that was previously accepted.
    
            :param dict payload: The incoming payload. This is a dictionary which may have the following keys:
    Severity: Minor
    Found in salt/crypt.py - About 6 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 sign_in has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

        def sign_in(self, timeout=60, safe=True, tries=1, channel=None):
            '''
            Send a sign in request to the master, sets the key information and
            returns a dict containing the master publish interface to bind to
            and the decrypted aes key for transport decryption.
    Severity: Minor
    Found in salt/crypt.py - About 5 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 _authenticate has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        def _authenticate(self):
            '''
            Authenticate with the master, this method breaks the functional
            paradigm, it will update the master information from a fresh sign
            in, signing in can occur as often as needed to keep up with the
    Severity: Minor
    Found in salt/crypt.py - About 5 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 sign_in has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        def sign_in(self, timeout=60, safe=True, tries=1, channel=None):
            '''
            Send a sign in request to the master, sets the key information and
            returns a dict containing the master publish interface to bind to
            and the decrypted aes key for transport decryption.
    Severity: Minor
    Found in salt/crypt.py - About 5 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 decrypt_aes has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        def decrypt_aes(self, payload, master_pub=True):
            '''
            This function is used to decrypt the AES seed phrase returned from
            the master server. The seed phrase is decrypted with the SSH RSA
            host key.
    Severity: Minor
    Found in salt/crypt.py - About 4 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 authenticate has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def authenticate(self, _=None):  # TODO: remove unused var
            '''
            Authenticate with the master, this method breaks the functional
            paradigm, it will update the master information from a fresh sign
            in, signing in can occur as often as needed to keep up with the
    Severity: Minor
    Found in salt/crypt.py - 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

    AsyncAuth has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class AsyncAuth(object):
        '''
        Set up an Async object to maintain authentication with the salt master
        '''
        # This class is only a singleton per minion/master pair
    Severity: Minor
    Found in salt/crypt.py - About 2 hrs to fix

      Cyclomatic complexity is too high in method sign_in. (21)
      Wontfix

          @tornado.gen.coroutine
          def sign_in(self, timeout=60, safe=True, tries=1, channel=None):
              '''
              Send a sign in request to the master, sets the key information and
              returns a dict containing the master publish interface to bind to
      Severity: Minor
      Found in salt/crypt.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Function gen_keys has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      def gen_keys(keydir, keyname, keysize, user=None, passphrase=None):
          '''
          Generate a RSA public keypair for use with salt
      
          :param str keydir: The directory to write the keypair to
      Severity: Minor
      Found in salt/crypt.py - 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 decrypt has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def decrypt(self, data):
              '''
              verify HMAC-SHA256 signature and decrypt data with AES-CBC
              '''
              aes_key, hmac_key = self.keys
      Severity: Minor
      Found in salt/crypt.py - 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 verify_pubkey_sig has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def verify_pubkey_sig(self, message, sig):
              '''
              Wraps the verify_signature method so we have
              additional checks.
      
      
      Severity: Minor
      Found in salt/crypt.py - About 45 mins 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 __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(self, opts):
              super(MasterKeys, self).__init__()
              self.opts = opts
              self.pub_path = os.path.join(self.opts['pki_dir'], 'master.pub')
              self.rsa_path = os.path.join(self.opts['pki_dir'], 'master.pem')
      Severity: Minor
      Found in salt/crypt.py - About 45 mins 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 __singleton_init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def __singleton_init__(self, opts, io_loop=None):
              '''
              Init an Auth instance
      
              :param dict opts: Options for this server
      Severity: Minor
      Found in salt/crypt.py - About 35 mins 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

      Avoid too many return statements within this function.
      Open

                      return self.extract_aes(payload, master_pub=False)
      Severity: Major
      Found in salt/crypt.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                        return key_str, ''
        Severity: Major
        Found in salt/crypt.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                              return ''
          Severity: Major
          Found in salt/crypt.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                            return ''
            Severity: Major
            Found in salt/crypt.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                                  return self.extract_aes(payload, master_pub=False)
              Severity: Major
              Found in salt/crypt.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                        return self.extract_aes(payload)
                Severity: Major
                Found in salt/crypt.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                  return key_str, token
                  Severity: Major
                  Found in salt/crypt.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return '', ''
                    Severity: Major
                    Found in salt/crypt.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                              return ''
                      Severity: Major
                      Found in salt/crypt.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                            return self.extract_aes(payload)
                        Severity: Major
                        Found in salt/crypt.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return auth
                          Severity: Major
                          Found in salt/crypt.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                                return ''
                            Severity: Major
                            Found in salt/crypt.py - About 30 mins to fix

                              Function minion_sign_in_payload has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def minion_sign_in_payload(self):
                                      '''
                                      Generates the payload used to authenticate with the master
                                      server. This payload consists of the passed in id_ and the ssh
                                      public key to encrypt the AES key sent back from the master.
                              Severity: Minor
                              Found in salt/crypt.py - About 25 mins 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 extract_aes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def extract_aes(self, payload, master_pub=True):
                                      '''
                                      Return the AES key received from the master after the minion has been
                                      successfully authenticated.
                              
                              
                              Severity: Minor
                              Found in salt/crypt.py - About 25 mins 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 __singleton_init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def __singleton_init__(self, opts, io_loop=None):
                                      '''
                                      Init an Auth instance
                              
                                      :param dict opts: Options for this server
                              Severity: Minor
                              Found in salt/crypt.py - About 25 mins 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 self.opts.get('syndic_master', False):  # Is syndic
                                          syndic_finger = self.opts.get('syndic_finger', self.opts.get('master_finger', False))
                                          if syndic_finger:
                                              if salt.utils.crypt.pem_finger(m_pub_fn, sum_type=self.opts['hash_type']) != syndic_finger:
                                                  self._finger_fail(syndic_finger, m_pub_fn)
                              Severity: Major
                              Found in salt/crypt.py and 1 other location - About 1 day to fix
                              salt/crypt.py on lines 1354..1362

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

                              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 self.opts.get('syndic_master', False):  # Is syndic
                                          syndic_finger = self.opts.get('syndic_finger', self.opts.get('master_finger', False))
                                          if syndic_finger:
                                              if salt.utils.crypt.pem_finger(m_pub_fn, sum_type=self.opts['hash_type']) != syndic_finger:
                                                  self._finger_fail(syndic_finger, m_pub_fn)
                              Severity: Major
                              Found in salt/crypt.py and 1 other location - About 1 day to fix
                              salt/crypt.py on lines 769..777

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

                              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 public_decrypt(pub, message):
                                  '''
                                  Verify an M2Crypto-compatible signature
                              
                                  :param Crypto.PublicKey.RSA._RSAobj key: The RSA public key object
                              Severity: Major
                              Found in salt/crypt.py and 1 other location - About 2 hrs to fix
                              salt/crypt.py on lines 284..297

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

                              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 private_encrypt(key, message):
                                  '''
                                  Generate an M2Crypto-compatible signature
                              
                                  :param Crypto.PublicKey.RSA._RSAobj key: The RSA key object
                              Severity: Major
                              Found in salt/crypt.py and 1 other location - About 2 hrs to fix
                              salt/crypt.py on lines 300..314

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

                              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 self.opts.get('caller'):
                                                      # We have a list of masters, so we should break
                                                      # and try the next one in the list.
                                                      if self.opts.get('local_masters', None):
                                                          error = SaltClientError('Minion failed to authenticate'
                              Severity: Major
                              Found in salt/crypt.py and 1 other location - About 2 hrs to fix
                              salt/crypt.py on lines 1230..1241

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

                              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 self.opts.get('caller'):
                                                      # We have a list of masters, so we should break
                                                      # and try the next one in the list.
                                                      if self.opts.get('local_masters', None):
                                                          error = SaltClientError('Minion failed to authenticate'
                              Severity: Major
                              Found in salt/crypt.py and 1 other location - About 2 hrs to fix
                              salt/crypt.py on lines 613..624

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

                              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 4 locations. Consider refactoring.
                              Open

                                      if callback is not None:
                                          def handle_future(future):
                                              response = future.result()
                                              self.io_loop.add_callback(callback, response)
                                          future.add_done_callback(handle_future)
                              Severity: Major
                              Found in salt/crypt.py and 3 other locations - About 1 hr to fix
                              salt/transport/ipc.py on lines 287..291
                              salt/transport/tcp.py on lines 1176..1180
                              salt/transport/zeromq.py on lines 1273..1277

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

                              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

                                      if HAS_M2:
                                          key_str = key.private_decrypt(payload['aes'],
                                                                        RSA.pkcs1_oaep_padding)
                                      else:
                                          cipher = PKCS1_OAEP.new(key)
                              Severity: Major
                              Found in salt/crypt.py and 2 other locations - About 1 hr to fix
                              salt/transport/tcp.py on lines 350..354
                              salt/transport/zeromq.py on lines 302..307

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

                              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

                                  if HAS_M2:
                                      gen.save_pub_key(pub)
                                  else:
                                      with salt.utils.files.fopen(pub, 'wb+') as f:
                                          f.write(gen.publickey().exportKey('PEM'))
                              Severity: Major
                              Found in salt/crypt.py and 1 other location - About 1 hr to fix
                              salt/crypt.py on lines 418..422

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

                              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

                                          if HAS_M2:
                                              key.save_pub_key(path)
                                          else:
                                              with salt.utils.files.fopen(path, 'wb+') as wfh:
                                                  wfh.write(key.publickey().exportKey('PEM'))
                              Severity: Major
                              Found in salt/crypt.py and 1 other location - About 1 hr to fix
                              salt/crypt.py on lines 152..156

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

                              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 6 locations. Consider refactoring.
                              Open

                                              if not m_pub_exists:
                                                  # the minion has not received any masters pubkey yet, write
                                                  # the newly received pubkey to minion_master.pub
                                                  with salt.utils.files.fopen(m_pub_fn, 'wb+') as fp_:
                                                      fp_.write(salt.utils.stringutils.to_bytes(payload['pub_key']))
                              Severity: Major
                              Found in salt/crypt.py and 5 other locations - About 40 mins to fix
                              salt/daemons/masterapi.py on lines 982..983
                              salt/fileserver/azurefs.py on lines 293..294
                              salt/runners/digicertapi.py on lines 583..584
                              salt/runners/venafiapi.py on lines 209..210
                              salt/wheel/key.py on lines 419..420

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

                              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

                              There are no issues that match your filters.

                              Category
                              Status