Repository navigation
feat(app): mask secrets in API key and MCP install snippets with a shared RevealSnippet #2988
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0cc8834
feat(app): add RevealSnippet, mask secrets in API key and MCP install…
brandon-pereira e7cd6d5
fix(app): re-mask RevealSnippet on value change; drop unused exports
brandon-pereira 4ebe870
test(app): cover copy-without-reveal + MCP snippet masking; harden re…
brandon-pereira 9f403bb
Merge branch 'main' into brandon/reveal-snippet-component
kodiakhq[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@hyperdx/app': patch | ||
| --- | ||
|
|
||
| feat(app): mask secrets in API key and MCP install snippets with a shared reveal-to-copy component |
38 changes: 32 additions & 6 deletions
38
packages/app/src/components/ClickStackOnboarding/CopySnippet.tsx
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
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
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
63 changes: 63 additions & 0 deletions
63
packages/app/src/components/ClickStackOnboarding/__tests__/McpInstallPanel.test.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import { MantineProvider } from '@mantine/core'; | ||
| import { render, screen } from '@testing-library/react'; | ||
| import userEvent from '@testing-library/user-event'; | ||
|
|
||
| import McpInstallPanel from '@/components/ClickStackOnboarding/McpInstallPanel'; | ||
| import { defaultRedact } from '@/components/RevealSnippet/RevealSnippet'; | ||
|
|
||
| // A realistic-length access key so defaultRedact keeps a visible prefix and | ||
| // masks the rest (matching production, where the key is a UUIDv4). | ||
| const ACCESS_KEY = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'; | ||
|
|
||
| const DEPLOYMENT = { | ||
| apiUrl: 'https://app.example.com/api', | ||
| accessKey: ACCESS_KEY, | ||
| }; | ||
|
|
||
| function renderPanel() { | ||
| return render( | ||
| <MantineProvider> | ||
| <McpInstallPanel deployment={DEPLOYMENT} /> | ||
| </MantineProvider>, | ||
| ); | ||
| } | ||
|
|
||
| function codeText(): string { | ||
| // Every masked host renders its snippet in the shared code block. | ||
| return screen.getByTestId('reveal-snippet-code').textContent ?? ''; | ||
| } | ||
|
|
||
| describe('McpInstallPanel secret masking', () => { | ||
| it('masks the access key in the default (Claude Code) command snippet', () => { | ||
| renderPanel(); | ||
|
|
||
| const text = codeText(); | ||
| // The raw key must never appear in the rendered snippet... | ||
| expect(text).not.toContain(ACCESS_KEY); | ||
| // ...but the masked stand-in (visible prefix + dots) should. | ||
| expect(text).toContain(defaultRedact(ACCESS_KEY)); | ||
| }); | ||
|
|
||
| it('masks the access key in the JSON fallback (Other) snippet', async () => { | ||
| const user = userEvent.setup(); | ||
| renderPanel(); | ||
|
|
||
| // Switch to the generic "Other" host, which renders the raw JSON block. | ||
| await user.click(screen.getByRole('radio', { name: /other/i })); | ||
|
|
||
| const text = codeText(); | ||
| expect(text).not.toContain(ACCESS_KEY); | ||
| expect(text).toContain(defaultRedact(ACCESS_KEY)); | ||
| }); | ||
|
|
||
| it('reveals the raw key only after an explicit reveal action', async () => { | ||
| const user = userEvent.setup(); | ||
| renderPanel(); | ||
|
|
||
| expect(codeText()).not.toContain(ACCESS_KEY); | ||
|
|
||
| await user.click(screen.getByRole('button', { name: /reveal key/i })); | ||
|
|
||
| expect(codeText()).toContain(ACCESS_KEY); | ||
| }); | ||
| }); |
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
29 changes: 29 additions & 0 deletions
29
packages/app/src/components/RevealSnippet/RevealSnippet.module.scss
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| .code { | ||
| margin: 0; | ||
| padding: 12px 14px; | ||
| overflow-x: auto; | ||
| border-radius: var(--mantine-radius-sm); | ||
| background: var(--color-bg-field); | ||
| color: var(--mantine-color-text); | ||
| font-family: var(--mantine-font-family-monospace); | ||
| font-size: var(--mantine-font-size-sm); | ||
| line-height: 1.6; | ||
| white-space: pre; | ||
| } | ||
|
|
||
| .wrap { | ||
| white-space: pre-wrap; | ||
| overflow-wrap: break-word; | ||
| } | ||
|
|
||
| // Shared muted-at-rest treatment for the Reveal and Copy buttons. Uses the | ||
| // themed text color (not Mantine "dimmed") so it stays legible in light/dark | ||
| // and across brands; both buttons carry `c="inherit"` to pick up this color. | ||
| .reveal { | ||
| color: var(--color-text-muted); | ||
| transition: color 100ms ease; | ||
|
|
||
| &:hover { | ||
| color: var(--color-text); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.