psono/psono-server

View on GitHub

Showing 228 of 423 total issues

File various.py has 1048 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from django.conf import settings
from django.contrib.auth.hashers import check_password, make_password
from django.core.cache import cache
from django.db import connection
from urllib.parse import urlparse
Severity: Major
Found in psono/restapi/utils/various.py - About 2 days to fix

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

    from django.db.models.signals import post_save, post_delete
    from django.db import models
    from django.dispatch import receiver
    from django.core.cache import cache
    from django.conf import settings
    Severity: Major
    Found in psono/restapi/models.py - About 2 days to fix

      File app_settings.py has 773 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      from django.conf import settings
      
      from importlib import import_module
      
      from .serializers import (
      Severity: Major
      Found in psono/restapi/app_settings.py - About 1 day to fix

        File settings.py has 571 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """
        Django settings for psono project.
        
        Generated by 'django-admin startproject' using Django 1.8.3.
        
        
        Severity: Major
        Found in psono/psono/settings.py - About 1 day to fix

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

              def put(self, request, *args, **kwargs):
                  """
                  Create Share_Right
          
                  Necessary Rights:
          Severity: Minor
          Found in psono/restapi/views/share_right.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

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

              def validate(self, attrs: dict) -> dict:
          
                  file_repository_id = attrs.get('file_repository_id')
                  title = attrs.get('title', '').strip()
                  type = attrs.get('type', '').lower().strip()
          Severity: Minor
          Found in psono/restapi/serializers/update_file_repository.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

          Function validate has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
          Open

              def validate(self, attrs: dict) -> dict:
          
                  title = attrs.get('title', '').strip()
                  type = attrs.get('type', '').lower().strip()
                  gcp_cloud_storage_bucket = attrs.get('gcp_cloud_storage_bucket', '').strip()
          Severity: Minor
          Found in psono/restapi/serializers/create_file_repository.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

          Function user_has_rights_on_secret has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
          Open

          def user_has_rights_on_secret(user_id: str, secret_id: Union[str, List[str]], read: bool = None, write: bool = None) -> Union[bool, List[bool]]:  #nosec B105, B107
              """
              Checks if the given user has the requested rights for the given secret
          
              :param user_id:
          Severity: Minor
          Found in psono/restapi/utils/various.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 authorize_upload.py has 463 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          from django.urls import reverse
          from django.conf import settings
          from django.utils import timezone
          from datetime import timedelta
          from rest_framework import status
          Severity: Minor
          Found in psono/fileserver/tests/authorize_upload.py - About 7 hrs to fix

            Function calculate_user_rights_on_share has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
            Open

            def calculate_user_rights_on_share(user_id: str, share_id: Union[str, List[str]]) -> Union[dict, List[dict], None]:
                """
                Calculates the user's rights on a share
            
                :param user_id:
            Severity: Minor
            Found in psono/restapi/utils/various.py - About 5 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 validate has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
            Open

                def validate(self, attrs: dict) -> dict:
            
                    link_share_id = attrs.get('link_share_id')
                    passphrase = attrs.get('passphrase', '')
            
            
            Severity: Minor
            Found in psono/restapi/serializers/update_link_share_access.py - About 5 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 create_secret_in_share.py has 393 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            """
            A small demo script that shows how to create a secret in a shared folder (unrestricted API key)
            """
            import uuid
            import requests
            Severity: Minor
            Found in examples/create_secret_in_share.py - About 5 hrs to fix

              Function validate has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
              Open

                  def validate(self, attrs: dict) -> dict:
              
                      link_share_id = attrs.get('link_share_id')
                      passphrase = attrs.get('passphrase', '')
              
              
              Severity: Minor
              Found in psono/restapi/serializers/read_link_share_access.py - About 5 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 post has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
              Open

                  def post(self, request, *args, **kwargs):
                      """
                      Creates a new security report
              
                      :param request:
              Severity: Minor
              Found in psono/restapi/views/security_report.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 get has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get(self, request, file_repository_id=None, *args, **kwargs):
                      """
                      Returns either a list of all file_repositories with own access privileges or the members specified file_repository
              
                      :param request:
              Severity: Minor
              Found in psono/restapi/views/file_repository.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 create_secret_in_datastore.py has 365 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              """
              A small demo script that shows how to create a secret in a datastore (unrestricted API key)
              """
              import uuid
              import requests
              Severity: Minor
              Found in examples/create_secret_in_datastore.py - About 4 hrs to fix

                Function validate has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
                Open

                    def validate(self, attrs: dict) -> dict:
                        email = attrs.get('email')
                        authkey_old = attrs.get('authkey_old')
                        authkey = attrs.get('authkey', False)
                        hashing_algorithm = attrs.get('hashing_algorithm', '')
                Severity: Minor
                Found in psono/restapi/serializers/user_update.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 authorize_download.py has 362 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                from django.urls import reverse
                from django.conf import settings
                from django.utils import timezone
                from datetime import timedelta
                from rest_framework import status
                Severity: Minor
                Found in psono/fileserver/tests/authorize_download.py - About 4 hrs to fix

                  File export_as_json.py has 357 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  """
                  A small demo script that shows how to export the datastore (unrestricted API key)
                  """
                  import requests
                  import json
                  Severity: Minor
                  Found in examples/export_as_json.py - About 4 hrs to fix

                    File authentication.py has 351 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import os
                    from datetime import timedelta
                    from django.conf import settings
                    from django.utils import timezone
                    from django.utils.crypto import constant_time_compare
                    Severity: Minor
                    Found in psono/restapi/authentication.py - About 4 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language