saltstack/salt

View on GitHub
salt/modules/tls.py

Summary

Maintainability
F
2 wks
Test Coverage

File tls.py has 1617 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
r'''
A salt module for SSL/TLS.
Can create a Certificate Authority (CA)
or use Self-Signed certificates.
Severity: Major
Found in salt/modules/tls.py - About 4 days to fix

    Function cert_info has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

    def cert_info(cert, digest='sha256'):
        '''
        Return information for a particular certificate
    
        cert
    Severity: Minor
    Found in salt/modules/tls.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 create_csr has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def create_csr(ca_name,
                   bits=2048,
                   CN='localhost',
                   C='US',
                   ST='Utah',
    Severity: Minor
    Found in salt/modules/tls.py - 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

    Function _check_onlyif_unless has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def _check_onlyif_unless(onlyif, unless):
        ret = None
        retcode = __salt__['cmd.retcode']
        if onlyif is not None:
            if not isinstance(onlyif, six.string_types):
    Severity: Minor
    Found in salt/modules/tls.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

    Function create_ca has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def create_ca(ca_name,
                  bits=2048,
                  days=365,
                  CN='localhost',
                  C='US',
    Severity: Minor
    Found in salt/modules/tls.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

    Function revoke_cert has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def revoke_cert(
            ca_name,
            CN,
            cacert_path=None,
            ca_filename=None,
    Severity: Minor
    Found in salt/modules/tls.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

    Cyclomatic complexity is too high in function create_ca. (23)
    Open

    def create_ca(ca_name,
                  bits=2048,
                  days=365,
                  CN='localhost',
                  C='US',
    Severity: Minor
    Found in salt/modules/tls.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 create_ca_signed_cert has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def create_ca_signed_cert(ca_name,
                              CN,
                              days=365,
                              cacert_path=None,
                              ca_filename=None,
    Severity: Minor
    Found in salt/modules/tls.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

    Function create_ca has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def create_ca(ca_name,
                  bits=2048,
                  days=365,
                  CN='localhost',
                  C='US',
    Severity: Minor
    Found in salt/modules/tls.py - About 1 hr to fix

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

      def get_extensions(cert_type):
          '''
          Fetch X509 and CSR extension definitions from tls:extensions:
          (common|server|client) or set them to standard defaults.
      
      
      Severity: Minor
      Found in salt/modules/tls.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 create_csr has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def create_csr(ca_name,
                     bits=2048,
                     CN='localhost',
                     C='US',
                     ST='Utah',
      Severity: Minor
      Found in salt/modules/tls.py - About 1 hr to fix

        Function create_self_signed_cert has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def create_self_signed_cert(tls_dir='tls',
                                    bits=2048,
                                    days=365,
                                    CN='localhost',
                                    C='US',
        Severity: Minor
        Found in salt/modules/tls.py - About 1 hr to fix

          Function create_ca_signed_cert has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          def create_ca_signed_cert(ca_name,
                                    CN,
                                    days=365,
                                    cacert_path=None,
                                    ca_filename=None,
          Severity: Minor
          Found in salt/modules/tls.py - About 1 hr to fix

            Function _read_cert has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            def _read_cert(cert):
                if isinstance(cert, six.string_types):
                    try:
                        with salt.utils.files.fopen(cert) as rfh:
                            return OpenSSL.crypto.load_certificate(
            Severity: Minor
            Found in salt/modules/tls.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 ret
            Severity: Major
            Found in salt/modules/tls.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return 'Created Certificate for "{0}": "{1}/{2}.crt"'.format(
              Severity: Major
              Found in salt/modules/tls.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return ('Revoked Certificate: "{0}/{1}.crt", '
                Severity: Major
                Found in salt/modules/tls.py - About 30 mins to fix

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

                  def __virtual__():
                      '''
                      Only load this module if the ca config options are set
                      '''
                      global X509_EXT_ENABLED
                  Severity: Minor
                  Found in salt/modules/tls.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 maybe_fix_ssl_version has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def maybe_fix_ssl_version(ca_name, cacert_path=None, ca_filename=None):
                      '''
                      Check that the X509 version is correct
                      (was incorrectly set in previous salt versions).
                      This will fix the version if needed.
                  Severity: Minor
                  Found in salt/modules/tls.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

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

                  def get_ca_signed_key(ca_name,
                                        CN='localhost',
                                        as_text=False,
                                        cacert_path=None,
                                        key_filename=None):
                  Severity: Major
                  Found in salt/modules/tls.py and 1 other location - About 7 hrs to fix
                  salt/modules/tls.py on lines 453..495

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

                  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 get_ca_signed_cert(ca_name,
                                         CN='localhost',
                                         as_text=False,
                                         cacert_path=None,
                                         cert_filename=None):
                  Severity: Major
                  Found in salt/modules/tls.py and 1 other location - About 7 hrs to fix
                  salt/modules/tls.py on lines 498..544

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

                  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

                      try:
                          with salt.utils.files.fopen('{0}/{1}/{2}.crt'.format(
                                  cert_base_path(),
                                  ca_name,
                                  ca_filename)) as fp_:
                  Severity: Major
                  Found in salt/modules/tls.py and 2 other locations - About 6 hrs to fix
                  salt/modules/tls.py on lines 1635..1651
                  salt/modules/tls.py on lines 1921..1939

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

                  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

                      try:
                          with salt.utils.files.fopen('{0}/{1}/{2}.crt'.format(
                                  cert_base_path(),
                                  ca_name,
                                  ca_filename)) as fp_:
                  Severity: Major
                  Found in salt/modules/tls.py and 2 other locations - About 6 hrs to fix
                  salt/modules/tls.py on lines 1635..1651
                  salt/modules/tls.py on lines 1824..1842

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

                  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

                      try:
                          with salt.utils.files.fopen('{0}/{1}/certs/{2}.crt'.format(cert_base_path(),
                                                                               ca_name,
                                                                               CN)) as fhr:
                              cert = OpenSSL.crypto.load_certificate(
                  Severity: Major
                  Found in salt/modules/tls.py and 2 other locations - About 6 hrs to fix
                  salt/modules/tls.py on lines 1824..1842
                  salt/modules/tls.py on lines 1921..1939

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

                  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

                      for key, value in cert.get_subject().get_components():
                          if isinstance(key, bytes):
                              key = salt.utils.stringutils.to_unicode(key)
                          if isinstance(value, bytes):
                              value = salt.utils.stringutils.to_unicode(value)
                  Severity: Major
                  Found in salt/modules/tls.py and 1 other location - About 3 hrs to fix
                  salt/modules/tls.py on lines 1706..1711

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

                  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

                      for key, value in cert.get_issuer().get_components():
                          if isinstance(key, bytes):
                              key = salt.utils.stringutils.to_unicode(key)
                          if isinstance(value, bytes):
                              value = salt.utils.stringutils.to_unicode(value)
                  Severity: Major
                  Found in salt/modules/tls.py and 1 other location - About 3 hrs to fix
                  salt/modules/tls.py on lines 1714..1719

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

                  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 not ext['client'] or ext['client'] == '':
                          ext['client'] = {
                              'csr': {
                                  'extendedKeyUsage': 'clientAuth',
                                  'keyUsage': 'nonRepudiation, digitalSignature, keyEncipherment',
                  Severity: Major
                  Found in salt/modules/tls.py and 1 other location - About 1 hr to fix
                  salt/modules/tls.py on lines 922..928

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

                  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 not ext['server'] or ext['server'] == '':
                          ext['server'] = {
                              'csr': {
                                  'extendedKeyUsage': 'serverAuth',
                                  'keyUsage': 'digitalSignature, keyEncipherment',
                  Severity: Major
                  Found in salt/modules/tls.py and 1 other location - About 1 hr to fix
                  salt/modules/tls.py on lines 936..942

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

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

                      with salt.utils.files.fopen(cert_full_path, 'wb+') as crt:
                          crt.write(
                              salt.utils.stringutils.to_bytes(
                                  OpenSSL.crypto.dump_certificate(OpenSSL.crypto.FILETYPE_PEM,
                                                                  cert)
                  Severity: Major
                  Found in salt/modules/tls.py and 4 other locations - About 1 hr to fix
                  salt/modules/tls.py on lines 853..858
                  salt/modules/tls.py on lines 1173..1178
                  salt/modules/tls.py on lines 1314..1318
                  salt/modules/tls.py on lines 1325..1330

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

                      with salt.utils.files.fopen(csr_f, 'wb+') as csr:
                          csr.write(
                              salt.utils.stringutils.to_bytes(
                                  OpenSSL.crypto.dump_certificate_request(
                                      OpenSSL.crypto.FILETYPE_PEM,
                  Severity: Major
                  Found in salt/modules/tls.py and 4 other locations - About 1 hr to fix
                  salt/modules/tls.py on lines 853..858
                  salt/modules/tls.py on lines 1314..1318
                  salt/modules/tls.py on lines 1325..1330
                  salt/modules/tls.py on lines 1565..1569

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

                      with salt.utils.files.fopen(priv_key_path, 'wb+') as priv_key:
                          priv_key.write(
                              salt.utils.stringutils.to_bytes(
                                  OpenSSL.crypto.dump_privatekey(OpenSSL.crypto.FILETYPE_PEM,
                                                                 key)
                  Severity: Major
                  Found in salt/modules/tls.py and 4 other locations - About 1 hr to fix
                  salt/modules/tls.py on lines 853..858
                  salt/modules/tls.py on lines 1173..1178
                  salt/modules/tls.py on lines 1325..1330
                  salt/modules/tls.py on lines 1565..1569

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

                      with salt.utils.files.fopen(crt_path, 'wb+') as crt:
                          crt.write(
                              salt.utils.stringutils.to_bytes(
                                  OpenSSL.crypto.dump_certificate(
                                      OpenSSL.crypto.FILETYPE_PEM,
                  Severity: Major
                  Found in salt/modules/tls.py and 4 other locations - About 1 hr to fix
                  salt/modules/tls.py on lines 853..858
                  salt/modules/tls.py on lines 1173..1178
                  salt/modules/tls.py on lines 1314..1318
                  salt/modules/tls.py on lines 1565..1569

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

                      with salt.utils.files.fopen(certp, 'wb') as ca_crt:
                          ca_crt.write(
                              salt.utils.stringutils.to_bytes(
                                  OpenSSL.crypto.dump_certificate(
                                      OpenSSL.crypto.FILETYPE_PEM,
                  Severity: Major
                  Found in salt/modules/tls.py and 4 other locations - About 1 hr to fix
                  salt/modules/tls.py on lines 1173..1178
                  salt/modules/tls.py on lines 1314..1318
                  salt/modules/tls.py on lines 1325..1330
                  salt/modules/tls.py on lines 1565..1569

                  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

                      if not os.path.exists('{0}/{1}/certs/'.format(cert_base_path(), tls_dir)):
                          os.makedirs("{0}/{1}/certs/".format(cert_base_path(),
                                                              tls_dir))
                  Severity: Minor
                  Found in salt/modules/tls.py and 1 other location - About 45 mins to fix
                  salt/modules/tls.py on lines 771..775

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

                  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 not os.path.exists('{0}/{1}'.format(
                          cert_base_path(), ca_name)
                      ):
                          os.makedirs('{0}/{1}'.format(cert_base_path(),
                                                       ca_name))
                  Severity: Minor
                  Found in salt/modules/tls.py and 1 other location - About 45 mins to fix
                  salt/modules/tls.py on lines 1272..1274

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

                  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

                      try:
                          ext['common'] = __salt__['pillar.get']('tls.extensions:common', False)
                      except NameError as err:
                          log.debug(err)
                  Severity: Minor
                  Found in salt/modules/tls.py and 2 other locations - About 30 mins to fix
                  salt/modules/tls.py on lines 917..920
                  salt/modules/tls.py on lines 931..934

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

                  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

                      try:
                          ext['server'] = __salt__['pillar.get']('tls.extensions:server', False)
                      except NameError as err:
                          log.debug(err)
                  Severity: Minor
                  Found in salt/modules/tls.py and 2 other locations - About 30 mins to fix
                  salt/modules/tls.py on lines 901..904
                  salt/modules/tls.py on lines 931..934

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

                  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

                      try:
                          ext['client'] = __salt__['pillar.get']('tls.extensions:client', False)
                      except NameError as err:
                          log.debug(err)
                  Severity: Minor
                  Found in salt/modules/tls.py and 2 other locations - About 30 mins to fix
                  salt/modules/tls.py on lines 901..904
                  salt/modules/tls.py on lines 917..920

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

                  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 not replace and os.path.exists(
                              '{0}/{1}/certs/{2}.p12'.format(
                                  cert_base_path(),
                                  ca_name,
                                  CN)
                  Severity: Minor
                  Found in salt/modules/tls.py and 1 other location - About 30 mins to fix
                  salt/modules/tls.py on lines 1279..1283

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

                  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 not replace and os.path.exists(
                              '{0}/{1}/certs/{2}.crt'.format(cert_base_path(),
                                                             tls_dir, cert_filename)
                      ):
                          return 'Certificate "{0}" already exists'.format(cert_filename)
                  Severity: Minor
                  Found in salt/modules/tls.py and 1 other location - About 30 mins to fix
                  salt/modules/tls.py on lines 1617..1623

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

                  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 write_key:
                          with salt.utils.files.fopen(ca_keyp, 'wb') as ca_key:
                              ca_key.write(salt.utils.stringutils.to_bytes(keycontent))
                  Severity: Minor
                  Found in salt/modules/tls.py and 1 other location - About 30 mins to fix
                  salt/modules/zcbuildout.py on lines 545..548

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

                  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