ValiMail/dane-discovery

View on GitHub

Showing 21 of 33 total issues

File dane.py has 464 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""DANE class definition."""
import binascii
import hashlib
import re
import requests
Severity: Minor
Found in dane_discovery/dane.py - About 7 hrs to fix

    File identity.py has 338 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """Identity abstraction."""
    import pprint
    
    from cryptography.hazmat.primitives import serialization
    
    
    Severity: Minor
    Found in dane_discovery/identity.py - About 4 hrs to fix

      Function get_all_certificates has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_all_certificates(self, filters=[]):
              """Return a dictionary of all EE certificates for this identity.
      
              This method uses available methods for validating certificates retrieved
              from TLSA records associated with the identity's DNS name. 
      Severity: Minor
      Found in dane_discovery/identity.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

      File pki.py has 295 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """PKI- and Certificate-oriented utilities here."""
      import binascii
      
      from cryptography import x509
      from cryptography.hazmat.primitives import serialization
      Severity: Minor
      Found in dane_discovery/pki.py - About 3 hrs to fix

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

            def validate_certificate(self, certificate):
                """Return True, None if the certificate is valid for the identity.
                
                This method returns two values, success and status.
        
        
        Severity: Minor
        Found in dane_discovery/identity.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 get_first_entity_certificate_by_type has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_first_entity_certificate_by_type(self, cert_type, strict=True):
                """Return the first certificate of ``cert_type`` for the identity.
                
                Supported certificate types:
                    PKIX-EE: Corresponds with ``certificate_usage`` ``1``.
        Severity: Minor
        Found in dane_discovery/identity.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 get_first_entity_certificate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_first_entity_certificate(self, strict=True):
                """Return the first entity certificate for the identity.
        
                Keyword args:
                    strict (bool): Raise TLSAError if certificate was not retrieved
        Severity: Minor
        Found in dane_discovery/identity.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 validate_certificate_chain has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def validate_certificate_chain(cls, entity_certificate, ca_certificates):
                """Return True if PKI trust chain is established from entity to CA.
                
                This method attempts cryptographic validation of ``entity_certificate`` 
                against the list of ``ca_certificates``. This method only checks 
        Severity: Minor
        Found in dane_discovery/pki.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 report has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def report(self):
                """Return a report for the identity.
        
                Prints the query context (DNSSEC, etc) as well as information about
                the TLSA records stored at the identity's name.
        Severity: Minor
        Found in dane_discovery/identity.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 get_ca_certificates_for_identity has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_ca_certificates_for_identity(cls, identity_name, certificate, max_levels=100, nsaddr=None, dns_timeout=5):
                """Return the CA certificates for verifying identity_name.
                
                Returns the PEM representation of the CA certificates
                used for verifying any DANE PKIX-CD certificate 
        Severity: Minor
        Found in dane_discovery/dane.py - About 55 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 authenticate_tlsa has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def authenticate_tlsa(cls, dns_name, record, nsaddr=None, dns_timeout=5):
                """Return None if the identity is authenticated, or raise ValueError.
        
                This method authenticates a TLSA record as follows:
        
        
        Severity: Minor
        Found in dane_discovery/dane.py - About 55 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 verify_certificate_signature has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def verify_certificate_signature(cls, certificate, ca_certificate):
                """Return True if certificate was signed by ca_certificate.
        
                Args:
                    entity_certificate (str): entity certificate in DER or PEM format.
        Severity: Minor
        Found in dane_discovery/pki.py - About 55 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 validate_tlsa_fields has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def validate_tlsa_fields(cls, tlsa_fields):
                """Validate the fields that come from DNS.
        
                Args:
                    tlsa_fields (dict): Must contain the following keys:
        Severity: Minor
        Found in dane_discovery/dane.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 get_ca_certificates_for_identity has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def get_ca_certificates_for_identity(cls, identity_name, certificate, max_levels=100, nsaddr=None, dns_timeout=5):
        Severity: Minor
        Found in dane_discovery/dane.py - About 35 mins to fix

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

              def get_tlsa_records(cls, dnsname, nsaddr=None, dns_timeout=5):
                  """TLSA records in a list of dictionaries.
          
                  This method retrieves and parses the TLSA records from
                  DNS for a given DNS name.
          Severity: Minor
          Found in dane_discovery/dane.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

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

          def main():
              """Wrap functionality provided by Identity.get_all_certificates()"""
              # Parse args
              args = parser.parse_args()
              # Get PKIX-CD certs from DNS
          Severity: Minor
          Found in dane_discovery/scripts/dane_discovery_get_ca_certificates.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 True, "Format and authority CA signature verified."
          Severity: Major
          Found in dane_discovery/identity.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return (False, msg)
            Severity: Major
            Found in dane_discovery/pki.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return {x509_ext.oid._name: x509_ext.value}
              Severity: Major
              Found in dane_discovery/pki.py - About 30 mins to fix

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

                    def validate_pkix_cd(self, cert_obj, credential):
                        """Validate a certificate with certificate_usage 4.
                        
                        PKIX-CD expects selector 0 and matching type 0. This
                        method will not validate configuration which differs 
                Severity: Minor
                Found in dane_discovery/identity.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

                Severity
                Category
                Status
                Source
                Language