18F/domain-scan

View on GitHub
scanners/sslyze.py

Summary

Maintainability
F
4 days
Test Coverage

File sslyze.py has 706 lines of code (exceeds 250 allowed). Consider refactoring.
Open

###
# Inspect a site's TLS configuration using sslyze.
#
# If data exists for a domain from `pshtt`, will check results
# and only process domains with valid HTTPS, or broken chains.
Severity: Major
Found in scanners/sslyze.py - About 1 day to fix

    Function analyze_certs has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
    Open

    def analyze_certs(certs):
        data = {'certs': {}}
    
        # Served chain.
        served_chain = certs.received_certificate_chain
    Severity: Minor
    Found in scanners/sslyze.py - About 1 day to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function analyze_protocols_and_ciphers has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

    def analyze_protocols_and_ciphers(data, sslv2, sslv3, tlsv1, tlsv1_1, tlsv1_2, tlsv1_3):
        data['protocols'] = {
            'sslv2': supported_protocol(sslv2),
            'sslv3': supported_protocol(sslv3),
            'tlsv1.0': supported_protocol(tlsv1),
    Severity: Minor
    Found in scanners/sslyze.py - About 5 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function scan_parallel has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def scan_parallel(scanner, server_info, data, options):
        logging.debug("\tRunning scans in parallel.")
    
        def queue(command):
            try:
    Severity: Minor
    Found in scanners/sslyze.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 scan_serial has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def scan_serial(scanner, server_info, data, options):
        errors = 0
    
        def run_scan(scan_type, command, errors):
            if(errors >= 2):
    Severity: Minor
    Found in scanners/sslyze.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 post_scan has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def post_scan(domain: str, data: Any, environment: dict, options: dict):
        """Post-scan hook for sslyze
    
        Add SMTP results to the fast cache, keyed by the concatenation of
        the mail server and port.  Do not update if an appropriate cache
    Severity: Minor
    Found in scanners/sslyze.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 init_domain has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def init_domain(domain, environment, options):
        hosts_to_scan = []
        cached_data = []
        cache_dir = options.get('_', {}).get('cache_dir', './cache')
    
    
    Severity: Minor
    Found in scanners/sslyze.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 analyze_certs has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def analyze_certs(certs):
        data = {'certs': {}}
    
        # Served chain.
        served_chain = certs.received_certificate_chain
    Severity: Minor
    Found in scanners/sslyze.py - About 1 hr to fix

      Function analyze_protocols_and_ciphers has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def analyze_protocols_and_ciphers(data, sslv2, sslv3, tlsv1, tlsv1_1, tlsv1_2, tlsv1_3):
      Severity: Major
      Found in scanners/sslyze.py - About 50 mins to fix

        Function run_sslyze has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def run_sslyze(data, environment, options):
            # Each sslyze worker can use a sync or parallel mode.
            #
            # SynchronousScanner can show memory leaks when parsing certs,
            # so local scanning defaults to using ConcurrentScanner.
        Severity: Minor
        Found in scanners/sslyze.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

        Consider simplifying this complex logical expression.
        Open

            if sslv2 and sslv3 and tlsv1 and tlsv1_1 and tlsv1_2 and tlsv1_3:
                analyze_protocols_and_ciphers(data, sslv2, sslv3, tlsv1, tlsv1_1, tlsv1_2, tlsv1_3)
        
        
        Severity: Major
        Found in scanners/sslyze.py - About 40 mins to fix

          Function init_sslyze has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def init_sslyze(hostname, port, starttls_smtp, options, sync=False):
          Severity: Minor
          Found in scanners/sslyze.py - About 35 mins to fix

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

            def init_sslyze(hostname, port, starttls_smtp, options, sync=False):
                global network_timeout, CA_FILE
            
                network_timeout = int(options.get("network_timeout", network_timeout))
                if options.get('ca_file'):
            Severity: Minor
            Found in scanners/sslyze.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

            There are no issues that match your filters.

            Category
            Status