fixed dependabot code smells - #491
Merged
Merged
Conversation
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
This pull request addresses several security vulnerabilities and improves logging practices across multiple services. The changes focus on preventing log injection attacks by sanitizing user-controlled data before logging, redacting sensitive information (passwords, header values) from logs, avoiding the exposure of raw request/response bodies in logs, and hardening path traversal protections. Additionally, minor Go style improvements (e.g., removing blank identifiers in range loops) are included.
Files Changed
📄
app2job/app.goImproves the
Handlerfunction with two security fixes: removes the raw URL path from the bad-path error response to prevent XSS, and adds input validation that rejects job definition names containing characters outside of alphanumerics, hyphens, and underscores, guarding against injection attacks.📄
cos-event/cos-listen.goReplaces logging of the raw HTTP request body with a byte count summary (
%d bytes received) to avoid exposing potentially sensitive payload data in logs.📄
cron/cron.goRedacts HTTP header values from logs (replacing them with
[REDACTED]) to prevent leaking sensitive data such as authorization tokens. Also replaces raw body logging with a byte count. Removes the unused blank identifier in therangeloop as a minor style cleanup.📄
github/github.goAdds the
stringsimport and appliesstrings.ReplaceAllto sanitize newline characters from user-controlled fields (eventType, event body JSON, pusher name, commit SHA, and ref) before logging, preventing log injection attacks. Raw event body is also removed from the JSON parse error log to avoid leaking sensitive data.📄
kafka/receiver.goRedacts HTTP header values in logs, replacing them with
[REDACTED], and replaces raw event body logging with a byte count to prevent sensitive data exposure. Removes the blank identifier from therangeloop as a minor style fix. Also corrects a typo in a comment (headrs→headers).📄
kafka/sender.goRedacts the Kafka password from logs entirely (replacing a partial reveal with
[REDACTED]). Sanitizes the Kafka topic name by stripping newline characters before logging to prevent log injection.📄
thumbnail/eventer/eventer.goSanitizes
objectNameandbucketNameby stripping newline characters before logging throughout the file to prevent log injection. Replaces raw event body logging with a byte count. Fixes an incorrect use oflog.Print(which does not support format verbs) tolog.Printf.📄
thumbnail/v1/app.goSanitizes the URL path before logging by stripping newline characters. Strengthens the path traversal check by also rejecting paths containing
/(subdirectory access), and removes the raw path value from the error response to prevent information leakage. Replaces the deprecatedstrings.Indexcheck with the more idiomaticstrings.Contains.📄
thumbnail/v2/app.goMirrors the path traversal hardening from
v1/app.go: strips the leading/upfront, rejects paths containing..or/, removes the raw path from the error response, and eliminates the redundant inline strip in theos.ReadFilecall. Replacesstrings.Indexwithstrings.Contains.📄
websocket/server.goReplaces logging of raw WebSocket message content with a byte count (
%d bytes) to avoid exposing potentially sensitive message data in server logs.