failmap/admin

View on GitHub

Showing 267 of 577 total issues

Avoid too many return statements within this function.
Open

    return amount_of_issues, judgement_issues
Severity: Major
Found in websecmap/reporting/report.py - About 30 mins to fix

    Function compose_discover_task has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def compose_discover_task(urls: List[Url]):
        tasks = []
    
        for ip_version in [4, 6]:
            for port in PREFERRED_PORT_ORDER:
    Severity: Minor
    Found in websecmap/scanners/scanner/http.py - About 25 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 accept has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def accept(self, request, queryset):
            for urlsubmission in queryset:
    
                # don't add the same thing over and over, allows to re-select the ones already added without a problem
                # once rejected, can't be accepted via buttons: needs to be a manual action
    Severity: Minor
    Found in websecmap/game/admin.py - About 25 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 handle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle(self, *args, **options):
            """Command handle logic, eg: logging."""
            # set django loglevel based on `-v` argument
            verbosity = int(options["verbosity"])
            root_logger = logging.getLogger("")
    Severity: Minor
    Found in websecmap/app/management/commands/_private.py - About 25 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 validate_record has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def validate_record(record):
    
        if not record.get("Name", ""):
            ValueError('Missing "Name" column or column was empty.')
    
    
    Severity: Minor
    Found in websecmap/organizations/datasources/excel.py - About 25 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 pickup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def pickup(activity: str, scanner: str, amount: int = 10) -> List[Url]:
        """
        Amount should not be too high: then this loses it's power and make scans invisible again. But it helps
        with faster scanning as fewer queries are needed.
    
    
    Severity: Minor
    Found in websecmap/scanners/plannedscan.py - About 25 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 update_feature has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def update_feature(feature, scan):
        # log.debug('Updating feature %s, with scan %s' % (feature['properties']['organization_id'], scan))
        calculation = get_severity(scan)
    
        feature["properties"]["high"] += calculation["high"]
    Severity: Minor
    Found in websecmap/game/views.py - About 25 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 run_tests has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def run_tests(self, test_labels):
            """Run pytest and return the exitcode.
    
            It translates some of Django's test command option to pytest's.
            """
    Severity: Minor
    Found in websecmap/testrunner.py - About 25 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 q_configurations_to_report has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def q_configurations_to_report(level: str = "url"):
        """
        Retrieves configurations and makes q-queries for them. You can select if you want to have the q-queries directly
        for the organization tables, or with a join from url to organization.
    
    
    Severity: Minor
    Found in websecmap/scanners/scanner/__init__.py - About 25 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 name_details has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def name_details(self):
            if self.is_dead:
                return "✝ %s, %s (%s - %s)" % (
                    self.name,
                    self.country,
    Severity: Minor
    Found in websecmap/organizations/admin.py - About 25 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 has_wildcards has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def has_wildcards(urls: List[Dict[str, Any]]):
        """Run this when adding a new url.
    
        So you can be sure that there are no wildcards if you don't want them.
    
    
    Severity: Minor
    Found in websecmap/scanners/scanner/subdomains.py - About 25 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_discover_task has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def compose_discover_task(urls):
        tasks = []
        for ip_version in [4, 6]:
            # first iterate through ports, so there is more time between different connection attempts. Which reduces load
            # for the tested server. Also, the first port has the most hits :)
    Severity: Minor
    Found in websecmap/scanners/scanner/ftp.py - About 25 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 claim_proxy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def claim_proxy(tracing_label="") -> Dict[str, Any]:
        """A proxy should first be claimed and then checked. If not, several scans might use the same proxy and thus
        crash.
    
        This is run on a dedicated worker as this is a blocking task.
    Severity: Minor
    Found in websecmap/scanners/proxy.py - About 25 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 check_network has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def check_network(code_location=""):
        """
        Used to see if a worker can do IPv6. Will trigger an exception when no ipv4 or ipv6 is available,
        which is logged in sentry and other logs.
    
    
    Severity: Minor
    Found in websecmap/scanners/scanner/http.py - About 25 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 store_wildcard has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def store_wildcard(result: bool, url_id: int):
        try:
            url = Url.objects.all().get(id=url_id)
        except Url.DoesNotExist:
            log.debug(f"Url {url_id} does not exist anymore. Not doing anything")
    Severity: Minor
    Found in websecmap/scanners/scanner/dns_wildcards.py - About 25 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 q_configurations_to_display has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def q_configurations_to_display(level: str = "url"):
        """
        Retrieves configurations and makes q-queries for them. You can select if you want to have the q-queries directly
        for the organization tables, or with a join from url to organization.
    
    
    Severity: Minor
    Found in websecmap/scanners/scanner/__init__.py - About 25 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 handle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle(self, *args, **options):
            # internet.nl v2 scanner has to be used in websecmap.
            for scanner in [
                ftp,
                dnssec,
    Severity: Minor
    Found in websecmap/scanners/management/commands/plan_everything.py - About 25 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_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_data(dataset, download_function):
    
        # support downloads:
        if dataset["url"]:
    
    
    Severity: Minor
    Found in websecmap/organizations/datasources/__init__.py - About 25 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 save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def save(self):
    
            # validate again to prevent duplicates within the transaction
            # we can also check if the data is not in the db yet, which is nicer as it potentially saves a lot of time
            self.clean()
    Severity: Minor
    Found in websecmap/game/forms.py - About 25 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 validate_flat_organization has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def validate_flat_organization(flat_organization: Dict):
        layer = OrganizationType.objects.all().filter(name=flat_organization.get("layer", "")).first()
        if not layer:
            raise ValueError(
                f"Layer {flat_organization.get('layer', '')} " f"not defined. Is this layer defined in this installation?"
    Severity: Minor
    Found in websecmap/api/apis/zorgkaart.py - About 25 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

    Severity
    Category
    Status
    Source
    Language