failmap/admin

View on GitHub

Showing 577 of 577 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    assert sixth_report.calculation == {
        "endpoint_issues_high": 0,
        "endpoint_issues_low": 0,
        "endpoint_issues_medium": 0,
        "endpoints": [
Severity: Major
Found in websecmap/reporting/tests/test_create_url_report.py and 1 other location - About 1 day to fix
websecmap/reporting/tests/test_create_url_report.py on lines 155..230

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 163.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      class Command(ScannerTaskCommand):
          """Can perform a host of scans. Run like: failmap scan [scanner_name] and then options."""
      
          help = __doc__
      
      
      Severity: Major
      Found in websecmap/scanners/management/commands/scan.py and 2 other locations - About 1 day to fix
      websecmap/scanners/management/commands/discover.py on lines 19..39
      websecmap/scanners/management/commands/verify.py on lines 18..38

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 147.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      class Command(DiscoverTaskCommand):
          """Can perform a host of scans. Run like: failmap scan [scanner_name] and then options."""
      
          help = __doc__
      
      
      Severity: Major
      Found in websecmap/scanners/management/commands/discover.py and 2 other locations - About 1 day to fix
      websecmap/scanners/management/commands/scan.py on lines 35..55
      websecmap/scanners/management/commands/verify.py on lines 18..38

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 147.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      class Command(VerifyTaskCommand):
          """Can perform a host of scans. Run like: failmap scan [scanner_name] and then options."""
      
          help = __doc__
      
      
      Severity: Major
      Found in websecmap/scanners/management/commands/verify.py and 2 other locations - About 1 day to fix
      websecmap/scanners/management/commands/discover.py on lines 19..39
      websecmap/scanners/management/commands/scan.py on lines 35..55

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 147.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        class EndpointIssues(models.Model):
            """
            A sum of issues per endpoint. An endpoint can have many scans with various severities.
            It sums up EndpointGenericScans.
            """
        Severity: Major
        Found in websecmap/reporting/models.py and 1 other location - About 1 day to fix
        websecmap/reporting/models.py on lines 66..92

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 144.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

                    "new": {
                        "high": changes.get("overall", {}).get("new", {}).get("high", 0) + changes[scan_type]["new"]["high"],
                        "medium": changes.get("overall", {}).get("new", {}).get("medium", 0)
                        + changes[scan_type]["new"]["medium"],
                        "low": changes.get("overall", {}).get("new", {}).get("low", 0) + changes[scan_type]["new"]["low"],
        Severity: Major
        Found in websecmap/map/logic/improvements.py and 2 other locations - About 1 day to fix
        websecmap/map/logic/improvements.py on lines 175..179
        websecmap/map/logic/improvements.py on lines 187..193

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 144.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

                    "old": {
                        "high": changes.get("overall", {}).get("old", {}).get("high", 0) + changes[scan_type]["old"]["high"],
                        "medium": changes.get("overall", {}).get("old", {}).get("medium", 0)
                        + changes[scan_type]["old"]["medium"],
                        "low": changes.get("overall", {}).get("old", {}).get("low", 0) + changes[scan_type]["old"]["low"],
        Severity: Major
        Found in websecmap/map/logic/improvements.py and 2 other locations - About 1 day to fix
        websecmap/map/logic/improvements.py on lines 181..185
        websecmap/map/logic/improvements.py on lines 187..193

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 144.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

                    "improvements": {
                        "high": changes.get("overall", {}).get("improvements", {}).get("high", 0)
                        + changes[scan_type]["improvements"]["high"],
                        "medium": changes.get("overall", {}).get("improvements", {}).get("medium", 0)
                        + changes[scan_type]["improvements"]["medium"],
        Severity: Major
        Found in websecmap/map/logic/improvements.py and 2 other locations - About 1 day to fix
        websecmap/map/logic/improvements.py on lines 175..179
        websecmap/map/logic/improvements.py on lines 181..185

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 144.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        class UrlIssues(models.Model):
            """
            The same as EndpointGenericScan, but then on URL level.
            """
        
        
        Severity: Major
        Found in websecmap/reporting/models.py and 1 other location - About 1 day to fix
        websecmap/reporting/models.py on lines 26..63

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 144.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                def handle(self, *app_labels, **options):
                    """
                    This function will make a YAML export of the data in the database that is not easily
                    recreateable.
            
            
            websecmap/organizations/management/commands/create_dataset.py on lines 46..77

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 128.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                def handle(self, *app_labels, **options):
                    """
                    This function will make a JSON export of the data in the database that is not easily
                    recreateable.
            
            
            websecmap/organizations/management/commands/create_dataset_without_scans.py on lines 70..101

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 128.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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