James main dev 01#327
Closed
lstruman wants to merge 7 commits into
Closed
Conversation
…ogging of sensitive information'" This reverts commit e98851e.
…ogging of sensitive information'" This reverts commit dbb2aad.
…ogging of sensitive information'" This reverts commit f3f60c5.
…ogging of sensitive information'" This reverts commit d1d7181.
…ogging of sensitive information'" This reverts commit df0fb2f.
There was a problem hiding this comment.
Pull request overview
This PR changes logging behavior across the server by removing redaction/sanitization and logging more request/Kafka details (headers, device_id, and Kafka output payloads).
Changes:
- Removed header-key filtering/redaction in
util.HeaderToMap. - Removed sensitive-field sanitization in
common.FilterLogFields. - Expanded Kafka and token-related logs in
http/webconfig_server.goto include previously masked identifiers/payloads.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| util/dict.go | Changes how HTTP headers are converted for logging (now unredacted and can panic on empty header values). |
| http/webconfig_server.go | Logs more Kafka message/device information and changes token/header logging behavior. |
| common/log_fields.go | Changes log field filtering from sanitizing/redacting to mostly pass-through cloning. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
213
to
218
| func HeaderToMap(header http.Header) map[string]string { | ||
| m := make(map[string]string) | ||
| for k, v := range header { | ||
| if !isSafeHeaderKey(k) { | ||
| m[k] = "****" | ||
| continue | ||
| } | ||
| if len(v) == 0 { | ||
| m[k] = "" | ||
| continue | ||
| } | ||
| m[k] = v[0] | ||
| } | ||
| return m |
Comment on lines
1065
to
1067
| if len(m.DeviceId) != 16 { | ||
| log.WithFields(tfields).Warn("invalid device_id") | ||
| log.WithFields(tfields).Warn("invalid device_id " + m.DeviceId) | ||
| continue |
Comment on lines
+1086
to
1088
| tfields["output_key"] = mac | ||
| tfields["output_body"] = m | ||
| log.WithFields(tfields).Info("send") |
Comment on lines
1093
to
1098
| fields := xw.Audit() | ||
| fields["logger"] = "token" | ||
| tfields := common.FilterLogFields(fields) | ||
| delete(tfields, "header") | ||
| var headerMap map[string]string | ||
| var isObfuscated bool | ||
| if itf, ok := tfields["header"]; ok { |
Comment on lines
48
to
66
| func FilterLogFields(src log.Fields, excludes ...string) log.Fields { | ||
| fields := log.Fields{} | ||
| for k, v := range src { | ||
| switch ty := v.(type) { | ||
| case map[string]string: | ||
| fields[k] = maps.Clone(ty) | ||
| case map[string]interface{}: | ||
| fields[k] = maps.Clone(ty) | ||
| case string: | ||
| if slices.Contains(nonEmptyFields, k) { | ||
| if len(ty) > 0 { | ||
| fields[k] = sanitizeLogValue(k, ty) | ||
| fields[k] = ty | ||
| } | ||
| } else { | ||
| fields[k] = sanitizeLogValue(k, ty) | ||
| fields[k] = ty | ||
| } | ||
| case map[string]string: | ||
| fields[k] = sanitizeLogValue(k, maps.Clone(ty)) | ||
| case map[string]interface{}: | ||
| fields[k] = sanitizeLogValue(k, maps.Clone(ty)) | ||
| default: | ||
| fields[k] = sanitizeLogValue(k, ty) | ||
| fields[k] = ty | ||
| } |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
No description provided.