Skip to content

feat(security): show which platforms feed the audit log and how to connect more - #2724

Merged
Makisuo merged 2 commits into
mainfrom
t3/improve-service-ingestion-discovery
Nov 16, 2026
Merged

Makisuo merged 2 commits into
mainfrom
t3/improve-service-ingestion-discovery

Conversation

@Makisuo

@Makisuo Makisuo commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Why

The audit log gave no hint of what feeds it: which platforms send events, whether each one is sending, or what else can be connected.

What changed

  • Sources panel above the event list. It lists every platform that can feed the log (Maple, Vercel, Google Cloud). Each row shows what the platform sends, the connected account, its state, the event count over the last 30 days, and one action:
    • States: Built in, Receiving, No events yet, Audit feed off, Failing (shows the integration's own error), Not connected.
    • Actions: "Connect" when the platform isn't connected, "Turn on" when its audit feed is off, "Open integration" when the feed is failing, and "View events" when it's sending. "View events" filters the list to that platform.
    • The header counts how many are sending, e.g. "2 of 3 sending · last 30 days".
  • Platform logos next to the platform name in the event list and in an expanded event's details.
  • API: a new admin-only endpoint, GET /internal/audit-trail/sources, which needs audit_log:read.
    • It reads per-platform event counts and the latest event time for the last 30 days (a new auditTrailSourcesQuery, filtered by org) and checks them against the integration inventory.
    • Vercel counts as on when its "audit log" drain is installed. Google Cloud counts as on when log forwarding is on, because audit logs arrive through the log sink.
    • If the inventory can't be read, the endpoint still returns what arrived, and connectable platforms read as receiving or waiting.
    • Platforms a newer writer adds still show, so their events are never unaccounted for.

Screenshots

From the lab page (/lab/security?state=audit-log and audit-log-empty).

Before After

Empty org: every platform with its Connect button.

Before After

Phone:

Before After

Notes

  • Google Cloud and Vercel need the production switch. Their audit rows are stored only once INGEST_AUDIT_TRAIL_ENABLED is on in production. The API can't see that switch, so until it's on, a correctly set-up feed shows "No events yet".
  • GitHub and Cloudflare aren't listed yet. Adding them needs a GitHub App permission change and a new Cloudflare OAuth scope.

Tests

  • New unit tests for how each platform's state is worked out (6).
  • New route tests for the endpoint: 403 for non-admins, the admin response, and the inventory-down fallback (3, all 19 in the file pass).
  • New page tests for the panel's links, header and filter (3, all 31 pass).
  • The SQL catalog baseline is regenerated. The OpenAPI and UI-pattern checks pass.
  • CI lint is clean on every changed file, checked after merging main.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Devin Review

…nnect more

A Sources panel above the audit log lists Maple, Vercel and Google Cloud with
their state (built in, receiving, no events yet, feed off, failing, not
connected), 30 day event counts and the action to connect or turn each on.
Events now show each platform's mark. Backed by GET /internal/audit-trail/sources,
which reads per-platform counts against the integration inventory.
@Makisuo Makisuo added the preview:web Deploy a Workers-only PR preview (no ingest/Electric); see docs/pr-previews.md label Nov 16, 2026
@maple-review-bot

maple-review-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Maple review

🟢 Confidence 10/10 · safe to merge. State derivation, the route and the panel are pinned by tests, and the org filter is on the new query; only two cosmetic UI defects were found.
2 notes · tests covered · risk medium · 3/3 new units observable

Adds a Sources panel to the audit log that lists each feeding platform with its state and one action, plus a new admin-only GET /internal/audit-trail/sources endpoint that joins 30-day per-platform event counts against the integration inventory. Safe to merge; the findings are copy and accessible-name polish.

  • auditTrailSources derives each platform's state from event counts and the inventory
  • GET /audit-trail/sources counts events per provider over 30 days
  • The audit log page reads sources alongside the first page and shows the panel
  • Events and event details render the platform's logo

Before merge

  • Manual · Confirm INGEST_AUDIT_TRAIL_ENABLED is on in prd, or Vercel and Google Cloud rows read "No events yet"

Findings

🔵 Note · F1 · Sources failure line points at a retry the page does not show

correctness · apps/web/src/page/security/audit-log/view-sources.ts:172

"Try again from the list below" only exists when the list itself failed: the sole control sending Message.ClickedRetry renders inside the first page's failure state (view.ts:446). When the events load and only providerStats fails, the reader is sent to a retry that is not on the page.

				"Couldn't load which platforms feed the audit log.",
🔵 Note · F2 · Turn on and Open integration links repeat one accessible name across rows

correctness · apps/web/src/page/security/audit-log/view-sources.ts:120-123

With both connectable platforms off — the state a new org opens on — two rows carry links whose accessible name is only "Turn on" (and two "Open integration" when both fail), each going to a different platform's setup. Connect ${name} and the View events AriaLabel show the intended pattern.

	if (source.state === "off" || source.state === "failing")
		return linkButton(
			h,
			{
				variant: "outline",
				size: "sm",
				href: setupHref(source.provider),
				attributes: [h.AriaLabel(`${source.state === "off" ? "Turn on" : "Open"} ${name}'s audit feed`)],
			},
			[source.state === "off" ? "Turn on" : "Open integration"],
		)
🤖 Prompt to fix all 2 findings with an AI agent
Findings from an automated review of commit 4f3270ffc211203a3871c4f43c8801e733c0937d. Verify each one against the current code before changing anything, fix only those that still apply, and keep each fix to the lines it names.

---

F1 · Note · correctness · apps/web/src/page/security/audit-log/view-sources.ts:172
Sources failure line points at a retry the page does not show
"Try again from the list below" only exists when the list itself failed: the sole control sending `Message.ClickedRetry` renders inside the first page's failure state (`view.ts:446`). When the events load and only `providerStats` fails, the reader is sent to a retry that is not on the page.
Replace those lines with:
				"Couldn't load which platforms feed the audit log.",

---

F2 · Note · correctness · apps/web/src/page/security/audit-log/view-sources.ts:120-123
`Turn on` and `Open integration` links repeat one accessible name across rows
With both connectable platforms off — the state a new org opens on — two rows carry links whose accessible name is only "Turn on" (and two "Open integration" when both fail), each going to a different platform's setup. `Connect ${name}` and the `View events` `AriaLabel` show the intended pattern.
Replace those lines with:
	if (source.state === "off" || source.state === "failing")
		return linkButton(
			h,
			{
				variant: "outline",
				size: "sm",
				href: setupHref(source.provider),
				attributes: [h.AriaLabel(`${source.state === "off" ? "Turn on" : "Open"} ${name}'s audit feed`)],
			},
			[source.state === "off" ? "Turn on" : "Open integration"],
		)

4f3270f · What was checked, coverage and telemetry details are on the Maple / review check. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@Makisuo
Makisuo merged commit 90a9d82 into main Nov 16, 2026
41 of 45 checks passed
@Makisuo
Makisuo deleted the t3/improve-service-ingestion-discovery branch November 16, 2026 17:54

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

Comment on lines +120 to +123
if (source.state === "off" || source.state === "failing")
return linkButton(h, { variant: "outline", size: "sm", href: setupHref(source.provider) }, [
source.state === "off" ? "Turn on" : "Open integration",
])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Google Cloud repair actions open onboarding

For connected Google Cloud accounts, setupHref sends “Turn on” and “Open integration” to new-connection onboarding. enterGcp initializes a New target, so neither action edits or repairs the existing connection.

Learn more

Google Cloud uses a dedicated creation flow on the new-source page. Its entry handler initializes a New target, and flowConnector does not resolve existing connections for that target. The flow therefore presents creation fields rather than the existing connection's settings or setup.

Example: An admin has connected project acme-prod with metrics enabled and logs disabled. The audit log shows “Audit feed off.” Clicking “Turn on” asks the admin to create a connection; entering acme-prod again fails because that scope already exists.

Recommended fix: Keep new-source onboarding for disconnected platforms. For connected Google Cloud accounts, link to the existing source's Connection tab, using the existing sourceHref routing pattern. Expose the necessary source identity in the response, or route to a connected-source selector when several scopes exist. Cover both off and failing states with navigation tests.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +170 to +173
onFailure: () =>
typography(h, { size: "xs", tone: "muted", as: "p" }, [
"Couldn't load which platforms feed the audit log. Try again from the list below.",
]),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Sources failures lack a retry control

When sources fail but events load, sourcesPanel directs users to a retry control that does not exist. listBody exposes ClickedRetry only when events fail, leaving sources unavailable until page re-entry or reload.

Learn more

The sources and event list load independently. The retry handler refreshes both, but the event list renders its retry control only on failure. The page's subscription only updates the clock, so it does not recover a failed sources request.

Example: The sources endpoint returns 503 during a transient warehouse failure while the events endpoint returns 200. After the warehouse recovers, the page still displays the sources failure and offers no retry button.

Recommended fix: Render a retry control alongside the sources failure, wired to Message.ClickedRetry(), or add a sources-only retry message and command. Add a scene test with successful events and failed sources that activates the retry and verifies a new sources request.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🍁 Maple PR preview

Note

Preview resources were removed when this pull request closed.

Final commit 4f3270f · View workflow run

@maple-review-bot

Copy link
Copy Markdown

Merged with 1 step from "Before merge" still open. If it is done, tick it on the review comment; if not, now is the time.

  • Manual · Confirm INGEST_AUDIT_TRAIL_ENABLED is on in prd, or Vercel and Google Cloud rows read "No events yet"

@Makisuo
Makisuo deployed to pr-preview November 16, 2026 17:54 — with GitHub Actions Active

This branch was successfully deployed

1 active deployment
pr-preview — 4f3270ff Deployed Nov 16, 2026 by Makisuo via deploy-pr-preview #13049
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview:web Deploy a Workers-only PR preview (no ingest/Electric); see docs/pr-previews.md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant