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.
feat(slack): enhance error handling and logging in slackPostMessage function #1874
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
Uh oh!
There was an error while loading. Please reload this page.
feat(slack): enhance error handling and logging in slackPostMessage function #1874
Changes from all commits
aef9c1d31728e7File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
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.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: rocket-admin/rocketadmin
Length of output: 1483
🏁 Script executed:
Repository: rocket-admin/rocketadmin
Length of output: 2770
🌐 Web query:
Axios 1.16.1 AxiosError toJSON config util.inspect console.error authorization header serialization Sentry@sentry/minimal6.19.7 captureException AxiosError config💡 Result:
In Axios 1.16.1,
AxiosError.toJSON()is the standard way to serialize error details for logging or debugging [1][2]. BecauseAxiosErrorobjects contain the requestconfig—which includes sensitive headers likeAuthorization—logging the error object directly (e.g., viaconsole.erroror Sentry) can leak credentials [3][4]. To prevent this, use theredactconfiguration option in your request. When provided, Axios will mask specified headers (case-insensitively) at any depth whentoJSON()is called [1][5]: axios.get('/user', { headers: { Authorization: 'Bearer token' }, redact: ['authorization'] }).catch(error => { // error.toJSON.config.headers.Authorization will be [REDACTED ] console.error(error.toJSON); }); Key technical details: - Serialization Safety:AxiosError.toJSON()produces a bounded snapshot of the error [6][7]. Recent updates ensure that complex objects like HTTP agents are replaced with '[Agent]' and streamed response bodies are marked as '[Readable]' to prevent CPU spikes or Out-of-Memory (OOM) errors during serialization [6][8]. - Sensitive Data: Relying solely onutil.inspectorconsole.erroron the rawAxiosErrorobject remains risky because they may traverse the full object structure, including sensitive headers, bypassing thetoJSON()redaction logic [3][4]. Always invokeerror.toJSON()or specifically sanitize the object before logging [1][2]. - Sentry Integration: When using@sentry/minimal6.19.7, passing anAxiosErrordirectly tocaptureExceptionmay attach the full, unredacted error context [9][10][11]. To safely capture context, use thebeforeSendhook in your Sentry initialization to sanitize the error or extract only the necessary response data [12]: Sentry.init({ beforeSend(event, hint) { if (hint?.originalException?.isAxiosError) { // Manually extract and attach only what you need event.extra = {...event.extra, status: hint.originalException.response?.status }; } return event; } }); Note:@sentry/minimalwas deprecated in Sentry v7; its functionality was moved to@sentry/hub[13]. If possible, upgrade to a newer Sentry SDK version for improved error handling and type support [13].Citations:
Sensitive Data Exposure (CWE-532): Insertion of Sensitive Information into Log File
Reachability: External · Exploitability: Difficult
Do not log or capture the raw Axios error.
Axios retains the request config on rejected requests, including the Slack bearer token. Sanitize the error before passing it to
console.errororSentry.captureException, while preserving the non-throwing behavior.🤖 Prompt for AI Agents
Uh oh!
There was an error while loading. Please reload this page.