Skip to content

channels: tighten slack-channel-factory mock to be name-aware#94

Merged
mcheemaa merged 1 commit intomainfrom
audit-fix/canonicalize-gateway-signing-secret
Apr 25, 2026
Merged

channels: tighten slack-channel-factory mock to be name-aware#94
mcheemaa merged 1 commit intomainfrom
audit-fix/canonicalize-gateway-signing-secret

Conversation

@mcheemaa
Copy link
Copy Markdown
Member

Summary

Cross-repo audit Finding 1 (2026-04-25) caught a regression that the existing test suite hid: the mock secret fetcher in slack-channel-factory.test.ts returned a hardcoded value for any name the production code requested. That permissive mock masked a real production bug where phantomd's /v1/secrets allowlist did not include slack_gateway_signing_secret, which made SLACK_TRANSPORT=http boot 404 in production.

This PR tightens the test mock so future drift between phantom and phantomd fails CI immediately:

  • Replace the loose secFetcher in every transport=http test with makeSecretFetcher(), a helper that throws fail-loud on any name not in SECRET_RESPONSES. The error message points at phantomd's AllowedSecretNames so an engineer landing a rename knows where to update the other repo.
  • Add an explicit regression test (makeSecretFetcher fails-loud when production asks for an unknown name) that pins the guard itself.
  • Add a cross-repo doc comment in slack-channel-factory.ts near the secFetcher.get(...) calls naming both required secret names and pointing at phantomd's allowlist file.

The companion change on the phantomd side (ghostwright/phantomd PR #9) adds slack_gateway_signing_secret to its allowlist and adds a matching reverse-pointer doc comment. With both PRs merged, drift on either side fails CI on at least one of the two repos.

The production code in slack-channel-factory.ts was already requesting the correct name (slack_gateway_signing_secret); this PR does not change the production fetch.

Changes

  • src/channels/__tests__/slack-channel-factory.test.ts: introduce makeSecretFetcher(tape?) helper; convert all five http-mode tests to use it; add the new fail-loud regression test; add requested.toHaveLength(2) assertion in the parallel-fetch test.
  • src/channels/slack-channel-factory.ts: add a cross-repo invariant doc comment immediately above the Promise.all that fetches the two secrets.

Test plan

  • bun test green: 1930 pass, 0 fail (file count up by 1: 13 to 14 in this file)
  • bun run typecheck clean
  • bun run lint clean
  • Targeted run of slack-channel-factory.test.ts confirms 14 tests pass and the new regression test fails-loud on the legacy name

Audit reference

Finding 1 of local/2026-04-25-cross-repo-audit-report.md (severity: critical, marked as production-breaking for SLACK_TRANSPORT=http).

Base branch note

Targets slack-5b/http-receiver because the file under test does not yet exist on main. After slack-5b/http-receiver merges, this branch can fast-forward into the same merge train.

@mcheemaa mcheemaa changed the base branch from slack-5b/http-receiver to main April 25, 2026 21:06
Cross-repo audit Finding 1 (2026-04-25) found that the existing test
mock returned a hardcoded value regardless of which secret name the
production code requested. That permissive mock hid a real bug:
SLACK_TRANSPORT=http would 404 in production because phantomd's
allowlist did not include slack_gateway_signing_secret.

Fix: replace the loose secFetcher in every transport=http test with
makeSecretFetcher(), a helper that throws fail-loud on any name not
in SECRET_RESPONSES. The error message points at phantomd's
AllowedSecretNames map so a future divergence between the two
repos surfaces in CI instead of in production logs.

Adds an explicit regression test (makeSecretFetcher fails-loud when
production asks for an unknown name) so the guard itself is pinned.
Adds a cross-repo doc comment in slack-channel-factory.ts pointing
at phantomd's allowlist; phantomd's matching commit adds the
reverse pointer.

Refs: phantomd audit-fix/canonicalize-gateway-signing-secret
@mcheemaa mcheemaa force-pushed the audit-fix/canonicalize-gateway-signing-secret branch from 2858c9e to fc7178e Compare April 25, 2026 21:07
@mcheemaa mcheemaa merged commit db56e93 into main Apr 25, 2026
1 check passed
@mcheemaa mcheemaa deleted the audit-fix/canonicalize-gateway-signing-secret branch April 25, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant