18F/domain-scan

View on GitHub

Showing 57 of 65 total issues

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

def post_scan(domain: str, data: Any, environment: dict, options: dict):
    """Post-scan hook for trustymail

    Add mail server results to the fast cache, keyed by the
    concatenation of the mail server and port.  Do not update if an
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 scan has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def scan(domain: str, environment: dict, options: dict) -> dict:
    logging.debug("Scan function called with options: %s" % options)

    sitemap = None
    fqd = "https://%s" % domain  # note lack of trailing slash
Severity: Minor
Found in scanners/sitemap.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 scan has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  scan: async (domain, environment, options, browser, page) => {
    const url = environment.url;

    var data = {
      domain: domain,
Severity: Minor
Found in scanners/dap.js - About 1 hr to fix

    Function load_domains has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def load_domains(domain_csv, whole_rows=False):
        domains = []
        with open(domain_csv, newline='') as csvfile:
            for row in csv.reader(csvfile):
                # Skip empty rows.
    Severity: Minor
    Found in utils/utils.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 scan has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      scan: async (domain, environment, options, browser, page) => {
        const url = environment.url;
    
        var data = {
          url: url,
    Severity: Minor
    Found in scanners/third_parties.js - About 1 hr to fix

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

        def init_domain(domain, environment, options):
            cached_data = {}
        
            if not options['no_fast_cache']:
                #
        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 handle_scanner_args has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        def handle_scanner_args(args, opts) -> Tuple[dict, list]:
            """
            --analytics: file path or URL to a CSV of participating domains.
        
            This function also handles checking for the existence of the file,
        Severity: Minor
        Found in scanners/analytics.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 scan has a Cognitive Complexity of 10 (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 = {}
            url = 'https://' + domain + '/privacy'
        Severity: Minor
        Found in scanners/privacy.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 handle_domains_argument has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        def handle_domains_argument(domains: str, cache_dir: Path) -> Union[Path, str]:
            # `domains` can be either a path or a domain name.
            # It can also be a URL, and if it is we want to download it now,
            # and then adjust the value to be the path of the cached download.
            # Note that the cache_dir is basically guaranteed to exist by the time
        Severity: Minor
        Found in utils/scan_utils.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 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 write_rows has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def write_rows(rows, domain, base_domain, scanner, csv_writer, meta=None):
          Severity: Minor
          Found in runner/runner.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                        if event == 'string':
                                            counter = counter + 1
            
                                        # see if there is a 'conformsTo' field, which indicates that it might
                                        # be open-data compliant.
            Severity: Major
            Found in scanners/pagedata.py - About 45 mins to fix

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

              def init_domain(domain, environment, options):
                  cache_dir = options.get("_", {}).get("cache_dir", "./cache")
                  # If we have data from pshtt, skip if it's not a live domain.
                  if utils.domain_not_live(domain):
                      logging.debug("\tSkipping, domain not reachable during inspection.")
              Severity: Minor
              Found in scanners/third_parties.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 write_rows has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def write_rows(rows, domain, base_domain, scanner, csv_writer, meta={}):
              Severity: Minor
              Found in utils/scan_utils.py - About 45 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

                Avoid deeply nested control flow statements.
                Open

                                            if prefix.endswith('.conformsTo') or prefix.endswith('.conformsto'):
                                                results[page]['opendata_conforms_to'] = ' '.join([value, results[page]['opendata_conforms_to']])
                
                                            # see if there is a 'measurementType' field, which indicates that it might
                                            # be code.gov compliant.  Taken from https://code.gov/about/compliance/inventory-code
                Severity: Major
                Found in scanners/pagedata.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if domain_suffix.startswith("."):
                                          sep = ""
                                      yield "%s%s%s" % (domain, sep, domain_suffix)
                  Severity: Major
                  Found in utils/scan_utils.py - About 45 mins to fix

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

                    def init_domain(domain, environment, options):
                        cache_dir = options.get("_", {}).get("cache_dir", "./cache")
                        # If we have data from pshtt, skip if it's not a live domain.
                        if utils.domain_not_live(domain, cache_dir=cache_dir):
                            logging.debug("\tSkipping, domain not reachable during inspection.")
                    Severity: Minor
                    Found in scanners/csp.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

                    Severity
                    Category
                    Status
                    Source
                    Language