From 979daf76214d1fa9fdbf3e5ebebe154d2c579073 Mon Sep 17 00:00:00 2001 From: Lucas ONeil Date: Wed, 11 Sep 2024 12:24:05 -0700 Subject: [PATCH] codeql Signed-off-by: Lucas ONeil --- oidc-controller/api/routers/oidc.py | 6 ++++-- oidc-controller/api/verificationConfigs/helpers.py | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/oidc-controller/api/routers/oidc.py b/oidc-controller/api/routers/oidc.py index 88a4acbc..dc42807a 100644 --- a/oidc-controller/api/routers/oidc.py +++ b/oidc-controller/api/routers/oidc.py @@ -128,14 +128,16 @@ async def get_authorize(request: Request, db: Database = Depends(get_db)): # Create presentation_request to show on screen try: - # Create presentation_request to show on screen response = client.create_presentation_request( ver_config.generate_proof_request() ) except VariableSubstitutionError as e: return JSONResponse( status_code=http_status.HTTP_400_BAD_REQUEST, - content={"detail": str(e)}, + content={ + "detail": f"Variable substitution error: \ +'{e.variable_name}' not found in substitution map." + }, ) pres_exch_dict = response.dict() diff --git a/oidc-controller/api/verificationConfigs/helpers.py b/oidc-controller/api/verificationConfigs/helpers.py index f577b066..a60de98b 100644 --- a/oidc-controller/api/verificationConfigs/helpers.py +++ b/oidc-controller/api/verificationConfigs/helpers.py @@ -4,7 +4,9 @@ class VariableSubstitutionError(Exception): """Custom exception for if a variable is used that does not exist.""" - pass + def __init__(self, variable_name: str): + self.variable_name = variable_name + super().__init__(f"Variable '{variable_name}' not found in substitution map.") def replace_proof_variables(proof_req_dict: dict) -> dict: @@ -35,9 +37,7 @@ def replace_proof_variables(proof_req_dict: dict) -> dict: if v in variable_substitution_map: proof_req_dict[k] = variable_substitution_map[v]() else: - raise VariableSubstitutionError( - f"Variable '{v}' not found in substitution map." - ) + raise VariableSubstitutionError(v) # Base case: If the value is not a dict, list, or matching string, do nothing return proof_req_dict