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
File identity.py
has 338 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Identity abstraction."""
import pprint
from cryptography.hazmat.primitives import serialization
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.
- Read upRead up
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
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.
- Read upRead up
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``.
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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.
- Read upRead up
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
- Read upRead up
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:
- Read upRead up
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.
- Read upRead up
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:
- Read upRead up
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):
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.
- Read upRead up
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
- Read upRead up
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."
Avoid too many return
statements within this function. Open
return (False, msg)
Avoid too many return
statements within this function. Open
return {x509_ext.oid._name: x509_ext.value}
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
- Read upRead up
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"