18F/domain-scan

View on GitHub

Showing 57 of 65 total issues

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 scan has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
    Open

    def scan(domain: str, environment: dict, options: dict) -> dict:
        logging.debug("Scan function called with options: %s" % options)
    
        results = {}
    
    
    Severity: Minor
    Found in scanners/pagedata.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 scan has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
    Open

    def scan(domain: str, environment: dict, options: dict) -> dict:
        logging.debug("Scan function called with options: %s" % options)
    
        # Run sitemap_scan to capture that data
        sitemap_results = sitemap_scan(domain, environment, options)
    Severity: Minor
    Found in scanners/seo.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

    File scan_utils.py has 534 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import argparse
    import codecs
    import csv
    import datetime
    import errno
    Severity: Major
    Found in utils/scan_utils.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

      File utils.py has 457 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import argparse
      import os
      import re
      import errno
      import subprocess
      Severity: Minor
      Found in utils/utils.py - About 7 hrs to fix

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

        def scan(domain: str, environment: dict, options: dict) -> dict:
            results = {}
            for i in headers:
                results[i] = 0
            results['uswdsversion'] = ""
        Severity: Minor
        Found in scanners/uswds2.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 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 processUrl has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

        var processUrl = (href, sourceHref, data) => {
          if (debug) console.log("URI: " + href);
        
          // Ignore blob: and data: URIs, these do not generate an external request.
          // Catch them before running URL.parse(), since they are not URLs and the
        Severity: Minor
        Found in scanners/third_parties.js - 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 init has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

        def init(environment, options):
            global redirects
            global config
            cache_dir = options.get("_", {}).get("cache_dir", "./cache")
        
        
        Severity: Minor
        Found in scanners/a11y.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_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 options_for_gather has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

        def options_for_gather():
            """
            Parse options for the ``gather`` command.
        
            :rtype: dict
        Severity: Minor
        Found in utils/utils.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 processUrl has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var processUrl = (href, sourceHref, data) => {
          if (debug) console.log("URI: " + href);
        
          // Ignore blob: and data: URIs, these do not generate an external request.
          // Catch them before running URL.parse(), since they are not URLs and the
        Severity: Major
        Found in scanners/third_parties.js - About 2 hrs to fix

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

          def _df_path(arg: Path, domain_suffix: Union[str, None]=None) -> Iterable[str]:
              if arg.suffix == ".csv":
                  with arg.open(encoding='utf-8', newline='') as csvfile:
                      for row in csv.reader(csvfile):
                          if (not row) or (not row[0]) or (row[0].lower() == "domain") or (row[0].lower() == "domain name"):
          Severity: Minor
          Found in utils/scan_utils.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 gather has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def gather(self):
          
                  # Returns a parsed, processed Google service credentials object.
                  credentials = load_credentials()
          
          
          Severity: Minor
          Found in gatherers/censys.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 scan has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

          def scan(domain, environment, options):
              # Save the old logging level
              old_log_level = logging.getLogger().getEffectiveLevel()
              log_level = logging.WARN
              if options.get('debug', False):
          Severity: Minor
          Found in scanners/trustymail.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 handler has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          exports.handler = (event, context, callback) => {
            var start_time = new Date().getTime() / 1000;
          
            // Tell Lambda to shut it down after the callback executes,
            // even if the container still has stuff (e.g. Chrome) running.
          Severity: Minor
          Found in lambda/headless/lambda_handler.js - About 1 hr to fix

            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 build_scan_options_parser has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            def build_scan_options_parser() -> ArgumentParser:
                """ Builds the argparse parser object. """
                parser = ArgumentParser(prefix_chars="--")
                parser.add_argument("domains", help="".join([
                    "Either a comma-separated list of domains or the url of a CSV ",
            Severity: Minor
            Found in utils/scan_utils.py - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language