-
Notifications
You must be signed in to change notification settings - Fork 39
GH#3605: fix critical quality-debt from PR #796 review — unsafe echo -e in supervisor log functions #4369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH#3605: fix critical quality-debt from PR #796 review — unsafe echo -e in supervisor log functions #4369
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -28,30 +28,32 @@ db() { | |||||||
|
|
||||||||
| ####################################### | ||||||||
| # Structured logging functions | ||||||||
| # All output to stderr with color-coded prefixes | ||||||||
| # All output to stderr with color-coded prefixes. | ||||||||
| # Uses printf to safely handle arbitrary message content (avoids echo -e | ||||||||
| # interpreting backslash sequences in $* and word-splitting on unquoted args). | ||||||||
| ####################################### | ||||||||
| log_info() { | ||||||||
| echo -e "${BLUE}[SUPERVISOR]${NC} $*" >&2 | ||||||||
| printf "%b %s\n" "${BLUE}[SUPERVISOR]${NC}" "$*" >&2 | ||||||||
| return 0 | ||||||||
| } | ||||||||
|
|
||||||||
| log_success() { | ||||||||
| echo -e "${GREEN}[SUPERVISOR]${NC} $*" >&2 | ||||||||
| printf "%b %s\n" "${GREEN}[SUPERVISOR]${NC}" "$*" >&2 | ||||||||
| return 0 | ||||||||
|
Comment on lines
+41
to
42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency and robustness, consider adding
Suggested change
References
|
||||||||
| } | ||||||||
|
|
||||||||
| log_warn() { | ||||||||
| echo -e "${YELLOW}[SUPERVISOR]${NC} $*" >&2 | ||||||||
| printf "%b %s\n" "${YELLOW}[SUPERVISOR]${NC}" "$*" >&2 | ||||||||
| return 0 | ||||||||
|
Comment on lines
+46
to
47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency and robustness, consider adding
Suggested change
References
|
||||||||
| } | ||||||||
|
|
||||||||
| log_error() { | ||||||||
| echo -e "${RED}[SUPERVISOR]${NC} $*" >&2 | ||||||||
| printf "%b %s\n" "${RED}[SUPERVISOR]${NC}" "$*" >&2 | ||||||||
| return 0 | ||||||||
|
Comment on lines
+51
to
52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency and robustness, consider adding
Suggested change
References
|
||||||||
| } | ||||||||
|
|
||||||||
| log_verbose() { | ||||||||
| [[ "${SUPERVISOR_VERBOSE:-}" == "true" ]] && echo -e "${BLUE}[SUPERVISOR]${NC} $*" >&2 || true | ||||||||
| [[ "${SUPERVISOR_VERBOSE:-}" == "true" ]] && printf "%b %s\n" "${BLUE}[SUPERVISOR]${NC}" "$*" >&2 || true | ||||||||
| return 0 | ||||||||
| } | ||||||||
|
|
||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For improved robustness, consider adding
|| trueto theprintfcommand. This prevents the script from exiting on a logging failure (e.g., a broken pipe on stderr) whenset -eis active. This change also makes the explicitreturn 0redundant, as the command will always succeed.References
set -eis active, using|| truefor non-critical commands like logging prevents the script from exiting prematurely on minor failures (e.g., broken pipe), ensuring robustness.