-
Notifications
You must be signed in to change notification settings - Fork 83
fix(observability): redact sensitive data from logs #2802
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
base: main
Are you sure you want to change the base?
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 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,13 +24,11 @@ export function collectFullErrorStack(error: string | Error | AggregateError | E | |||||||||||||||||
| const requestedPath = currentError.response.config?.url | ||||||||||||||||||
| ? `${currentError.response.config.method?.toUpperCase() || "(HTTP method not specified)"} ${currentError.response.config?.url}` | ||||||||||||||||||
| : "Unknown request"; | ||||||||||||||||||
|
Comment on lines
24
to
26
Contributor
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. 🧩 Analysis chain🏁 Script executed: # First, examine the target file to see the full context around lines 24-26
head -40 packages/logging/src/utils/collect-full-error-stack/collect-full-error-stack.ts | cat -nRepository: akash-network/console Length of output: 1898 🏁 Script executed: # Search for query string stripping patterns in the logging package
rg -n 'split.*\?|stripQuery|removeQuery|URL.*query' packages/logging/ --type ts -C2Repository: akash-network/console Length of output: 1040 🏁 Script executed: # Check for any URL sanitization utilities in the codebase
fd -e ts -e js packages/logging/ | xargs grep -l "sanitize.*url\|stripQuery\|removeQuery" 2>/dev/null || echo "No sanitization utils found"Repository: akash-network/console Length of output: 483 🏁 Script executed: # Search broadly for URL query parameter handling in the entire codebase
rg -n 'split\("?\?\)' --type ts --type tsx | head -20Repository: akash-network/console Length of output: 92 🏁 Script executed: # Check if there are any PR objectives or documentation files
find . -maxdepth 3 -name "*.md" -o -name "OBJECTIVES*" -o -name "PHASE*" | head -10Repository: akash-network/console Length of output: 441 🏁 Script executed: # Check if stripQueryParams is exported from http-logger.service.ts
cat -n packages/logging/src/hono/http-logger/http-logger.service.ts | head -50Repository: akash-network/console Length of output: 1729 🏁 Script executed: # Check if there's a shared utils or utilities directory for logging functions
fd -type f -name "*.ts" packages/logging/src/utils/ | head -20Repository: akash-network/console Length of output: 235 🏁 Script executed: # Look for any exports or re-exports in the logging package index files
find packages/logging/src -name "index.ts" -o -name "index.js" | xargs cat 2>/dev/nullRepository: akash-network/console Length of output: 311 🏁 Script executed: # Check git history/context - when was collect-full-error-stack added vs http-logger
git log --oneline --all -- packages/logging/src/utils/collect-full-error-stack/collect-full-error-stack.ts packages/logging/src/hono/http-logger/http-logger.service.ts 2>/dev/null | head -10Repository: akash-network/console Length of output: 744 URL query strings should be stripped before logging to prevent sensitive data exposure. Lines 24-26 log the URL as-is, which may contain sensitive query parameters like tokens or API keys. A ♻️ Suggested implementation- const requestedPath = currentError.response.config?.url
- ? `${currentError.response.config.method?.toUpperCase() || "(HTTP method not specified)"} ${currentError.response.config?.url}`
+ const rawUrl = currentError.response.config?.url;
+ const sanitizedUrl = rawUrl ? rawUrl.split("?")[0] : undefined;
+ const requestedPath = sanitizedUrl
+ ? `${currentError.response.config.method?.toUpperCase() || "(HTTP method not specified)"} ${sanitizedUrl}`
: "Unknown request";📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| const body = currentError.response.data ? JSON.stringify(currentError.response.data) : "No body"; | ||||||||||||||||||
| stack.push( | ||||||||||||||||||
| "\nResponse:", | ||||||||||||||||||
| `\nRequest: ${requestedPath}`, | ||||||||||||||||||
| `\nStatus: ${currentError.response.status}`, | ||||||||||||||||||
| `\nError: ${sanitizeString(currentError.response.data?.message) || "Not specified"} (code: ${currentError.response.data?.code || "Not specified"})`, | ||||||||||||||||||
| `\nBody: ${body.length > 200 ? `${body.slice(0, 200)}...` : body}` | ||||||||||||||||||
| `\nError: ${sanitizeString(currentError.response.data?.message) || "Not specified"} (code: ${currentError.response.data?.code || "Not specified"})` | ||||||||||||||||||
| ); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
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.
issue(blocking): without the cause we will not know the underlying issue. SO, when you receive this error in grafana, you won't be able to act.
Uh oh!
There was an error while loading. Please reload this page.
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.
We should tackle this from a different angle. Like understand what sensitive information auth0 errors can return (this would be weird IMO) and then redact it: