You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(admin): redact nested webhook urls in settings-change notifications - #1295
PATCH /admin/settings builds a settings.changed notification and redacts secrets in it in two steps:
redactSettingsValue(path, value) for each change, which only replaced a string value at a sensitive path (passwordHash, secret, botToken or an admin.notifications.targets…url), and returned an object or array as it was;
redactSettingsSecrets(changes) on the list of { path, value, reload } records, which walks the list with paths such as [0].value.targets[0].url. The rule for a webhook url is path.startsWith('admin.notifications.targets'), so it never matches there.
So when the changed path is a parent of the webhook targets, for example admin.notifications or admin, the value is the whole object and the url of each target is sent to the notification recipients unredacted.
redactSettingsValue now walks an object or array value with the path it was written at (admin.notifications.targets[0].url), so the rules that already exist apply to the nested values;
redactSettingsSecrets uses the same walk, so nothing else changes for it;
the response of the settings request uses the same function, so it no longer echoes the url either.
Related Issue
Partly addresses #1022 (F-041). The other findings in that issue are handled separately.
Motivation and Context
A webhook url holds a token (a Discord or Slack webhook). The settings API and the dedicated notifications endpoint already hide it, and the settings-change notification is the one place that sent it to the recipients. CodeRabbit's scan did not establish reachability, so I checked the code: the path rule is startsWith('admin.notifications.targets') and the walk in redactSettingsSecrets starts at the list, so a parent-path change is not caught.
How Has This Been Tested?
New test in test/unit/utils/settings-redaction.spec.ts for a value written at admin.notifications, at admin.notifications.targets and at admin.
New test in test/unit/controllers/admin/patch-settings-controller.spec.ts: replacing admin.notifications puts no webhook url in the outbox payload or in the response. Both tests fail without the change.
pnpm run test:unit, pnpm lint and pnpm run build:check.
Screenshots (if appropriate):
Types of changes
Non-functional change (docs, style, minor refactor)
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
My code follows the code style of this project.
My change requires a change to the documentation.
I have updated the documentation accordingly.
I have read the CONTRIBUTING document.
I have added tests to cover my code changes.
I added a changeset, or this is docs-only and I added an empty changeset.
All new and existing tests passed.
Summary by CodeRabbit
Bug Fixes
Webhook URLs are masked in settings notifications and request responses, including when an entire parent settings path is replaced rather than an individual nested value.
Sensitive values remain hidden when paths include surrounding whitespace, while unrelated notification targets and recipient fields continue to appear unchanged.
Nested sensitive values are redacted consistently across settings updates and returned settings data.
No actionable comments were generated in the recent review.
Walkthrough
Settings redaction now recursively checks nested values beneath the supplied path. Tests cover webhook URL redaction in settings values, notification payloads, and responses, including paths with whitespace. A patch changeset documents the update.
The shared traversal recursively redacts non-empty strings at sensitive paths. Path checks trim the supplied path and its segments. Tests cover nested values and verify that replacing admin.notifications masks webhook URLs in notification payloads and responses. The changeset describes the patch.
Issue 1022 describes settings-change notifications that fail to redact nested webhook URLs after a parent path is replaced. This PR adds nested redaction using the supplied path, addressing the described F-041 finding.
Issue 1193 describes container-valued settings writes echoing secrets in responses and outbox payloads. This PR addresses the TypeScript redaction behavior, but the Rust implementation mentioned in the issue is not included.
Merge Risk: Minimal · up to a7238
This change stops webhook URLs from appearing in notifications and settings responses when a parent settings path is replaced. No merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: nested webhook URLs are now redacted in settings-change notifications. It follows the conventional fix(scope) form and matches the PR objectives, which cover redacting…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: nested webhook URLs are now redacted in settings-change notifications. It follows the conventional fix(scope) form and matches the PR objectives, which cover redacting nested webhook URLs when PATCH /admin/settings changes a parent setting such as admin.notifications.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit checks each setting path, And masks the webhook in its track. Through nested fields, the secrets hide, In payloads and responses, side by side. Whiskers twitch; the tests pass by.
Recent review info
Automatic approval policy
Commit: a72384f593ef.
Setting
Effective value
Source
Automatic approvals
Enabled
Global configuration
Merge risk
Minimal
Global configuration
Security risk
Not set
Global configuration
Not set means no limit was configured after inheritance. Use @coderabbitai configuration to inspect the resolved settings and their sources.
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 7702fec2-b000-47cf-8f60-2cd8547ab092
Commits
Reviewing files that changed from the base of the PR and between df1f672 and a72384f.
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.
No base build found for commit c14342e on main.
Coverage changes can't be calculated without a base build. If a base build is processing, this comment will update automatically when it completes.
Coverage: 80.85%
Details
Patch coverage: 23 of 23 lines across 1 file are fully covered (100%).
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
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.
Description
PATCH /admin/settingsbuilds asettings.changednotification and redacts secrets in it in two steps:redactSettingsValue(path, value)for each change, which only replaced a string value at a sensitive path (passwordHash,secret,botTokenor anadmin.notifications.targets…url), and returned an object or array as it was;redactSettingsSecrets(changes)on the list of{ path, value, reload }records, which walks the list with paths such as[0].value.targets[0].url. The rule for a webhook url ispath.startsWith('admin.notifications.targets'), so it never matches there.So when the changed path is a parent of the webhook targets, for example
admin.notificationsoradmin, the value is the whole object and theurlof each target is sent to the notification recipients unredacted.redactSettingsValuenow walks an object or array value with the path it was written at (admin.notifications.targets[0].url), so the rules that already exist apply to the nested values;redactSettingsSecretsuses the same walk, so nothing else changes for it;Related Issue
Partly addresses #1022 (F-041). The other findings in that issue are handled separately.
Motivation and Context
A webhook url holds a token (a Discord or Slack webhook). The settings API and the dedicated notifications endpoint already hide it, and the settings-change notification is the one place that sent it to the recipients. CodeRabbit's scan did not establish reachability, so I checked the code: the path rule is
startsWith('admin.notifications.targets')and the walk inredactSettingsSecretsstarts at the list, so a parent-path change is not caught.How Has This Been Tested?
test/unit/utils/settings-redaction.spec.tsfor a value written atadmin.notifications, atadmin.notifications.targetsand atadmin.test/unit/controllers/admin/patch-settings-controller.spec.ts: replacingadmin.notificationsputs no webhook url in the outbox payload or in the response. Both tests fail without the change.pnpm run test:unit,pnpm lintandpnpm run build:check.Screenshots (if appropriate):
Types of changes
Checklist:
Summary by CodeRabbit