fix(checkoutservice): Option 3 — Centralized dialService helper with enforced TLS#4
Open
mikecstone wants to merge 1 commit into
Open
fix(checkoutservice): Option 3 — Centralized dialService helper with enforced TLS#4mikecstone wants to merge 1 commit into
mikecstone wants to merge 1 commit into
Conversation
Introduces dialService(), a shared helper that wraps grpc.DialContext with TLS credentials (system root CA) and the OpenCensus stats handler. All 8 service connection call sites are replaced with cs.dialService(), removing grpc.WithInsecure() entirely and preventing it from reappearing on future additions. Also fixes context.TODO() -> ctx in convertCurrency. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
OX Security reviewed this pull request — nothing to fix.
Branch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dialService(ctx, addr), a shared helper method oncheckoutServicethat wrapsgrpc.DialContextwith system CA TLS credentials and the OpenCensus stats handlergrpc.DialContext(... grpc.WithInsecure() ...)call sites withcs.dialService(ctx, addr)context.TODO()→ctxinconvertCurrencyTrade-offs
Pros:
cs.dialService()and gets TLS for free; they'd have to actively bypass it to introduce insecure connectionsCons:
Note on the existing TODO comment
main.goline 431 has// TODO: Dial and create client once, reuse.— this PR does not address connection pooling, but thedialServicehelper makes that refactor straightforward in a follow-up.When to use this
Best fit when you want to fix the security issue and clean up the code duplication in the same PR. Recommended as the baseline regardless of whether you later layer mTLS on top.
Test plan
PlaceOrderend-to-end works after the changegrpc.WithInsecure()references remain in the file (grep WithInsecure src/checkoutservice/main.goshould return nothing)dialServiceand not a rawgrpc.DialContext🤖 Generated with Claude Code