failmap/admin

View on GitHub

Showing 267 of 577 total issues

Function test_url_report has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def test_url_report(db):
    # Url test.nl has been created
    day_0 = datetime(day=1, month=1, year=2000, tzinfo=pytz.utc)
    # First endpoint was created, first OK scan
    day_1 = datetime(day=2, month=1, year=2000, tzinfo=pytz.utc)
Severity: Major
Found in websecmap/reporting/tests/test_url_report.py - About 2 hrs to fix

    Function merge_endpoints_that_recently_died has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def merge_endpoints_that_recently_died():
        # with a timespan of a week: if within a week a new similar endpoint was created, merge them into the old one.
    
        # find difference between "is_dead_since" and "discovered_on" for the same url.
        for url in Url.objects.all():
    Severity: Minor
    Found in websecmap/organizations/management/commands/clean_short_outages.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 get_security_header_calculation has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_security_header_calculation(scan: Union[EndpointGenericScan, UrlGenericScan]):
        """
        Rationale for classifcation
    
            # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection
    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 internet_nl_api_v1_requirement_tilde_value_format has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def internet_nl_api_v1_requirement_tilde_value_format(scan: Union[EndpointGenericScan, UrlGenericScan]):
        """
        See documentation of upgrade_api_response to learn how this parsing works.
    
        sept 2019:
    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 item_title has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def item_title(self, item):
            calculation = get_severity(item)
            if not calculation:
                return ""
    
    
    Severity: Minor
    Found in websecmap/map/logic/rss_feeds.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 aggegrate_url_rating_scores has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def aggegrate_url_rating_scores(url_ratings: List, only_include_issues: List[str] = None):
        """
    
        :param url_ratings: All url ratings that should be combined into a single report.
        :param only_include_issues: List of issue names, that will be added in the report. This can save a lot of data.
    Severity: Minor
    Found in websecmap/reporting/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 get_new_urls has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_new_urls(urls: List[str]):
    
        new_urls = []
    
        for url in urls:
    Severity: Minor
    Found in websecmap/organizations/management/commands/add_urls.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 scores has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def scores(request):
    
        # todo: this param handling code is absolutely disgusting, it should be more beautiful.
        # todo: should we just get the last contest if there is no contest at all?
        submitted_contest = request.GET.get("contest", "")
    Severity: Minor
    Found in websecmap/game/views.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 add_scanner_fields has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def add_scanner_fields(constance_config):
        """
        Add a series of configuration options depending on the scanners in websecmap.
    
        Allows for easier reuse in projects that import websecmap.
    Severity: Minor
    Found in websecmap/scanners/constance.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 recreate_url_report has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def recreate_url_report(url_id):
        """
        This used to rebuild all reports every night. This works fine until there are a lot of urls and a lot of
        scan moments to address. It would rebuild 816088 rows on production each night while there are only
        60.000 urls. Only adding the latest report, if anything changed at all, will reduce 90% of the workload.
    Severity: Minor
    Found in websecmap/reporting/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 add_or_update_features has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def add_or_update_features(features, scan):
        # not really memory efficient
        new_features = []
    
        # features are unique by organization ID.
    Severity: Minor
    Found in websecmap/game/views.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 add_organization has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def add_organization(data):
    
        if not data.get("layer", 0):
            return operation_response(error=True, message="No layer selected, cannot add organization.")
    
    
    Severity: Minor
    Found in websecmap/map/logic/admin.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 update_map_health_reports has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def update_map_health_reports(
        published_scan_types, days: int = 366, countries: List = None, organization_types: List = None
    ):
    
        map_configurations = filter_map_configs(countries=countries, organization_types=organization_types)
    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 create_timeline has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def create_timeline(url: Url):
        """
        Maps happenings to moments.
    
        This is used to save database queries: when you know at what moment things change and what happened before,
    Severity: Minor
    Found in websecmap/reporting/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 handle has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def handle(self, *app_labels, **options):
            merge_date = datetime(year=2019, month=1, day=1, hour=0, minute=0, second=0, microsecond=0, tzinfo=pytz.utc)
    
            """
            De gemeenten Dongeradeel, Ferwerderadiel en Kollumerland en Nieuwkruisland: samenvoeging tot een

      Function handle has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def handle(self, *app_labels, **options):
              merge_date = datetime(year=2019, month=1, day=1, hour=0, minute=0, second=0, microsecond=0, tzinfo=pytz.utc)
      
              """
              De gemeenten Dongeradeel, Ferwerderadiel en Kollumerland en Nieuwkruisland: samenvoeging tot een

        Function test_internet_nl_logging has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def test_internet_nl_logging(db):
        
            # todo: make sure that never an empty list is added in normal situations?
            scan = initialize_scan("web", [])
            last = InternetNLV2StateLog.objects.all().last()
        Severity: Minor
        Found in websecmap/scanners/tests/test_internet_nl_v2.py - About 1 hr to fix

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

          def store_when_new_or_kill_if_gone(connected, url, port, protocol, ip_version):
              """
          
              :param url: any url where endpoints are discovered.
              :param port: any port: 1 to 65535
          Severity: Minor
          Found in websecmap/scanners/scanner/ftp.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 is_improved has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          def is_improved(first_scan, last_scan):
              if first_scan == "high":
                  return True if last_scan in ["medium", "low", "good"] else False
              if first_scan == "medium":
                  return True if last_scan in ["low", "good"] else False
          Severity: Minor
          Found in websecmap/scanners/impact.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 get_submitted_urls has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          def get_submitted_urls(contest):
              # Don't use to_attr or prefetch related, as it is not maintainable code and i could not get it to work at all for
              # hours. which was such a waste.
          
              submitted_urls = (
          Severity: Minor
          Found in websecmap/game/views.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

          Severity
          Category
          Status
          Source
          Language