failmap/admin

View on GitHub

Showing 577 of 577 total issues

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

class AllExplainedIssuesCombined(models.Model):
    """
    The same as all above statistics classes, but with the major difference that this does not contain
    not_testable, not_applicable and error in test. Each EndpointGenericScan and UrlGEnericScan can be explained.
    Instead of counting towards the normal set of issues, separate statistics are created over this.
Severity: Major
Found in websecmap/reporting/models.py and 3 other locations - About 4 hrs to fix
websecmap/reporting/models.py on lines 155..178
websecmap/reporting/models.py on lines 194..208
websecmap/reporting/models.py on lines 211..228

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 80.

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

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

class ExplainedJudgedEndpoints(models.Model):
    """
    See ExplainedJudgedUrls
    """

Severity: Major
Found in websecmap/reporting/models.py and 3 other locations - About 4 hrs to fix
websecmap/reporting/models.py on lines 130..152
websecmap/reporting/models.py on lines 155..178
websecmap/reporting/models.py on lines 194..208

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 80.

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

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

class ExplainedJudgedUrls(models.Model):
    """
    I can't imagine this being used. It's the amount of urls that are judged to have one or more explanation.
    It's already hard to understand. It's of course easy to make in statistics, but why?
    """
Severity: Major
Found in websecmap/reporting/models.py and 3 other locations - About 4 hrs to fix
websecmap/reporting/models.py on lines 130..152
websecmap/reporting/models.py on lines 155..178
websecmap/reporting/models.py on lines 211..228

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 80.

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

Cyclomatic complexity is too high in function test_internet_nl_store_testresults. (21)
Open

def test_internet_nl_store_testresults(db):
    test_results = {
        "secure.aalten.nl": {
            "status": "ok",
            "report": {"url": "https://dev.batch.internet.nl/site/secure.aalten.nl/665357/"},

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Source: http://radon.readthedocs.org/en/latest/intro.html

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

Severity: Major
Found in websecmap/map/management/commands/reports_rebuild.py and 2 other locations - About 4 hrs to fix
websecmap/reporting/management/commands/rebuild_url_reports.py on lines 0..21
websecmap/reporting/management/commands/report.py on lines 0..20

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 77.

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

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

websecmap/map/management/commands/reports_rebuild.py on lines 0..21
websecmap/reporting/management/commands/report.py on lines 0..20

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 77.

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

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

Severity: Major
Found in websecmap/reporting/management/commands/report.py and 2 other locations - About 4 hrs to fix
websecmap/map/management/commands/reports_rebuild.py on lines 0..21
websecmap/reporting/management/commands/rebuild_url_reports.py on lines 0..21

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 77.

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

def calculate_impact():
    """
    Based on scans: the first and the last measurement, calculates numbers on how much has changed. It takes
    into account how much endpoints / urls are deleted. This script is slow, but also simple. This simplicty
    makes it easy to understand and maintain.
Severity: Minor
Found in websecmap/scanners/impact.py - About 4 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 remove_wildcards_using_statistics has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

def remove_wildcards_using_statistics(found_hosts, url: str):
    # todo: test
    # some hosts rotate a set of IP's when providing wildcards. This is an annoying practice.
    # We can filter those out with some statistics. We cut off everything that resolve to the top IP's.
    ip_stats = {}
Severity: Minor
Found in websecmap/scanners/scanner/subdomains.py - About 4 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

File ftp.py has 335 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Scans for missing AUTH TLS / AUTH SSL options in FTP servers.

# Docs:
# https://docs.python.org/3/library/ftplib.html#ftplib.FTP_TLS.ssl_version
Severity: Minor
Found in websecmap/scanners/scanner/ftp.py - About 4 hrs to fix

    Function worker_verify_role_capabilities has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

    def worker_verify_role_capabilities(role):
        """Determine if chosen role can be performed on this host (eg: ipv6 connectivity.)"""
    
        failed = False
    
    
    Severity: Minor
    Found in websecmap/celery/worker.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 import_from_scratch has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

    def import_from_scratch(countries: List[str] = None, organization_types: List[str] = None, when=None):
        """
        Run this when you have nothing on the organization type in that country. It will help bootstrapping a
        certain region.
    
    
    Severity: Minor
    Found in websecmap/map/logic/openstreetmap.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

    File dns_endpoints.py has 329 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """
    This discovers endpoints that are used for the Internet.NL scanners. The internet.nl scanners require only the
    existence of AAAA or A DNS records for web and SOA for mail. This means this discovery will find DNS-record type
    endpoints that equal normal endpoints. Except they don't have a port and ip_version.
    
    
    Severity: Minor
    Found in websecmap/scanners/scanner/dns_endpoints.py - About 3 hrs to fix

      Cyclomatic complexity is too high in function calculate_vulnerability_statistics. (18)
      Open

      @app.task(queue="reporting")
      def calculate_vulnerability_statistics(days: int = 366, countries: List = None, organization_types: List = None):
          log.info("Calculation vulnerability graphs")
      
          map_configurations = filter_map_configs(countries=countries, organization_types=organization_types)
      Severity: Minor
      Found in websecmap/map/report.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in function analyze_result. (18)
      Open

      def analyze_result(result: List[str]):
          """
          All possible outcomes:
          https://github.com/dotse/dnscheck/blob/5b0fce771259d9dfc03c6c69abba44f2be142c30/engine/t/config/policy.yaml
      
      
      Severity: Minor
      Found in websecmap/scanners/scanner/dnssec.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in function get_endpoints_with_missing_encryption. (18)
      Open

      @app.task(queue="storage")
      def get_endpoints_with_missing_encryption(url):
          """
          Finds a list of endpoints that are missing an encrypted counterpart. Takes in account ip_version.
      
      

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      File security_headers.py has 319 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """
      Check if the https site uses HSTS to tell the browser the site should only be reached over HTTPS.
      (useful until browsers do https by default, instead of by choice)
      """
      import logging
      Severity: Minor
      Found in websecmap/scanners/scanner/security_headers.py - About 3 hrs to fix

        Function qualys_scan_thread has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

        def qualys_scan_thread(proxy: Dict[str, Any], url: str):
        
            normal_waiting_time = 30
            error_waiting_time = 60  # seconds until retry, can be increased when queues are full. Max = 180
            max_waiting_time = 360
        Severity: Minor
        Found in websecmap/scanners/scanner/tls_qualys.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

        File plannedscan.py has 315 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import logging
        from datetime import datetime, timedelta
        from typing import Dict, List, Tuple
        
        import dateutil.parser
        Severity: Minor
        Found in websecmap/scanners/plannedscan.py - About 3 hrs to fix

          Cyclomatic complexity is too high in function worker_verify_role_capabilities. (16)
          Open

          @retry(tries=3, delay=5)
          def worker_verify_role_capabilities(role):
              """Determine if chosen role can be performed on this host (eg: ipv6 connectivity.)"""
          
              failed = False
          Severity: Minor
          Found in websecmap/celery/worker.py by radon

          Cyclomatic Complexity

          Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

          Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

          Construct Effect on CC Reasoning
          if +1 An if statement is a single decision.
          elif +1 The elif statement adds another decision.
          else +0 The else statement does not cause a new decision. The decision is at the if.
          for +1 There is a decision at the start of the loop.
          while +1 There is a decision at the while statement.
          except +1 Each except branch adds a new conditional path of execution.
          finally +0 The finally block is unconditionally executed.
          with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
          assert +1 The assert statement internally roughly equals a conditional statement.
          Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
          Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

          Source: http://radon.readthedocs.org/en/latest/intro.html

          Severity
          Category
          Status
          Source
          Language