fix(erpc:PLA-1611): redact grpc and remote cache secrets#95
Open
0x666c6f wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR tightens secret redaction across two “admin/startup/logging” surfaces: gRPC upstream header configs when marshaled to JSON/YAML, and remote-cache keys in async refresh failure/panic logs.
Changes:
- Redact
GrpcUpstreamConfig.Headersvalues during JSON/YAML marshaling. - Redact
RemoteDataCacheasync refreshcacheKeyin warning/panic logs. - Add regression tests covering gRPC config redaction and remote-cache refresh-failure logging.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
thirdparty/remote_cache.go |
Redacts logged cacheKey using util.RedactEndpoint in async refresh error/panic logs. |
thirdparty/remote_cache_test.go |
Adds regression test asserting refresh-failure logs don’t leak raw cache keys/secrets. |
common/config.go |
Adds custom JSON/YAML marshaling for GrpcUpstreamConfig to redact header values. |
common/config_redaction_test.go |
Adds tests asserting gRPC headers + endpoint secrets are redacted across JSON/Sonic/YAML outputs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+17
to
+40
| prevLevel := zerolog.GlobalLevel() | ||
| zerolog.SetGlobalLevel(zerolog.WarnLevel) | ||
| defer zerolog.SetGlobalLevel(prevLevel) | ||
|
|
||
| var logs bytes.Buffer | ||
| logger := zerolog.New(&logs) | ||
| cache := NewRemoteDataCache[string]("quicknode") | ||
| cacheKey := "https://example.quiknode.pro/raw-provider-secret/evm?apiKey=provider-api-key" | ||
| fetchCalled := make(chan struct{}) | ||
|
|
||
| cache.TriggerAsyncRefresh(&logger, cacheKey, func(ctx context.Context) (string, error) { | ||
| close(fetchCalled) | ||
| return "", errors.New("refresh failed") | ||
| }) | ||
|
|
||
| select { | ||
| case <-fetchCalled: | ||
| case <-time.After(time.Second): | ||
| t.Fatal("fetcher was not called") | ||
| } | ||
|
|
||
| require.Eventually(t, func() bool { | ||
| return strings.Contains(logs.String(), "vendor remote-data refresh failed") | ||
| }, time.Second, 10*time.Millisecond) |
Comment on lines
+1210
to
+1225
| func (c *GrpcUpstreamConfig) MarshalJSON() ([]byte, error) { | ||
| type grpcUpstreamConfigJSON struct { | ||
| Headers map[string]string `json:"headers,omitempty"` | ||
| } | ||
| return sonic.Marshal(grpcUpstreamConfigJSON{ | ||
| Headers: redactHeaderValues(c.Headers), | ||
| }) | ||
| } | ||
|
|
||
| func (c *GrpcUpstreamConfig) MarshalYAML() (interface{}, error) { | ||
| out := make(map[string]interface{}) | ||
| if len(c.Headers) > 0 { | ||
| out["headers"] = redactHeaderValues(c.Headers) | ||
| } | ||
| return out, nil | ||
| } |
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
Validation
go test ./common ./thirdpartygo test -race ./thirdpartymake agent-gateblocked locally by rootless Docker not found in container-backed tests.Linear