18F/domain-scan

View on GitHub

Showing 65 of 65 total issues

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

      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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                if base_domain != domain and base_domain in environment.get("preload_list", []):
                    preload_list.append(base_domain)
            Severity: Minor
            Found in scanners/pshtt.py and 1 other location - About 55 mins to fix
            scanners/pshtt.py on lines 65..66

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 37.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                if base_domain != domain and base_domain in environment.get("preload_pending", []):
                    preload_pending.append(base_domain)
            Severity: Minor
            Found in scanners/pshtt.py and 1 other location - About 55 mins to fix
            scanners/pshtt.py on lines 58..59

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 37.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            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
              Severity
              Category
              Status
              Source
              Language