failmap/admin

View on GitHub

Showing 267 of 577 total issues

File test_zorgkaart.py has 481 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging

import websecmap
from websecmap.api.apis.zorgkaart import organization_and_url_import
from websecmap.organizations.models import Coordinate, Organization, OrganizationType, Url
Severity: Minor
Found in websecmap/api/tests/test_zorgkaart.py - About 7 hrs to fix

    File severity.py has 467 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """
    Business logic that determines what points and calculations are stored.
    
    This file contains (or should) verbose explantion of why points are given.
    
    
    Severity: Minor
    Found in websecmap/reporting/severity.py - About 7 hrs to fix

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

      import logging
      from copy import deepcopy
      from datetime import datetime
      from typing import Dict, Any
      
      
      Severity: Minor
      Found in websecmap/map/admin.py - About 7 hrs to fix

        File subdomains.py has 450 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import itertools
        import logging
        import random
        import string
        import tempfile
        Severity: Minor
        Found in websecmap/scanners/scanner/subdomains.py - About 6 hrs to fix

          File tls_qualys.py has 425 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          """
          Manages endpoints:
           Protocols: https
           Ports: 443
           IP's: any related to a domain on mentioned protocols and ports.
          Severity: Minor
          Found in websecmap/scanners/scanner/tls_qualys.py - About 6 hrs to fix

            File forms.py has 401 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import logging
            import time
            
            import tldextract
            from dal import autocomplete
            Severity: Minor
            Found in websecmap/game/forms.py - About 5 hrs to fix

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

              from django.contrib import admin
              from django.utils.html import format_html
              from django.utils.safestring import mark_safe
              from import_export.admin import ImportExportModelAdmin
              from jet.admin import CompactInline
              Severity: Minor
              Found in websecmap/scanners/admin.py - About 5 hrs to fix

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

                # coding=UTF-8
                # from __future__ import unicode_literals
                
                import hashlib
                import logging
                Severity: Minor
                Found in websecmap/organizations/models.py - About 5 hrs to fix

                  Function analyze_result has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                  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 - 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

                  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

                  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

                      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

                          File proxy.py has 306 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import logging
                          from datetime import datetime, timedelta
                          from http.client import BadStatusLine
                          from multiprocessing.pool import ThreadPool
                          from time import sleep
                          Severity: Minor
                          Found in websecmap/scanners/proxy.py - About 3 hrs to fix

                            Function update_coordinates has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def update_coordinates(countries: List[str] = None, organization_types: List[str] = None, when=None):
                            
                                if not osmtogeojson_available():
                                    raise FileNotFoundError(
                                        "osmtogeojson was not found. Please install it and make sure python can access it. " "Cannot continue."
                            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

                            Severity
                            Category
                            Status
                            Source
                            Language