failmap/admin

View on GitHub

Showing 577 of 577 total issues

Function analyze_headers has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def analyze_headers(headers: Dict[str, str], endpoint_id):
    # todo: remove code paths, and make a more clear case per header type. That's easier to understand edge cases.
    # todo: Content-Security-Policy, Referrer-Policy

    # if scan task failed, ignore the result (exception) and report failed status
Severity: Minor
Found in websecmap/scanners/scanner/security_headers.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 calculate_map_data has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def calculate_map_data(days: int = 366, countries: List = None, organization_types: List = None):
    from django.db import OperationalError

    log.info("calculate_map_data")

Severity: Minor
Found in websecmap/map/report.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 create_health_report has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def create_health_report(outdated: List, good: List, published_scan_types):
    """
    Returns:
        {
            'outdate_period_in_hours': 72,
Severity: Minor
Found in websecmap/map/logic/map_health.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 internet_nl_requirement_tilde_value_format has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def internet_nl_requirement_tilde_value_format(scan: Union[EndpointGenericScan, UrlGenericScan]):

    # To support old metrics:
    if "~" in scan.rating:
        return internet_nl_api_v1_requirement_tilde_value_format(scan)
Severity: Minor
Found in websecmap/reporting/severity.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 test_reflag_endpointgenericscan has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def test_reflag_endpointgenericscan(db):
    u = Url.objects.create(url="basisbeveiliging.nl")
    e = Endpoint.objects.create(protocol="https", port=443, ip_version=4, is_dead=False, url=u)

    # scans for first endpoint
Severity: Minor
Found in websecmap/scanners/tests/test_set_latest_scan.py - About 1 hr to fix

    Function store_check_result has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def store_check_result(
    Severity: Major
    Found in websecmap/scanners/proxy.py - About 1 hr to fix

      Function standard_calculation has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def standard_calculation(
      Severity: Major
      Found in websecmap/reporting/severity.py - About 1 hr to fix

        Function standard_calculation_for_internet_nl has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def standard_calculation_for_internet_nl(
        Severity: Major
        Found in websecmap/reporting/severity.py - About 1 hr to fix

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

              submitted_organizations = (
                  OrganizationSubmission.objects.all()
                  .filter(added_by_team__participating_in_contest=contest)
                  .annotate(num_urls=Count("organization_in_system__u_many_o_upgrade"))
                  .order_by("organization_type_name", "organization_name")
          Severity: Major
          Found in websecmap/game/views.py and 1 other location - About 1 hr to fix
          websecmap/game/views.py on lines 386..390

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

          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

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

              submitted_organizations = (
                  OrganizationSubmission.objects.all()
                  .filter(added_by_team__participating_in_contest=contest)
                  .annotate(num_urls=Count("organization_in_system__u_many_o_upgrade"))
                  .order_by("organization_type_name", "organization_name")
          Severity: Major
          Found in websecmap/game/views.py and 1 other location - About 1 hr to fix
          websecmap/game/views.py on lines 456..460

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

          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 2 locations. Consider refactoring.
          Open

                  def get_admin(self, path):
                      with urllib.request.urlopen(self.admin_url + path) as f:
                          return (f, f.read().decode("utf-8"))
          Severity: Major
          Found in tests/system/conftest.py and 1 other location - About 1 hr to fix
          tests/system/conftest.py on lines 34..36

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

          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 2 locations. Consider refactoring.
          Open

                      try:
                          with urllib.request.urlopen(self.frontend_url + path) as f:
                              return (f, f.read().decode("utf-8"))
          Severity: Major
          Found in tests/system/conftest.py and 1 other location - About 1 hr to fix
          tests/system/conftest.py on lines 29..31

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

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

          def parse_data(dataset, filename):
              data = read_data(filename)
              # this is some kind of XML format. for which an XSD is available.
              # for each document another namespace version is available, which makes it harder.
              # how can we identify the correct namespace for p correctly automatically?
          Severity: Minor
          Found in websecmap/organizations/datasources/dutch_government.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 merge has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          def merge(
              source_organizations_names: List[str],
              target_organization_name: str,
              when: datetime,
              organization_type: str = "municipality",
          Severity: Minor
          Found in websecmap/organizations/adminstrative_transformations.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 contest_map_data has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          def contest_map_data(request):
              """
              This doesn't have to take in account the time sliding features of failmap.
          
              Just take ANY result from the scans matching it with the is_latest_coordinate. It's already
          Severity: Minor
          Found in websecmap/game/views.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 compose_task has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          def compose_task(
              organizations_filter: dict = dict(), urls_filter: dict = dict(), endpoints_filter: dict = dict(), **kwargs
          ) -> Task:
              """Multi-stage onboarding."""
          
          
          Severity: Minor
          Found in websecmap/scanners/scanner/onboard.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 get_identical_sites_on_wildcard_url has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          def get_identical_sites_on_wildcard_url(wildcard_url: str) -> List[int]:
              identical = []
          
              if not discover_wildcard(wildcard_url):
                  return identical
          Severity: Minor
          Found in websecmap/scanners/scanner/dns_clean_wildcards.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 teams has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          def teams(request):
          
              # if you don't have a contest selected, you're required to do so...
              # contest 0 can exist. ?
              if request.session.get("contest", -1) < 0:
          Severity: Minor
          Found in websecmap/game/views.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 8 locations. Consider refactoring.
          Open

          class OrganizationConverter:
              regex = r"[a-z_\-]{0,50}"
          
              def to_python(self, value):
                  return str(value)
          Severity: Major
          Found in websecmap/converters.py and 7 other locations - About 55 mins to fix
          websecmap/converters.py on lines 1..8
          websecmap/converters.py on lines 11..18
          websecmap/converters.py on lines 21..28
          websecmap/converters.py on lines 41..49
          websecmap/converters.py on lines 52..59
          websecmap/converters.py on lines 62..69
          websecmap/converters.py on lines 72..79

          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

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

          class JsonConverter:
              # Supports {"key": "value", "key2": "value2"} syntax.
              regex = r'[a-zA-Z0-9:_\-=}{, "\']{0,1024}'
          
              def to_python(self, value):
          Severity: Major
          Found in websecmap/converters.py and 7 other locations - About 55 mins to fix
          websecmap/converters.py on lines 1..8
          websecmap/converters.py on lines 11..18
          websecmap/converters.py on lines 21..28
          websecmap/converters.py on lines 31..38
          websecmap/converters.py on lines 52..59
          websecmap/converters.py on lines 62..69
          websecmap/converters.py on lines 72..79

          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

          Severity
          Category
          Status
          Source
          Language