Skip to content

Commit

Permalink
Check dynamic imports with whitelist
Browse files Browse the repository at this point in the history
  • Loading branch information
fzumstein committed Feb 26, 2025
1 parent ab977aa commit bde483e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ async def authenticate(
)
else:
provider = auth_provider
# Validate the provider before import to prevent non-literal-import SAST flagging
if provider not in settings.auth_providers:
raise ValueError(f"Unsupported authentication provider: {provider}")
try:
module = importlib.import_module(f"app.auth.{provider}")
current_user = await module.validate_token(token_string)
Expand Down

0 comments on commit bde483e

Please sign in to comment.