psono/psono-server

View on GitHub

Showing 228 of 423 total issues

Function duo_auth_enroll has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def duo_auth_enroll(integration_key: str, secret_key: str, host: str, username: str) -> dict:
    """
    Anonymous enrollment of a new device

    :param integration_key: The Duo integration key
Severity: Minor
Found in psono/restapi/utils/duo.py - About 1 hr 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 main has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def main():
    # 1. Generate the login info including the private key for PFS
    session_private_key, client_login_info = generate_client_login_info()

    # 2. Send the login request and handle eventual exceptions, problems and so on ...
Severity: Minor
Found in examples/create_secret_in_share.py - About 1 hr 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_share has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def user_has_rights_on_share(user_id: str, share_id: Union[str, List[str]], read: bool = None, write: bool = None, grant: bool = None) -> Union[None, bool, List[bool]]:
    """
    Checks if the given user has the requested rights for the given share.
    User_share_rights and all Group_share_rights be checked first.

Severity: Minor
Found in psono/restapi/utils/various.py - About 1 hr 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 13 (exceeds 5 allowed). Consider refactoring.
Open

    def validate(self, attrs: dict) -> dict:

        link_id = attrs.get('link_id', '')
        share_id = attrs.get('share_id', '')
        parent_share_id = attrs.get('parent_share_id', None)
Severity: Minor
Found in psono/restapi/serializers/create_share_link.py - About 1 hr 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 13 (exceeds 5 allowed). Consider refactoring.
Open

    def validate(self, attrs: dict) -> dict:
        link_ids = attrs.get('link_ids')

        parent_shares = []
        parent_datastores = []
Severity: Minor
Found in psono/restapi/serializers/bulk_delete_secret_link.py - About 1 hr 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 13 (exceeds 5 allowed). Consider refactoring.
Open

    def validate(self, attrs: dict) -> dict:
        link_id = attrs.get('link_id')

        file_ids = []
        parent_shares = []
Severity: Minor
Found in psono/restapi/serializers/delete_file_link.py - About 1 hr 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 13 (exceeds 5 allowed). Consider refactoring.
Open

    def validate(self, attrs: dict) -> dict:
        link_id = attrs.get('link_id')

        secrets = []
        parent_shares = []
Severity: Minor
Found in psono/restapi/serializers/delete_secret_link.py - About 1 hr 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 13 (exceeds 5 allowed). Consider refactoring.
Open

    def validate(self, attrs: dict) -> dict:

        link_id = str(attrs.get('link_id')).replace("-", "")

        shares = []
Severity: Minor
Found in psono/restapi/serializers/delete_share_link.py - About 1 hr 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 13 (exceeds 5 allowed). Consider refactoring.
Open

    def validate(self, attrs: dict) -> dict:
        user_share_right_id = attrs.get('user_share_right_id', None)
        group_share_right_id = attrs.get('group_share_right_id', None)

        if user_share_right_id is None and group_share_right_id is None:
Severity: Minor
Found in psono/restapi/serializers/delete_share_right.py - About 1 hr 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 39 lines of code (exceeds 25 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 hr to fix

    Function setUp has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def setUp(self):
    
            self.test_email = ''.join(random.choice(string.ascii_lowercase) for _ in range(10)) + 'test@example.com'
            self.test_email_bcrypt = 'a'
            self.test_username = ''.join(random.choice(string.ascii_lowercase) for _ in range(10)) + 'test@psono.pw'
    Severity: Minor
    Found in psono/fileserver/tests/authorize_upload.py - About 1 hr to fix

      Function post has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def post(self, request, *args, **kwargs):
              """
              Check the username and authkey and return the REST Token
              if the credentials are valid and authenticated.
      
      
      Severity: Minor
      Found in psono/restapi/views/login.py - About 1 hr to fix

        Function get has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def get(self, request, *args, **kwargs):
                """
                Check the health of the application
                
                :param request:
        Severity: Minor
        Found in psono/restapi/views/health_check.py - About 1 hr 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_group_details has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_group_details(self, request, membership):
        
                members = []
                if membership.accepted:
                    for m in membership.group.members.all():
        Severity: Minor
        Found in psono/restapi/views/group.py - About 1 hr 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 is_allowed_url has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def is_allowed_url(url: str, url_filter: list) -> bool:
            """
            Takes an url, checks it against URL_FILTER and returns whether the url is allowed or not
        
            :param url: The url to test
        Severity: Minor
        Found in psono/restapi/utils/various.py - About 1 hr 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 put has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def put(self, request, *args, **kwargs):
                """
                Checks the REST Token and updates the users email / authkey / secret and private key
        
                :param request:
        Severity: Minor
        Found in psono/restapi/views/user_update.py - About 1 hr 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 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def validate(self, attrs: dict) -> dict:
        
                api_key_id = attrs.get('api_key_id')
                secret_id = attrs.get('secret_id')
                api_key_secret_key = attrs.get('api_key_secret_key', False)
        Severity: Minor
        Found in psono/restapi/serializers/update_secret_with_api_key.py - About 1 hr 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 config_get has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def config_get(key, *args):
            if 'PSONO_' + key in os.environ:
                val = os.environ.get('PSONO_' + key)
                try:
                    json_object = json.loads(val)
        Severity: Minor
        Found in psono/psono/settings.py - About 1 hr 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_user_info has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_user_info(self, user):
        
                memberships = []
                for m in User_Group_Membership.objects.filter(user=user).select_related('group').only("id", "accepted", "group_admin", "share_admin", "create_date", "group__id", "group__name", "group__create_date", "group__public_key"):
                    memberships.append({
        Severity: Minor
        Found in psono/administration/views/user.py - About 1 hr 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 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def post(self, request, *args, **kwargs):
                """
                Updates a api_key
        
                :param request:
        Severity: Minor
        Found in psono/restapi/views/api_key.py - About 1 hr 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