failmap/admin

View on GitHub

Showing 267 of 577 total issues

Function can_connect has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

def can_connect(self, protocol: str, url: str, port: int, ip_version: int) -> bool:
    """
    Searches for both IPv4 and IPv6 IP addresses / types.

    The algorithm is very simple: if there is a http status code, or "a response" there is an
Severity: Minor
Found in websecmap/scanners/scanner/http.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 verify_periodic_tasks_from_fixture has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

def verify_periodic_tasks_from_fixture(fixture):

    call_command("loaddata", fixture, verbosity=0)

    periodic_tasks = PeriodicTask.objects.all()
Severity: Minor
Found in websecmap/app/tests/test_periodic_tasks.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 inspect_timeline has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

def inspect_timeline(timeline, url: Url):
    newline = "\r\n"
    message = ""
    message += "" + newline
    message += "This timeline shows all changes over time on the following url:" + newline
Severity: Minor
Found in websecmap/reporting/report.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

File test_create_url_report.py has 275 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from datetime import datetime

import pytz

from websecmap.reporting.models import UrlReport
Severity: Minor
Found in websecmap/reporting/tests/test_create_url_report.py - About 2 hrs to fix

    Function store_new has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def store_new(feature: Dict, country: str = "NL", organization_type: str = "municipality", when=None):
        properties = feature["properties"]
        coordinates = feature["geometry"]
    
        """
    Severity: Minor
    Found in websecmap/map/logic/openstreetmap.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 test_internet_nl_store_testresults has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    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/"},
    Severity: Major
    Found in websecmap/scanners/tests/test_internet_nl_v2.py - About 2 hrs to fix

      File map.py has 270 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      from datetime import datetime
      from typing import List
      
      import pytz
      import simplejson as json
      Severity: Minor
      Found in websecmap/map/logic/map.py - About 2 hrs to fix

        File zorgkaart.py has 270 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        #!/usr/bin/python3
        # Note: run make fix and make check before committing code.
        
        """
        Scrapes organisations from Zorgkaart Nederland API
        Severity: Minor
        Found in websecmap/api/apis/zorgkaart.py - About 2 hrs to fix

          Function test_data_from_dead_endpoint_stays_gone has 61 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          def test_data_from_dead_endpoint_stays_gone(db):
              """
              Scenario:
          
              It's March 1st 2020 (or later). Example.nl has an endpoint that is dead, and one that is alive. A scan
          Severity: Major
          Found in websecmap/reporting/tests/test_create_url_report.py - About 2 hrs to fix

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

            def calculate_progress() -> List[Dict[str, int]]:
                """
                Retrieves the progress of all scans in the past 7 days. Will show how many are requested and how many
                are at what state.
            
            
            Severity: Minor
            Found in websecmap/scanners/plannedscan.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 get_endpoints_with_missing_encryption has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

            def get_endpoints_with_missing_encryption(url):
                """
                Finds a list of endpoints that are missing an encrypted counterpart. Takes in account ip_version.
            
                The default ports matter for normal humans. All services on other ports are special services.
            Severity: Minor
            Found in websecmap/scanners/scanner/plain_http.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 store_updates has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

            def store_updates(feature: Dict, country: str = "NL", organization_type: str = "municipality", when=None):
                properties = feature["properties"]
                coordinates = feature["geometry"]
            
                """
            Severity: Minor
            Found in websecmap/map/logic/openstreetmap.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 clean has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                def clean(self):
                    try:
                        organizations = self.data.getlist("for_organization", [])
                    except AttributeError:
                        organizations = []
            Severity: Minor
            Found in websecmap/game/forms.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 dnsrecon_parse_report_contents has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

            def dnsrecon_parse_report_contents(contents: List, url: Dict[str, Any]):
                """
                [
                    {'type': 'A', 'name': 'basisbeveiliging.nl', 'address': '1.1.1.1'},
                    {'type': 'AAAA', 'name': 'basisbeveiliging.nl', 'address': '2a00:d00:ff:....'},
            Severity: Minor
            Found in websecmap/scanners/scanner/subdomains.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 split_ratings_between_good_and_bad has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

            def split_ratings_between_good_and_bad(
                report: OrganizationReport, hours: int = OUTDATED_HOURS
            ) -> Tuple[List[Dict[str, Any]], List[Dict[str, Any]]]:
                now = datetime.now(pytz.utc)
                a_while_ago = now - timedelta(hours=hours)
            Severity: Minor
            Found in websecmap/map/logic/map_health.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 triage_identical has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

            def triage_identical():
                """
                This is mainly to clean up the Dutch Government Almanak, which has tons of duplicate data. For each
                tax office they use the same domains. Ministry of defense has tons of the same domains under different names.
            
            
            Severity: Minor
            Found in websecmap/map/logic/identical_organizations.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 save_url_report has 54 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            def save_url_report(url: Url, date: datetime, calculation, is_the_newest=False):
                # This also injects the statistics into the json, for use in representations / views in the right places.
                calculation, amount_of_issues = statistics_over_url_calculation(calculation)
            
                u = UrlReport()
            Severity: Major
            Found in websecmap/reporting/report.py - About 2 hrs to fix

              File _private.py has 255 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              """Management command base classes."""
              import json
              import logging
              import time
              from collections import Counter
              Severity: Minor
              Found in websecmap/app/management/commands/_private.py - About 2 hrs to fix

                Function statistics_over_url_calculation has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                def statistics_over_url_calculation(calculation):
                    empty_with_some_extras = {
                        "high": 0,
                        "medium": 0,
                        "low": 0,
                Severity: Minor
                Found in websecmap/reporting/report.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 add_scanner_fieldsets has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                def add_scanner_fieldsets(constance_config_fieldsets):
                    # now create the menus for these scanners.
                    discover_set = ("SCAN_AT_ALL",)
                    for scanner in SCANNERS:
                        if scanner["can discover urls"]:
                Severity: Minor
                Found in websecmap/scanners/constance.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

                Severity
                Category
                Status
                Source
                Language