failmap/admin

View on GitHub

Showing 267 of 577 total issues

File map_parse_administrative_regions.py has 1557 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# pylint: disable=C0321
import logging
import re
from typing import List

Severity: Major
Found in websecmap/map/management/commands/map_parse_administrative_regions.py - About 4 days to fix

    Function calculate_high_level_stats has a Cognitive Complexity of 116 (exceeds 5 allowed). Consider refactoring.
    Open

    def calculate_high_level_stats(days: int = 1, countries: List = None, organization_types: List = None):
        log.info("Creating high_level_stats")
    
        map_configurations = filter_map_configs(countries=countries, organization_types=organization_types)
    
    
    Severity: Minor
    Found in websecmap/map/report.py - About 2 days 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 settings.py has 892 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """Django settings for websecmap project.
    
    You do not need to edit the settings listed below.
    
    For example, you should not need to change the DEBUG setting here, ever. For this you can use
    Severity: Major
    Found in websecmap/settings.py - About 2 days to fix

      File test_internet_nl_v2.py has 839 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import logging
      from copy import copy
      from datetime import datetime, timedelta
      
      from websecmap.organizations.models import Url
      Severity: Major
      Found in websecmap/scanners/tests/test_internet_nl_v2.py - About 2 days to fix

        File report.py has 804 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import logging
        from collections import defaultdict
        from copy import copy, deepcopy
        from datetime import datetime
        from typing import List, Union
        Severity: Major
        Found in websecmap/reporting/report.py - About 1 day to fix

          File internet_nl_v2_websecmap.py has 752 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          """
          Web Security Map implementation of internet.nl scans.
          """
          
          import hashlib
          Severity: Major
          Found in websecmap/scanners/scanner/internet_nl_v2_websecmap.py - About 1 day to fix

            Function create_url_reports has a Cognitive Complexity of 87 (exceeds 5 allowed). Consider refactoring.
            Open

            def create_url_reports(url: Url) -> List[UrlReport]:
                timeline = create_timeline(url)
                url_reports: List[Union[UrlReport, None]] = []
            
                """
            Severity: Minor
            Found in websecmap/reporting/report.py - About 1 day 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 admin.py has 745 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import logging
            import re
            import urllib
            from datetime import datetime, timedelta
            from random import choice, choices, randint
            Severity: Major
            Found in websecmap/game/admin.py - About 1 day to fix

              File report.py has 715 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import calendar
              import logging
              from collections import OrderedDict
              from copy import deepcopy
              from datetime import date, datetime, timedelta
              Severity: Major
              Found in websecmap/map/report.py - About 1 day to fix

                File views.py has 711 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import logging
                from datetime import datetime
                
                import pytz
                import simplejson as json
                Severity: Major
                Found in websecmap/game/views.py - About 1 day to fix

                  File openstreetmap.py has 690 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import gzip
                  import json
                  import logging
                  import os.path
                  import re
                  Severity: Major
                  Found in websecmap/map/logic/openstreetmap.py - About 1 day to fix

                    Function calculate_vulnerability_statistics has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
                    Open

                    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 - About 1 day 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 views.py has 608 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import json
                    import logging
                    from datetime import datetime
                    from wsgiref.util import FileWrapper
                    
                    
                    Severity: Major
                    Found in websecmap/map/views.py - About 1 day to fix

                      Function get_improvements has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def get_improvements(country, organization_type, weeks_back, weeks_duration):
                          # todo: adjustable timespan
                          # todo: adjustable weeks_back
                      
                          weeks_back = int(weeks_back)
                      Severity: Minor
                      Found in websecmap/map/logic/improvements.py - About 1 day 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 http.py has 602 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      """
                      Scans for HTTP sites.
                      
                      If there is a HTTP site on port 80, but there is not a TLS equivalent: give points.
                      Every http site that does want to instantly upgrade gets 10 points? (how to determine?)
                      Severity: Major
                      Found in websecmap/scanners/scanner/http.py - About 1 day to fix

                        File __init__.py has 579 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        """
                        A list of all scan types that are reliable and can be used in production environments (reporting, etc).
                        
                        If you want to add a new scanner, you'll have to go through the following steps.
                        - Add it to the correct list below (todo: automate discovery of what scanners are available)
                        Severity: Major
                        Found in websecmap/scanners/__init__.py - About 1 day to fix

                          File admin.py has 570 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import importlib
                          import logging
                          from datetime import datetime
                          from json import loads
                          
                          
                          Severity: Major
                          Found in websecmap/organizations/admin.py - About 1 day to fix

                            Function get_map_data has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def get_map_data(
                                country: str = "NL", organization_type: str = "municipality", days_back: int = 0, displayed_issue: str = None
                            ):
                            
                                # A bug in the live version (possibly due to |safe) gives a Country(code='NL')} instead of
                            Severity: Minor
                            Found in websecmap/map/logic/map.py - About 1 day 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 admin.py has 531 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            import string
                            from datetime import datetime, timedelta
                            from random import choice
                            
                            import pytz
                            Severity: Major
                            Found in websecmap/app/admin.py - About 1 day to fix

                              File models.py has 515 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              # coding=UTF-8
                              from datetime import datetime, timedelta
                              
                              import pytz
                              from django.core.exceptions import ObjectDoesNotExist
                              Severity: Major
                              Found in websecmap/scanners/models.py - About 1 day to fix
                                Severity
                                Category
                                Status
                                Source
                                Language