italia/spid-cie-oidc-django

View on GitHub

Showing 35 of 138 total issues

Function trust_mark_status has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def trust_mark_status(request):
failed_data = {"active": False}
 
sub = request.POST.get("sub") or request.GET.get("sub", None)
_id = request.POST.get("trust_mark_id") or request.GET.get("trust_mark_id", None) \
Severity: Minor
Found in spid_cie_oidc/authority/views.py - About 1 hr to fix

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

spid_cie_oidc/entity/migrations/0030_remove_federationentityconfiguration_issue_x509.py on lines 0..15
spid_cie_oidc/provider/migrations/0002_remove_oidcsession_user_claims.py on lines 0..13

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

spid_cie_oidc/authority/migrations/0012_remove_federationdescendant_issue_x509.py on lines 0..12
spid_cie_oidc/provider/migrations/0002_remove_oidcsession_user_claims.py on lines 0..13

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

spid_cie_oidc/authority/migrations/0012_remove_federationdescendant_issue_x509.py on lines 0..12
spid_cie_oidc/entity/migrations/0030_remove_federationentityconfiguration_issue_x509.py on lines 0..15

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

Severity: Minor
Found in spid_cie_oidc/entity/migrations/0012_delete_publicjwk.py and 1 other location - About 45 mins to fix
spid_cie_oidc/authority/migrations/0009_delete_stafftoken.py on lines 0..13

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

Severity: Minor
Found in spid_cie_oidc/authority/migrations/0009_delete_stafftoken.py and 1 other location - About 45 mins to fix
spid_cie_oidc/entity/migrations/0012_delete_publicjwk.py on lines 0..13

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

migrations.AddField(
model_name='federationentityconfiguration',
name='jwks_core',
field=models.JSONField(default=spid_cie_oidc.entity.models.FederationEntityConfiguration._create_jwks, help_text='a list of private keys for Core ops'),
spid_cie_oidc/authority/migrations/0003_alter_federationdescendantcontact_entity_and_more.py on lines 26..30
spid_cie_oidc/authority/migrations/0003_alter_federationdescendantcontact_entity_and_more.py on lines 34..38
spid_cie_oidc/authority/migrations/0003_alter_federationdescendantcontact_entity_and_more.py on lines 42..46
spid_cie_oidc/entity/migrations/0009_trustchain_trust_marks_and_more.py on lines 21..25
spid_cie_oidc/entity/migrations/0017_remove_federationentityconfiguration_jwks_and_more.py on lines 23..26
spid_cie_oidc/relying_party_test/migrations/0002_alter_relyingpartytest_report.py on lines 13..17

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

migrations.AddField(
model_name='federationentityconfiguration',
name='jwks_fed',
field=models.JSONField(default=spid_cie_oidc.entity.models.FederationEntityConfiguration._create_jwks, help_text='a list of private keys for Federation ops'),
spid_cie_oidc/authority/migrations/0003_alter_federationdescendantcontact_entity_and_more.py on lines 26..30
spid_cie_oidc/authority/migrations/0003_alter_federationdescendantcontact_entity_and_more.py on lines 34..38
spid_cie_oidc/authority/migrations/0003_alter_federationdescendantcontact_entity_and_more.py on lines 42..46
spid_cie_oidc/entity/migrations/0009_trustchain_trust_marks_and_more.py on lines 21..25
spid_cie_oidc/entity/migrations/0017_remove_federationentityconfiguration_jwks_and_more.py on lines 18..21
spid_cie_oidc/relying_party_test/migrations/0002_alter_relyingpartytest_report.py on lines 13..17

Function save has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def save(self, *args, **kwargs):
if self.kid:
for jwk in self.entity.jwks_fed:
if not jwk.get('kid', None):
continue
Severity: Minor
Found in spid_cie_oidc/entity/models.py - About 35 mins to fix

Function get_jwks has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def get_jwks(metadata: dict, federation_jwks: list = []) -> dict:
"""
get jwks or jwks_uri or signed_jwks_uri
"""
jwks_list = []
Severity: Minor
Found in spid_cie_oidc/entity/utils.py - About 35 mins to fix

Function string_to_list has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def string_to_list(self, payload, must_list):
for i in must_list:
if isinstance(payload.get(i, None), str):
if ' ' in payload[i]:
payload[i] = payload[i].split(' ')
Severity: Minor
Found in spid_cie_oidc/provider/views/authz_request_view.py - About 35 mins to fix

Function get_token_request has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def get_token_request(self, auth_token, request, token_type):
 
default_logout_url = getattr(
settings, "LOGOUT_REDIRECT_URL", None
) or reverse("spid_cie_rp_landing")
Severity: Minor
Found in spid_cie_oidc/relying_party/views/__init__.py - About 35 mins to fix

Avoid too many return statements within this function.
Open

return JsonResponse(failed_data)
Severity: Major
Found in spid_cie_oidc/authority/views.py - About 30 mins to fix

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

    def create_jwe(plain_dict: Union[dict, str, int, None], jwk_dict: dict, **kwargs) -> str:
    logger.debug(f"Encrypting dict as JWE: " f"{plain_dict}")
    _key = key_from_jwk_dict(jwk_dict)
     
    if isinstance(_key, cryptojwt.jwk.rsa.RSAKey):
    Severity: Minor
    Found in spid_cie_oidc/entity/jwtse.py - About 25 mins to fix

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

    def advanced_entity_listing(request):
    desecendants = FederationDescendant.objects.filter(
    is_active = True,
    ).order_by("-modified")
    entities_list = []
    Severity: Minor
    Found in spid_cie_oidc/authority/views.py - About 25 mins to fix
    Severity
    Category
    Status
    Source
    Language