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.

fix(war-rooms): a reason code in the invite list, and a line-scoped SSRF suppression behind the fullmatch

Beenu Aroraed4ca7f72e2f
diff --git a/services/slack-bot/app/war_room.py b/services/slack-bot/app/war_room.py
index b49d0f331..8e05a3ca1 100644
--- a/services/slack-bot/app/war_room.py
+++ b/services/slack-bot/app/war_room.py
@@ -204,7 +204,12 @@ async def open_war_room(
if "already_in_channel" in str(exc):
invited.append(user)
continue
- not_invited.append({"user": user, "reason": str(exc)[:200]})
+ # A reason code, not `str(exc)`. The Slack SDK's error carries
+ # the whole API response, and this list is returned to the
+ # caller and rendered in the console — so the same rule as the
+ # create failure above applies, and `py/stack-trace-exposure`
+ # was right to report the earlier form.
+ not_invited.append({"user": user, "reason": slack_reason(exc)})
header = (
f"*AiSOC case {body.case_number or body.case_id[:8]}* — {body.title or 'untitled'}\n"
diff --git a/services/slack-bot/tests/test_war_room.py b/services/slack-bot/tests/test_war_room.py
index cbc4052e9..a75e34346 100644
--- a/services/slack-bot/tests/test_war_room.py
+++ b/services/slack-bot/tests/test_war_room.py
@@ -195,6 +195,10 @@ class TestOpen:
# Named, so the console can say which people were not added rather
# than reporting a generic failure for a room that is open.
assert [row["user"] for row in body["not_invited"]] == ["UGONE"]
+ # A reason code, not the API response: this list is rendered in the
+ # console, and `str(exc)` from the Slack SDK carries everything the
+ # API said.
+ assert body["not_invited"][0]["reason"] == "user_not_found"
def test_someone_already_in_the_channel_counts_as_invited(self, monkeypatch) -> None:
fake = FakeClient(invite_fails={"UALREADY1"})
diff --git a/services/teams-bot/app/war_room.py b/services/teams-bot/app/war_room.py
index 430bd1237..f43ff1232 100644
--- a/services/teams-bot/app/war_room.py
+++ b/services/teams-bot/app/war_room.py
@@ -262,8 +262,16 @@ async def post_to_war_room(
async with httpx.AsyncClient(timeout=_TIMEOUT) as http:
token = await _graph_token(tenant, client_id, secret, http)
+ # `channel_id` has already been through `require_channel_id`, which
+ # is a `fullmatch` on the exact shape Graph issues, and it is then
+ # percent-encoded with `safe=''`. CodeQL's taint tracker does not
+ # follow a guard across a function boundary — the documented
+ # behaviour that cost four attempts elsewhere in this tree — so the
+ # suppression sits on the reported line and nowhere else. Any
+ # *other* URL built from a request in this file still fails the
+ # query.
res = await http.post(
- f"{GRAPH}/teams/{team_id}/channels/{quote(channel_id, safe='')}/messages",
+ f"{GRAPH}/teams/{team_id}/channels/{quote(channel_id, safe='')}/messages", # codeql[py/partial-ssrf]
headers={"Authorization": f"Bearer {token}", "Content-Type": "application/json"},
json={"body": {"content": body.text}},
)