Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(signals): redact webhook URLs from scout project profile names (#93899)

posthog[bot]67b7bce5b73b
diff --git a/products/alerts/backend/destinations.py b/products/alerts/backend/destinations.py
index 2458e317ab2d..4038cd67c393 100644
--- a/products/alerts/backend/destinations.py
+++ b/products/alerts/backend/destinations.py
@@ -332,9 +332,13 @@ def count_active_alert_destinations(*, team_id: int, alert_id: str, allowed_even
# Webhook-style destination names embed the full webhook URL, whose path is a channel
-# credential (Slack/Discord/Teams webhook secret). Receipts flow into the API and the
-# History tooltip, so keep only the host.
-_URL_IN_NAME_RE = re.compile(r"\b[a-z][a-z0-9+.-]*://\S+", re.IGNORECASE)
+# credential (Slack/Discord/Teams webhook secret). Anything that shows such a name — a
+# receipt in the API, the History tooltip, or a read surface in another product — must
+# keep only the host.
+# No leading word boundary: a scheme glued to a word character (`hook_https://…`) is still
+# a URL, and skipping it would leave the credential in the name. The match ends on a
+# non-punctuation character, so a bracket or comma after the URL stays in the text.
+_URL_IN_NAME_RE = re.compile(r"[a-zA-Z][a-zA-Z0-9+.\-]*://[^\s'\"]*[^\s'\".,;:!?)\]}>]")
_DESTINATION_NAME_SEPARATOR = " → "
@@ -347,7 +351,8 @@ def _url_host(match: re.Match[str]) -> str:
return "destination"
-def _receipt_safe_name(name: str) -> str:
+def redact_urls_in_name(name: str) -> str:
+ """Replace every URL in a free-text name with its host."""
return _URL_IN_NAME_RE.sub(_url_host, name)
@@ -355,7 +360,7 @@ def _destination_display_name(name: str) -> str:
# Names read "<product> — <alert> (<kind>) → <destination>"; keep the trailing
# segment. rpartition, since an alert name may contain the separator too.
_, _, destination = name.rpartition(_DESTINATION_NAME_SEPARATOR)
- return _receipt_safe_name(destination or name)
+ return redact_urls_in_name(destination or name)
def list_active_alert_destinations(
diff --git a/products/alerts/backend/facade/api.py b/products/alerts/backend/facade/api.py
index e6a3531d7093..0a75f1c6c12f 100644
--- a/products/alerts/backend/facade/api.py
+++ b/products/alerts/backend/facade/api.py
@@ -28,6 +28,7 @@ from products.alerts.backend.destinations import (
create_alert_destination_hog_functions,
list_alert_destination_groups,
owned_alert_destinations_qs,
+ redact_urls_in_name,
soft_delete_alert_destinations,
soft_delete_alert_destinations_for_alerts,
soft_delete_all_alert_destinations,
@@ -219,6 +220,7 @@ __all__ = [
"insight_ids_with_alerts",
"list_alert_destination_groups",
"owned_alert_destinations_qs",
+ "redact_urls_in_name",
"serialize_insight_alerts",
"snooze_alert_from_slack",
"soft_delete_alert_destinations",
diff --git a/products/alerts/backend/test/test_destinations.py b/products/alerts/backend/test/test_destinations.py
index 279ace9901c7..4af8743e0d9a 100644
--- a/products/alerts/backend/test/test_destinations.py
+++ b/products/alerts/backend/test/test_destinations.py
@@ -28,6 +28,7 @@ from products.alerts.backend.destinations import (
alert_internal_event_delivered,
group_alert_destination_rows,
list_active_alert_destinations,
+ redact_urls_in_name,
serialize_deliveries,
soft_delete_alert_destinations,
soft_delete_all_alert_destinations,
@@ -730,6 +731,24 @@ class TestListActiveAlertDestinations(AlertDestinationTestCase):
assert [d.name for d in destinations] == ["Webhook discord.com"]
+class TestRedactUrlsInName:
+ @parameterized.expand(
+ [
+ # A scheme glued to a word character used to skip the match entirely, leaving the
+ # credential path in a name any read surface then showed.
+ ("scheme_glued_to_a_word_character", "hook_https://hooks.example.com/p/s3cr3t", "hook_hooks.example.com"),
+ ("punctuation_after_the_url_survives", "Docs (https://example.com/p/s3cr3t)", "Docs (example.com)"),
+ (
+ "every_url_in_the_name_is_redacted",
+ "a https://one.example.com/s, b https://two.example.com/s",
+ "a one.example.com, b two.example.com",
+ ),
+ ]
+ )
+ def test_redacts_a_url_to_its_host(self, _name: str, name: str, expected: str) -> None:
+ assert redact_urls_in_name(name) == expected
+
+
class TestSerializeDeliveries(APIBaseTest):
def test_serialize_deliveries_roundtrips_dataclass_fields(self) -> None:
delivery = AlertDelivery(channel="email", target="[email protected]", at="2026-08-11T00:00:00+00:00")
diff --git a/products/signals/backend/scout_harness/profile/builders.py b/products/signals/backend/scout_harness/profile/builders.py
index 65ae5f5cad5a..815d904f4321 100644
--- a/products/signals/backend/scout_harness/profile/builders.py
+++ b/products/signals/backend/scout_harness/profile/builders.py
@@ -44,6 +44,7 @@ from posthog.models.product_intent.product_intent import ProductIntent
from posthog.models.team.team import Team
from products.actions.backend.models.action import Action
+from products.alerts.backend.facade.api import redact_urls_in_name
from products.alerts.backend.models.alert import AlertConfiguration
from products.business_knowledge.backend.models.constants import SourceStatus
from products.business_knowledge.backend.models.knowledge_source import KnowledgeSource
@@ -73,8 +74,9 @@ logger = logging.getLogger(__name__)
# Bumps when the inventory schema changes meaningfully — `get_project_profile` invalidates
# rows whose `source_version` doesn't match the current build, so adding a new key here
# (or restructuring an existing one) without bumping the version would silently mix old
-# and new shapes in the cache.
-INVENTORY_SOURCE_VERSION = "v12"
+# and new shapes in the cache. A redaction change bumps it too, so rows built before the
+# redaction stop being served.
+INVENTORY_SOURCE_VERSION = "v13"
# Top-events ClickHouse query bounds. 7d is short enough to spot recent bursts and long
# enough to stabilize counts on low-traffic teams; 50 covers the long tail without
@@ -581,7 +583,7 @@ def _recent_alerts(team: Team) -> dict[str, Any]:
"recent": [
{
"id": str(row["id"]),
- "name": row["name"] or "",
+ "name": redact_urls_in_name(row["name"] or ""),
"enabled": row["enabled"],
"state": row["state"],
"calculation_interval": row["calculation_interval"],
@@ -599,6 +601,10 @@ def _recent_hog_functions(team: Team) -> dict[str, Any]:
`type` discriminates destinations vs transformations vs site apps — the agent
pattern-matches on it to decide whether activity is "data plumbing" or "user
surface" work.
+
+ An alert destination is a hog function whose name embeds the full webhook URL, so a
+ name can carry a live channel credential in its path or query. The profile goes into
+ an agent context, so each name keeps only its host.
"""
qs = HogFunction.objects.filter(team=team, deleted=False)
total = qs.count()
@@ -612,7 +618,7 @@ def _recent_hog_functions(team: Team) -> dict[str, Any]:
"recent": [
{
"id": str(row["id"]),
- "name": row["name"] or "",
+ "name": redact_urls_in_name(row["name"] or ""),
"type": row["type"],
"kind": row["kind"],
"enabled": row["enabled"],
diff --git a/products/signals/backend/test/test_scout_harness_profile.py b/products/signals/backend/test/test_scout_harness_profile.py
index 8d9759394bfe..ff70eca0d509 100644
--- a/products/signals/backend/test/test_scout_harness_profile.py
+++ b/products/signals/backend/test/test_scout_harness_profile.py
@@ -591,6 +591,15 @@ class TestRecentAlerts(BaseTest):
result = _recent_alerts(self.team)
assert [r["name"] for r in result["recent"]] == ["second", "first"]
+ def test_redacts_a_url_embedded_in_the_name(self) -> None:
+ AlertConfiguration.objects.create(
+ team=self.team,
+ insight=self._insight("a"),
+ name="Paging https://hooks.example.com/services/T0/B0/s3cr3t",
+ )
+ row = _recent_alerts(self.team)["recent"][0]
+ assert row["name"] == "Paging hooks.example.com"
+
def test_team_isolated(self) -> None:
other = self.organization.teams.create(name="other")
AlertConfiguration.objects.create(team=other, insight=Insight.objects.create(team=other, name="i"), name="x")
@@ -616,6 +625,20 @@ class TestRecentHogFunctions(BaseTest):
assert row["type"] == "destination"
assert row["kind"] == "webhook"
+ def test_redacts_a_webhook_url_embedded_in_the_name(self) -> None:
+ # An alert destination is named "<product> — <alert> (<kind>) → Webhook <url>",
+ # and the URL path and query hold the channel credential.
+ HogFunction.objects.create(
+ team=self.team,
+ name="Error tracking — Checkout errors (issue created) → Webhook "
+ "https://hooks.example.com/services/T0/B0/s3cr3t?token=s3cr3t",
+ enabled=True,
+ type="destination",
+ hog="",
+ )
+ row = _recent_hog_functions(self.team)["recent"][0]
+ assert row["name"] == "Error tracking — Checkout errors (issue created) → Webhook hooks.example.com"
+
def test_team_isolated(self) -> None:
other = self.organization.teams.create(name="other")
HogFunction.objects.create(team=other, name="x", enabled=True, type="destination", hog="")