Skip to content

Open URI to be handled by Code-based editor. - #704

Merged
rgrunber merged 1 commit into
che-incubator:mainfrom
rgrunber:sshd-uri
May 12, 2026
Merged

rgrunber merged 1 commit into
che-incubator:mainfrom
rgrunber:sshd-uri

Conversation

@rgrunber

@rgrunber rgrunber commented May 11, 2026 •

Copy link
Copy Markdown
Collaborator
  • Automatically open a vscode://redhat.devspaces-remote-ssh URI that
    will be handled by an active Code based editor with
    redhat.devspaces-remote-ssh extension installed
  • Replace the usage of the page URL with the vscode-based URI
  • Use innerText instead of innerHTML for clipboard copying in pre tags
  • pre tags should automatically wrap text
image

Summary by CodeRabbit

  • Style

    • Improved code block wrapping for better readability.
  • Bug Fixes

    • Fixed clipboard copy to copy plain text instead of rendered markup.
  • New Features

    • Added click-to-connect and copyable VS Code remote-SSH URI support, including automatic connect behavior for DevWorkspace sessions.

Review Change Stack

@github-actions

github-actions Bot commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

Click here to review and test in web IDE: Contribute

@coderabbitai

coderabbitai Bot commented May 11, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fc034cf4-f463-4cad-80a9-bab28dc4e104

📥 Commits

Reviewing files that changed from the base of the PR and between 02c433f and 9be9784.

📒 Files selected for processing (3)
  • build/scripts/code-sshd-page/page-style.css
  • build/scripts/code-sshd-page/page-utils.js
  • build/scripts/code-sshd-page/server.js
✅ Files skipped from review due to trivial changes (1)
  • build/scripts/code-sshd-page/page-style.css
🚧 Files skipped from review as they are similar to previous changes (2)
  • build/scripts/code-sshd-page/page-utils.js
  • build/scripts/code-sshd-page/server.js

📝 Walkthrough

Walkthrough

This PR integrates VSCode remote SSH connection capability into the code-sshd-page. The server reads SSH keys (both public and private) with fallbacks, selects one based on user preference, base64url-encodes it, and embeds it into a vscode://redhat.devspaces-remote-ssh gateway URI alongside workspace metadata and the dashboard URL. The generated page displays this URI in a styled <pre> block with copy-to-clipboard functionality and instructions. Client-side utilities enable clipboard copying of plain text and opening the URI via VSCode. The page initialization script automatically invokes the URI opening on load.

Sequence Diagram

sequenceDiagram
  participant Server as Server<br/>(key loading)
  participant Page as Generated Page<br/>(HTML+script)
  participant Client as Browser Client
  participant VSCode as VSCode Gateway

  Server->>Server: Read SSH keys<br/>(pub + private)
  Server->>Server: Select key & base64url<br/>-encode
  Server->>Server: Encode dashboard URL
  Server->>Page: Embed URI params in<br/>inline script
  Page->>Client: Render pre block with<br/>vscode:// URI
  Client->>Client: On page load:<br/>initializePlatformContent()
  Client->>Client: openDevspacesURI()<br/>constructs full URI
  Client->>VSCode: window.open(uri, "_self")
  VSCode->>VSCode: Establish remote<br/>SSH connection
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: automatically opening a vscode:// URI for Code-based editor handling. It meets length requirements (44 chars < 72) and uses imperative mood.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Rebase Rules For Upstream Changes ✅ Passed PR modifies only build-time files in build/scripts/code-sshd-page/, not upstream code/ files. No rebase rules required per check criteria: "PASS if no files under code/ are changed".

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@build/scripts/code-sshd-page/page-utils.js`:
- Around line 41-44: The current openDevspacesURI function uses window.open(...,
"_self") which replaces the instructions page; change it to open in a new tab or
avoid auto-opening to preserve the page — update openDevspacesURI to use
window.open(gatewayLink, "_blank") (or remove automatic call and return the
gatewayLink so the UI can render a clickable anchor) and ensure
encodedKeyMessage/encodedUrl are preserved; modify any callers accordingly
(either they continue to call openDevspacesURI which opens a new tab, or they
receive the link and let the user click).

In `@build/scripts/code-sshd-page/server.js`:
- Around line 160-163: The inline script is vulnerable to XSS because values are
interpolated directly into JavaScript strings in the call to openDevspacesURI;
update the template so every interpolated value (DEVWORKSPACE_NAMESPACE,
HOSTNAME, username, DEVWORKSPACE_NAME, encodedKeyMessage, encodedUrl) is safely
serialized/escaped for JS context before rendering and/or stop using raw
interpolation in the inline script; specifically, replace the direct
interpolation around the call to openDevspacesURI with either (a)
JSON.stringify-safe injection (serialize each value with a server-side
JS-escaping routine and insert the serialized literal) or (b) move the data into
a data-* attribute or a <script type="application/json"> block and read them via
initializePlatformContent before calling openDevspacesURI (ensuring
initializePlatformContent/openDevspacesURI consume the sanitized values).
- Around line 87-102: The anchor and <pre id="uri-connection"> currently
interpolate unescaped values (username, process.env["DEVWORKSPACE_NAMESPACE"],
process.env["HOSTNAME"], process.env["DEVWORKSPACE_NAME"], encodedKeyMessage,
encodedUrl) which creates an XSS risk; update the code that builds the URI and
DOM to properly escape/encode all interpolated values and avoid injecting raw
HTML: construct the URI with encodeURIComponent or a dedicated URL builder for
each query param (reference encodedKeyMessage, encodedUrl, username), set the
href and the pre's textContent/innerText instead of innerHTML, and ensure
server-side sanitization of any environment-derived values before rendering to
the template (or run them through an HTML-escaping util used by the template
renderer).
- Around line 31-54: The code currently base64url-encodes and embeds private key
material (variables userKey/genKey via encodedKeyMessage) into a vscode:// URI
(the logic that builds the URI where encodedKeyMessage is used); remove any
embedding of userKey or genKey into URLs and instead implement a secure
retrieval flow: create a server-side short-lived token (JWT or random one-time
token) tied to the authenticated session and store the private key server-side,
change the URI builder to include only the token or a reference (not the key)
and the encoded dashboard URL
(encodeURIComponent(process.env["CHE_DASHBOARD_URL"])), and implement an
authenticated endpoint (e.g., /ssh-key?token=...) that the VSCode extension
calls to exchange the short-lived token for the private key over HTTPS; ensure
token expiry and single-use semantics and that userKey/genKey remain read from
disk only on the server and are never placed into any URL or client-side logs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a5c0454e-0416-4a9a-9863-50a0de055046

📥 Commits

Reviewing files that changed from the base of the PR and between 08a7c34 and 02c433f.

📒 Files selected for processing (3)
  • build/scripts/code-sshd-page/page-style.css
  • build/scripts/code-sshd-page/page-utils.js
  • build/scripts/code-sshd-page/server.js

Comment thread build/scripts/code-sshd-page/server.js Resolved
Comment thread build/scripts/code-sshd-page/server.js Resolved
Comment thread build/scripts/code-sshd-page/server.js Resolved
@github-actions

Copy link
Copy Markdown
Contributor

@RomanNikitenko

Copy link
Copy Markdown
Collaborator

coderabbitai reported a problem related to a rebase rule in the code/package.json, see #704 (comment)
but
I don't see any changes in the code/package.json

@sbouchet
I guess it's just coderabbitai's hallucinations, not something that we can fix in https://github.com/che-incubator/che-code/blob/main/.coderabbit.yaml?

@sbouchet

Copy link
Copy Markdown
Collaborator

coderabbitai reported a problem related to a rebase rule in the code/package.json, see #704 (comment) but I don't see any changes in the code/package.json

@sbouchet I guess it's just coderabbitai's hallucinations, not something that we can fix in https://github.com/che-incubator/che-code/blob/main/.coderabbit.yaml?

unfortunately you''re right, nothing in the coderabbit config tells about such rule.

@rgrunber you can rebase to re-trigger another coderabbit check. result might be different?

- Automatically open a vscode://redhat.devspaces-remote-ssh URI that
  will be handled by an active Code based editor with
  redhat.devspaces-remote-ssh extension installed
- Replace the usage of the page URL with the vscode-based URI
- Use innerText instead of innerHTML for clipboard copying in pre tags
- pre tags should automatically wrap text

Signed-off-by: Roland Grunberg <[email protected]>
@rgrunber

rgrunber commented May 12, 2026 •

Copy link
Copy Markdown
Collaborator Author

Currently running the devspaces-auto-validation against this 🚧 ..

======================
Summary:
  Total tests: 169 
  Successful: 161
  Failed: 8
  Elapsed time: 1h 35m 10s
======================

Failed images:
  - Devfile 'https://registry.devfile.io/devfiles/nodejs' using image 'registry.access.redhat.com/ubi8-micro:latest'
  - Devfile 'https://registry.devfile.io/devfiles/nodejs' using image 'registry.access.redhat.com/ubi8/pause:latest'
  - Devfile 'https://registry.devfile.io/devfiles/nodejs' using image 'registry.access.redhat.com/ubi9-micro:9.6'
  - Devfile 'https://registry.devfile.io/devfiles/nodejs' using image 'registry.access.redhat.com/ubi9/ubi-stig:9.6'
  - Devfile 'https://registry.devfile.io/devfiles/nodejs' using image 'registry.access.redhat.com/ubi9-micro:9.7'
  - Devfile 'https://registry.devfile.io/devfiles/nodejs' using image 'registry.access.redhat.com/ubi9/ubi-stig:9.7'
  - Devfile 'https://registry.devfile.io/devfiles/nodejs' using image 'registry.access.redhat.com/ubi10/ubi-micro:10.0'
  - Devfile 'https://registry.devfile.io/devfiles/nodejs' using image 'registry.access.redhat.com/ubi10/ubi-micro:10.1'

@github-actions

Copy link
Copy Markdown
Contributor

@rgrunber
rgrunber merged commit 2288e06 into che-incubator:main May 12, 2026
13 checks passed
@rgrunber
rgrunber deleted the sshd-uri branch May 12, 2026 20:06
@rgrunber rgrunber moved this from Ready for Review to ✅ Done in Eclipse Che Team C Backlog [DEPRECATED] May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants