Skip to content
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

Implement buttons in VNet diag report #52346

Merged
merged 8 commits into from
Feb 21, 2025
Merged

Implement buttons in VNet diag report #52346

merged 8 commits into from
Feb 21, 2025

Conversation

ravicious
Copy link
Member

This PR provides the implementation for the three buttons in the top right of a VNet diag report.

vnet-diag-report

@ravicious ravicious added no-changelog Indicates that a PR does not require a changelog entry backport/branch/v17 labels Feb 20, 2025
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a snapshot test for this as I feel it's one of those cases where snapshot tests are actually useful. Matter of fact, I already benefited from it – I was doing a small refactoring of reportToText and the snapshot test guarantees that the output stays the same.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! (i hate it)

| Conflicting destination | VNet destination | Interface | Set up by |
| ----------------------- | ---------------- | --------- | --------- |
| 100.64.0.0/10 | 100.64.0.1 | utun5 | VPN: Foobar |
| 0.0.0.0/1 | 100.64.0.0/10 | utun6 | unknown |
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really want to spend time on making the whole table line up perfectly as that's not the point. I sparingly used Markdown in the report so that the output is rendered correctly when pasted into Zendesk and Slack. Slack doesn't support tables, but Zendesk does.

vnet-text-report

CLI command output looks particularly bad without code blocks, as in that case most Markdown parsers (or I guess all of them?) do not interpret a single newline character as the start of a new line. So the output from netstat ends up all garbled if code blocks are not used.

Copy link
Member Author

@ravicious ravicious Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I should probably document that it's supposed to be Zendesk/Slack friendly. Edit: Done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great that you thought of making it Zendesk/Slack friendly.

@@ -103,6 +103,9 @@ export default function createMainProcessClient(): MainProcessClient {
showFileSaveDialog(filePath: string) {
return ipcRenderer.invoke('main-process-show-file-save-dialog', filePath);
},
saveTextToFile(args) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's already showFileSaveDialog which is used for SSH file transfers. Compared to saveTextToFile, showFileSaveDialog merely shows the dialog and returns the path chosen by the user.

If I wanted to use this for saving the report, I'd have to implement an IPC API that would let the renderer save arbitrary text to an arbitrary file on the disk, which seems bad. It seems much simpler to just not let the path chosen by the user escape the main process. This way an attacker cannot abuse this through an XSS to silently write to an arbitrary file. They'd have to show a prompt first.

Mind you, I think the renderer already has this ability but in a much smaller scope, as it can do so file transfers. So technically an XSS in Connect would allow the attacker to write to an arbitrary file on disk, as long as they first store whatever text they want to save in a file on an SSH server. 🫠

@ravicious ravicious marked this pull request as ready for review February 20, 2025 11:12
@github-actions github-actions bot requested review from kimlisa and kiosion February 20, 2025 11:13
This was implemented back when we were thinking of showing recent VNet
connections in the panel. We've never had time to implement this, so
it's better to just remove this rather keeping this component in the
project.
JSDocs for individual methods should be defined on the type, so that the
JSDocs are available in any place that uses the type, rather than only
where we use the implementation of the type.
@ravicious ravicious force-pushed the r7s/diag-buttons-base branch from a441ab7 to 2a6a20f Compare February 20, 2025 11:16
@ravicious ravicious changed the base branch from r7s/diag-buttons-base to master February 20, 2025 11:16
@ravicious ravicious requested review from avatus and gzdunek and removed request for kiosion and kimlisa February 20, 2025 11:16
Copy link
Contributor

@avatus avatus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These reports are so sick! super rad

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! (i hate it)

Copy link
Contributor

@gzdunek gzdunek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it and works great.

Comment on lines 55 to 56
Created at (local): ${localCreatedAt}
Created at (UTC): ${utcCreatedAt}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd make it less verbose and combine into one line: Created at: 2025-02-21 10:28:58 (Fri, 21 Feb 2025 09:28:58 GMT)

| Conflicting destination | VNet destination | Interface | Set up by |
| ----------------------- | ---------------- | --------- | --------- |
| 100.64.0.0/10 | 100.64.0.1 | utun5 | VPN: Foobar |
| 0.0.0.0/1 | 100.64.0.0/10 | utun6 | unknown |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great that you thought of making it Zendesk/Slack friendly.

@ravicious ravicious enabled auto-merge February 21, 2025 11:49
@ravicious ravicious added this pull request to the merge queue Feb 21, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 21, 2025
@ravicious ravicious added this pull request to the merge queue Feb 21, 2025
Merged via the queue into master with commit 3d91540 Feb 21, 2025
41 checks passed
@ravicious ravicious deleted the r7s/diag-buttons branch February 21, 2025 13:18
@public-teleport-github-review-bot

@ravicious See the table below for backport results.

Branch Result
branch/v17 Create PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v17 no-changelog Indicates that a PR does not require a changelog entry size/md ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants