Skip to content

fix(extensions): Rust bundler/deploy path parity with TS [DEVEX-712] - #177

Merged
jpage-godaddy merged 3 commits into
mainfrom
DEVEX-712
Aug 3, 2026
Merged

jpage-godaddy merged 3 commits into
mainfrom
DEVEX-712

Conversation

@qcai-godaddy

Copy link
Copy Markdown
Collaborator

Summary

  • Bring Rust extension bundling in line with the TS CLI: artifact report (name/path/size/sha256), handle-based artifact naming, UI runtime wrapper for embed/checkout, tsconfig resolution, shared deploy timestamp + PID-suffixed temp dirs, and RAII temp cleanup.
  • Sandbox sources under extensions/{handle}/ (lexical checks, symlink realpath, case-insensitive / on-disk casing for Mac→Linux), reject multi-chunk .mjs outputs, and validate/normalize --source on platform app add so config matches deploy.

Test plan

  • cargo build / cargo fmt --check / cargo clippy -- -D warnings / cargo test (439 passed)
  • GDDY_MIN_STAGE=experimental + platform app add extension embed|checkout|blocks with handle-relative src/index.ts writes normalized source into godaddy.toml (repo-relative under handle also normalizes)
  • Rejects path escape (../../…), missing source file, and handle escape (../evil) with VALIDATION_ERROR
  • Linux case-sensitive: handle=Widget with folder widget (covered by unit tests)

Copilot AI review requested due to automatic review settings August 3, 2026 20:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Rust extension deploy pipeline to match the TypeScript CLI’s bundling/deploy behavior, including artifact metadata reporting, deploy-time path sandboxing/normalization, and improved temp-dir handling.

Changes:

  • Add bundle artifact metadata (name/path/size/sha256 + optional sourcemap) and UI runtime wrapper support for embed/checkout extensions.
  • Introduce robust extension path resolution/sandboxing (handle-rooted under extensions/{handle}/, case-insensitive matching, symlink escape prevention) and normalize --source on platform app add.
  • Use a single deploy timestamp for consistent artifact naming and temp-root naming, plus RAII cleanup for temp directories.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
rust/src/extension/mod.rs Adds bundle options/results, artifact naming, UI wrapper generation, tsconfig resolution, sandboxed path resolution/normalization, multi-chunk rejection, and temp-dir lifecycle management.
rust/src/application/commands/mod.rs Updates deploy flow to use sandboxed path resolution + new bundler options, emits richer artifact progress events, and normalizes --source when writing extension config.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rust/src/application/commands/mod.rs Resolved
Comment thread rust/src/extension/mod.rs Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Suppressed comments (4)

rust/src/application/commands/mod.rs:1805

  • Same as above: the checkout --source help text includes indentation spaces due to line continuations; prefer concat! (or a single-line string) to keep help output clean.
            .with_arg(clap::Arg::new("source").long("source").required(true).help(
                "Path to the JavaScript entry-point file, relative to \
                         extensions/<handle>/ (e.g. src/index.ts), or a path already \
                         under that directory",
            ))

rust/src/application/commands/mod.rs:1864

  • Same as above: the blocks --source help text will render with extra indentation whitespace because it relies on \ continuations with indented lines.
            .with_arg(clap::Arg::new("source").long("source").required(true).help(
                "Path to the JavaScript entry-point file for the blocks extension, \
                         relative to extensions/blocks/ (e.g. src/index.ts), or a path \
                         already under that directory",
            )),

rust/src/extension/mod.rs:670

  • resolve_extension_paths currently allows handle values like "" or "." to resolve extension_dir to the extensions/ root itself, which undermines the stated invariant that sources are sandboxed under extensions/{handle}/ (and can broaden what --source is allowed to reference). Reject handles that resolve to the extensions root.
    let extensions_root = normalize_path(&repo_root.join("extensions"));
    let extension_dir = normalize_path(&extensions_root.join(handle));
    if !is_path_within(&extensions_root, &extension_dir) {
        return Err(invalid_handle_path(handle));
    }
    let extension_dir = dir_casing_on_disk(&extensions_root, &extension_dir);

rust/src/application/commands/mod.rs:1735

  • The --source help text uses \ line continuations plus indentation, which will include a large run of spaces in the rendered help output. Using concat! (or a single-line string) avoids accidental whitespace in user-facing CLI help.

This issue also appears in the following locations of the same file:

  • line 1801
  • line 1860
            .with_arg(clap::Arg::new("source").long("source").required(true).help(
                "Path to the JavaScript entry-point file, relative to \
                         extensions/<handle>/ (e.g. src/index.ts), or a path already \
                         under that directory",
            ))

Comment thread rust/src/extension/mod.rs Resolved
Comment thread rust/src/extension/mod.rs Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (2)

rust/src/extension/mod.rs:940

  • map_path is built via format!("{}.map", mjs_path.display()), which round-trips through a lossy UTF-8 string and can break on non-UTF8 paths. Since this is purely a filesystem path derivation, it should stay in OsStr/OsString space (append ".map" to the existing path).
    let map_path = {
        let candidate = PathBuf::from(format!("{}.map", mjs_path.display()));
        candidate.is_file().then_some(candidate)
    };

rust/src/application/commands/mod.rs:1476

  • The security scan runs against the bundled artifact (bundle.bytes), so the reported file/line numbers should refer to the artifact (e.g. bundle.artifact_name or bundle.artifact_path), not the configured source entry-point. Using ext.source here can mislead users because the line numbers won't match the source file.
    let source_display = ext.source.as_str();
    let content = String::from_utf8_lossy(&bundle.bytes);
    let findings = crate::extension::scan_bundle(&content, source_display);

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