Repository navigation
Open URI to be handled by Code-based editor. - #704
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThis 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 Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
build/scripts/code-sshd-page/page-style.cssbuild/scripts/code-sshd-page/page-utils.jsbuild/scripts/code-sshd-page/server.js
|
Pull Request images published ✨ Editor amd64: quay.io/che-incubator-pull-requests/che-code:pr-704-amd64 |
|
@sbouchet |
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]>
|
|
|
Pull Request images published ✨ Editor amd64: quay.io/che-incubator-pull-requests/che-code:pr-704-amd64 |
will be handled by an active Code based editor with
redhat.devspaces-remote-ssh extension installed
Summary by CodeRabbit
Style
Bug Fixes
New Features