Skip to content

armgit / AiSOC

Public Imported from GitHub
0

Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.

style(8.1): ruff format the console MFA changes

Beenu Arora83801b8e482f
diff --git a/services/api/app/api/v1/endpoints/mfa.py b/services/api/app/api/v1/endpoints/mfa.py
index 75e30e53d..f039043f5 100644
--- a/services/api/app/api/v1/endpoints/mfa.py
+++ b/services/api/app/api/v1/endpoints/mfa.py
@@ -160,11 +160,7 @@ async def has_webauthn_factor(db: Any, user_id: uuid.UUID) -> bool:
authenticator, splitting the clone-detection control in half.
"""
count = (
- await db.execute(
- text(
- "SELECT count(*) FROM passkey_credentials WHERE user_id = :u AND revoked_at IS NULL"
- ).bindparams(u=user_id)
- )
+ await db.execute(text("SELECT count(*) FROM passkey_credentials WHERE user_id = :u AND revoked_at IS NULL").bindparams(u=user_id))
).scalar()
return bool(count)
@@ -211,9 +207,7 @@ async def roles_requiring_mfa(db: Any, tenant_id: uuid.UUID) -> set[str]:
rows = (
(
await db.execute(
- text(
- "SELECT role FROM aisoc_tenant_mfa_role_policy WHERE tenant_id = :t AND require_mfa IS TRUE"
- ).bindparams(t=tenant_id)
+ text("SELECT role FROM aisoc_tenant_mfa_role_policy WHERE tenant_id = :t AND require_mfa IS TRUE").bindparams(t=tenant_id)
)
)
.mappings()
@@ -866,9 +860,7 @@ async def put_policy(
# role from the console actually clears it. A merge would make the
# page able to add a requirement and never able to remove one.
requested = sorted(set(body.require_for_roles))
- await db.execute(
- text("DELETE FROM aisoc_tenant_mfa_role_policy WHERE tenant_id = :t").bindparams(t=current_user.tenant_id)
- )
+ await db.execute(text("DELETE FROM aisoc_tenant_mfa_role_policy WHERE tenant_id = :t").bindparams(t=current_user.tenant_id))
for role_name in requested:
await db.execute(
text("""
diff --git a/services/api/app/api/v1/endpoints/passkeys.py b/services/api/app/api/v1/endpoints/passkeys.py
index 558a061e3..362c9a550 100644
--- a/services/api/app/api/v1/endpoints/passkeys.py
+++ b/services/api/app/api/v1/endpoints/passkeys.py
@@ -353,8 +353,7 @@ async def webauthn_second_factor_options(db: Any, *, user_id: uuid.UUID, tenant_
options = webauthn.generate_authentication_options(
rp_id=settings.PASSKEY_RP_ID,
allow_credentials=[
- {"id": _b64url_decode(c.credential_id), "type": "public-key", "transports": c.transports or None}
- for c in cred_rows
+ {"id": _b64url_decode(c.credential_id), "type": "public-key", "transports": c.transports or None} for c in cred_rows
],
)
encoded_challenge = await _store_challenge(
diff --git a/services/api/app/auth/sso_provisioning.py b/services/api/app/auth/sso_provisioning.py
index 2cc9484f6..f7b4bdad1 100644
--- a/services/api/app/auth/sso_provisioning.py
+++ b/services/api/app/auth/sso_provisioning.py
@@ -469,9 +469,7 @@ def idp_asserted_multi_factor(authn_methods: list[str] | None) -> bool:
return any(str(method).strip() in MULTI_FACTOR_AUTHN_METHODS for method in (authn_methods or []))
-async def _second_factor_challenge(
- db: AsyncSession, *, tenant_id: Any, user_id: Any, role: str
-) -> dict[str, Any] | None:
+async def _second_factor_challenge(db: AsyncSession, *, tenant_id: Any, user_id: Any, role: str) -> dict[str, Any] | None:
"""The challenge this SSO sign-in still owes, or `None`.
Delegates to the same two helpers `POST /auth/login` uses, so the
@@ -634,9 +632,7 @@ async def complete_sso_login(
# mean a user covered by the policy never gets an account, so the
# administrator enforcing the policy cannot see them to help them.
if not idp_asserted_multi_factor(authn_methods):
- challenge = await _second_factor_challenge(
- db, tenant_id=connection["tenant_id"], user_id=user["id"], role=role
- )
+ challenge = await _second_factor_challenge(db, tenant_id=connection["tenant_id"], user_id=user["id"], role=role)
if challenge is not None:
return {
**challenge,