Skip to content

Visual Studio Code, rebuilt in Rust

Rust

feat(extensions): trust product.json trustedExtensionPublishers

rokarturfea756139052
diff --git a/README.md b/README.md
index 710e8b7d11c..c0233a996e3 100644
--- a/README.md
+++ b/README.md
@@ -11,8 +11,8 @@ Coverage of VS Code 1.147.0, from [port/ledger.md](port/ledger.md) (584 rows). V
```mermaid
pie showData
- "verified" : 413
- "ported" : 17
+ "verified" : 414
+ "ported" : 16
"removed" : 126
"n/a" : 28
```
@@ -23,7 +23,7 @@ pie showData
| workbench contribution | 63 | 5 | 30 | 3 | `███████████████████░ 93%` |
| built-in extension | 88 | 1 | 6 | 0 | `████████████████████ 99%` |
| MainThread* shape (Rust side) | 59 | 0 | 30 | 0 | `████████████████████ 100%` |
-| workbench service | 58 | 7 | 23 | 7 | `██████████████████░░ 89%` |
+| workbench service | 59 | 6 | 23 | 7 | `██████████████████░░ 91%` |
| src/vs/editor/contrib | 54 | 0 | 2 | 1 | `████████████████████ 100%` |
| workbench part | 10 | 1 | 2 | 0 | `██████████████████░░ 91%` |
| extension host seam | 7 | 0 | 0 | 0 | `████████████████████ 100%` |
@@ -31,7 +31,7 @@ pie showData
| src/vs/editor | 0 | 2 | 1 | 1 | `░░░░░░░░░░░░░░░░░░░░ 0%` |
| src/vs/base | 0 | 0 | 2 | 3 | `████████████████████ 100%` |
| port feature | 1 | 0 | 0 | 0 | `████████████████████ 100%` |
-| **all** | **413** | **17** | **126** | **28** | `███████████████████░ 96%` |
+| **all** | **414** | **16** | **126** | **28** | `███████████████████░ 96%` |
<!-- coverage:end -->
`removed` are parts left out by decision: AI features, Microsoft services, telemetry, remote and tunnels ([port/notes.md](port/notes.md)). `n/a` are upstream test infrastructure and the Electron process, IPC and DOM layers the native architecture replaces.
diff --git a/native/crates/app/src/product.rs b/native/crates/app/src/product.rs
index 902d6d6994e..dc4e78d0662 100644
--- a/native/crates/app/src/product.rs
+++ b/native/crates/app/src/product.rs
@@ -30,6 +30,12 @@ pub fn load(root: &Path, bundled: bool) {
for (key, value) in OVERLAY.as_object().expect("port/product.json is a JSON object").iter().filter(|_| !bundled) {
product[key] = value.clone();
}
+ // bootstrap-meta.ts: run with VSCODE_DEV, `<root>/product.overrides.json` overrides product.json's keys.
+ if std::env::var_os("VSCODE_DEV").is_some() {
+ for (key, value) in read("product.overrides.json").as_ref().and_then(Value::as_object).into_iter().flatten() {
+ product[key] = value.clone();
+ }
+ }
if product["version"].is_null() {
if let Some(version) = read("package.json").map(|package| package["version"].clone()) {
product["version"] = version;
diff --git a/native/crates/app/src/workbench/trusted_publishers.rs b/native/crates/app/src/workbench/trusted_publishers.rs
index 45414d51025..7d381bdc424 100644
--- a/native/crates/app/src/workbench/trusted_publishers.rs
+++ b/native/crates/app/src/workbench/trusted_publishers.rs
@@ -64,7 +64,7 @@ impl Workbench {
}
}
- /// `isPublisherUserTrusted` for each lower-case publisher; the port's product has no `trustedExtensionPublishers`.
+ /// `isPublisherUserTrusted` for each lower-case publisher.
pub(super) fn user_trusted_publishers(&self) -> Vec<String> {
self.trusted_publishers().keys().cloned().collect()
}
@@ -90,7 +90,7 @@ impl Workbench {
/// trusted, else the dialog's answer, true once "Trust Publisher & Install" trusted every publisher it names.
/// While extension tests run, DialogService.prompt refuses the dialog and the install fails.
pub(super) fn check_trusted_publishers(&mut self, extension: &GalleryExtension, others: Vec<Publisher>, cx: &mut Context<Self>) -> anyhow::Result<Option<oneshot::Receiver<bool>>> {
- if extension.private || self.user_trusted_publishers().contains(&extension.publisher.to_lowercase()) {
+ if extension.private || is_publisher_trusted(extension, crate::product::get("trustedExtensionPublishers"), &self.user_trusted_publishers()) {
return Ok(None);
}
let mut publishers = vec![Publisher::of(extension)];
@@ -158,7 +158,7 @@ pub(super) fn other_untrusted_publishers(gallery: &Gallery, extension: &GalleryE
}
let mut publishers: Vec<Publisher> = Vec::new();
for extension in found {
- if extension.private || trusted.contains(&extension.publisher.to_lowercase()) {
+ if extension.private || is_publisher_trusted(&extension, crate::product::get("trustedExtensionPublishers"), trusted) {
continue;
}
match publishers.iter_mut().find(|publisher| publisher.display_name == extension.publisher_display_name) {
@@ -169,6 +169,15 @@ pub(super) fn other_untrusted_publishers(gallery: &Gallery, extension: &GalleryE
publishers
}
+/// `isPublisherTrusted` without allowed extensions: product.json `trustedExtensionPublishers` names the publisher or its
+/// display name, lower-case, or the user trusted it.
+fn is_publisher_trusted(extension: &GalleryExtension, product_trusted: &Value, user_trusted: &[String]) -> bool {
+ let product_trusted = product_trusted.as_array().map(Vec::as_slice).unwrap_or_default();
+ let publisher = extension.publisher.to_lowercase();
+ let display_name = extension.publisher_display_name.to_lowercase();
+ product_trusted.iter().any(|trusted| *trusted == publisher || *trusted == display_name) || user_trusted.contains(&publisher)
+}
+
fn title(publishers: &[Publisher]) -> String {
match publishers {
[one] => format!("Do you trust the publisher \"{}\"?", one.display_name),
@@ -334,6 +343,16 @@ mod tests {
assert!(details[3].ends_with("Proceed only if you trust the publishers."));
}
+ #[test]
+ fn product_trusted_publishers_name_the_publisher_or_its_display_name() {
+ let product_trusted = json!(["redhat", "github inc."]);
+ assert!(is_publisher_trusted(&extension("RedHat", "Red Hat", None), &product_trusted, &[]));
+ assert!(is_publisher_trusted(&extension("github", "GitHub Inc.", None), &product_trusted, &[]));
+ assert!(!is_publisher_trusted(&extension("alpha", "Alpha", None), &product_trusted, &[]));
+ assert!(!is_publisher_trusted(&extension("alpha", "Alpha", None), &Value::Null, &[]));
+ assert!(is_publisher_trusted(&extension("Alpha", "Alpha", None), &Value::Null, &["alpha".into()]));
+ }
+
#[gpui::test]
fn extension_tests_refuse_the_dialog_and_fail_the_install(cx: &mut gpui::TestAppContext) {
let app_root = std::path::Path::new(env!("VSCODE_SRC")).to_path_buf();
diff --git a/port/ledger.md b/port/ledger.md
index bec9c2f6c6b..9907b685f1d 100644
--- a/port/ledger.md
+++ b/port/ledger.md
@@ -32,7 +32,7 @@ Status: `open`, `in progress`, `waiting on Artur`, `later` (postponed), `done`,
| Milestones | M15 terminal, tasks, output | done | Integrated terminal (PTY from Rust, VT parser and renderer in GPUI), shell integration, extension terminals and pseudoterminals, tasks and problem matchers, npm/grunt/gulp/jake task providers, external terminal, Output panel and log viewer. Open gaps: the gaps column of its unit rows. | api-tests `terminal.test`, `terminal.shellIntegration.test` and `workspace.tasks.test` pass as in the reference (run with `SHELL=/bin/bash` as the baseline was); `npm: build` task from the fixture runs in a terminal. |
| Milestones | M16 debug and testing | in progress | Debug adapter protocol client, launch.json, breakpoints in the gutter, call stack, variables, watch, debug console, JS debugger (`ms-vscode.js-debug`), Test Explorer and test results. Open gaps: the gaps column of its unit rows. | api-tests `debug.test` and testing cases pass as in the reference; a breakpoint in a Node script from the fixture stops and shows variables. |
| Milestones | M17 webviews and notebooks | in progress | A WKWebView embedded in the GPUI window for webview panels, webview views and custom editors, with the upstream message and resource protocol; Markdown preview, image/media preview, simple browser, editor insets; notebooks (ipynb) with renderers and kernels. Open gaps: the gaps column of its unit rows. | api-tests `webview.test`, `customEditor` and `notebook*.test` cases pass as in the reference; Markdown preview of the fixture README draws next to its source. |
-| Milestones | M18 extensions: install, update, gallery | in progress | Extensions view backed by Open VSX, install/uninstall/update/disable, VSIX install, signature and checksum checks, recommendations, ESM extensions added after startup on Bun, language packs and display language. Open gaps: the gaps column of its unit rows. | Installing an extension from Open VSX activates it without restart (an ESM one included); api-tests `extensions.test` pass as in the reference. |
+| Milestones | M18 extensions: install, update, gallery | done | Extensions view backed by Open VSX, install/uninstall/update/disable, VSIX install, signature and checksum checks, recommendations, ESM extensions added after startup on Bun, language packs and display language. | Installing an extension from Open VSX activates it without restart (an ESM one included); api-tests `extensions.test` pass as in the reference. PORT_GALLERY=1 port/tools/extensions-check: 5 ok; MOCHA_GREP="vscode server cli" port/tools/api-tests: its one test pending, as in the reference (remote only). |
| Milestones | M19 product shell, privacy, accessibility, release | done | Welcome page and walkthroughs, update channel for the port's own builds, relaunch, splash, accessibility (VoiceOver through GPUI's accessibility tree, accessibility signals, high-contrast checks), process explorer and performance views, telemetry inert end to end, packaged and signed `.app`. Open gaps: the gaps column of its unit rows. | The telemetry source search (no telemetry endpoint string reachable) and network capture (zero outbound requests in a 10 min session with no user action) pass; VoiceOver reads the editor line and the Explorer rows; the signed `.app` passes `spctl -a`; benchmark rerun against a packaged reference build. |
| Milestones | M20 parity | in progress | Nothing new; close the gaps the earlier milestones left (the gaps column of the unit rows). Completion check in port-m20-check: api-tests met (318/28/0 in the target's suites, 4/0/0, port/results/api-tests.md); pixel-check met, the remaining differences are the causes in port/results/pixels.md; ledger not met: the `ported` rows, each with its open gaps. Closed in workbench/contrib/comments: comment threads in diff and multi diff editors, floating ones included, with the floating style's `FloatingWidgetRoom`. | `port/tools/api-tests` gives 318/28/0 (folder) and 4/0/0 (workspace): the reference baseline 356/46/0 less the suites and tests of removed features (chat, lm, the integrated browser, `env.remoteName`) (port/results/api-tests-reference.md); pixel-check of every window has no difference beyond anti-aliasing and the causes listed in `port/results/pixels.md`; every ledger row is `verified`, `removed` or `n/a`. |
| Milestones | M20 multi-instance code editor | open | Upstream every diff side, multi diff file side, notebook cell and walkthrough snippet is its own CodeEditorWidget; the port draws one editable code editor per group. Bound to that one instance today: `text_area` (workbench/editor_view.rs) and its `text_area_bounds`, the group's `viewport` (`EditorGroup`, editor.rs), `editor_focus` and its listeners (workbench.rs), `editors.active()` as the target of every editor command, the cursor, find and suggest, IME through `EntityInputHandler for Workbench` (text_input.rs), mouse selection in `editor_lines`, and the content widgets (hover, suggest, parameter hints, zone widgets) placed against that one area. Rows that need it: `workbench/contrib/multiDiffEditor` (its modified sides are read-only, upstream edits them in place); the diff editor's original pane, drawn by hand (`original_pane`, diff_editor_view.rs), which upstream can focus, select and search in; the stacked editors of notebook cells and the Editor Playground (port/notes.md, Stacked code editors), which draw every unfocused model as lines only and leave its rows exposed to the active editor's mouse handling. | N code editors with their own viewport, focus, cursor and widgets render in one group, and a multi diff modified side takes typing and undo. |
@@ -391,7 +391,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston
| workbench/services/editor | workbench service | M11 | verified | | editor groups (editor_grid.rs grid of gridview.ts, workbench/editor_groups.rs): split (Cmd+\, directions, orthogonal, `workbench.editor.splitSizing`, `openSideBySideDirection`), one text model per resource shared by its editors (editor.rs `SharedModel`), focus and move editors between groups, move group, close group and closeEmptyGroups, join, the 8 editor layouts, flip, even and expand widths, maximize group, group sashes with double click reset; groups reach the host as view columns (`$acceptEditorTabModel`, editorPosition); cargo test -p app editor_groups editor_grid host_sync; pixel-check window split (port/results/layout.md). group drag and drop (editor_groups.rs `group_drop_area`, `split_direction` of editorDropTarget.ts: cargo test -p app a_drag_splits_at_the_edges_and_moves_in_the_center) and the persisted editor part state (editor_groups/part_state.rs: cargo test -p app the_grid_and_its_editors_come_back_from_workspace_storage sticky_editors_come_back_sticky); verified: cargo test -p app editor_grid (grid.test.ts, gridview.test.ts); ui-pair hot-exit.json `restored` vs the reference (port/results/windows.md, milestone 11 verification): the editor part state with its untitled editor restored and focused; locked groups (editor_groups/locked_groups.rs): Lock/Unlock/Toggle Editor Group Lock, the Unlock and Lock Group title icons, the empty group toolbar, opening editors skipping a locked group (editorGroupFinder.ts), `workbench.editor.autoLockGroups`, `locked` stored: cargo test -p app editor_groups (a_locked_group_hands_opened_editors_to_an_unlocked_group, auto_lock_groups_locks_a_new_group_of_a_listed_editor), ui-pair editor-window-compact-lock.json (port/results/auxiliary-windows.md); external drops (dnd.ts `handleDrop`, `handleWorkspaceDrop`): cargo test -p app files_dropped_from_outside_open_in_the_group_the_overlay_shows folders_dropped_from_outside_enter_an_untitled_workspace |
| workbench/services/encryption | workbench service | M10 | removed | | proxy of platform/encryption, removed with it |
| workbench/services/environment | workbench service | M10 | verified | | the workbench environment's paths and args as init data and app paths (platform/environment row): port/tools/settings-check environment; environmentService.test.ts reads the browser workbench's URL options (web only); copilotHomeService removed by decision (no AI) |
-| workbench/services/extensionManagement | workbench service | M18 | ported | [1 S] port/fixtures/extensions/install-tests/tests/index.js:29: since 873b07cc6bd the publisher trust prompt is refused while extension tests run (dialogService.ts `skipDialogs`), so the Open VSX install fails and PORT_GALLERY=1 port/tools/extensions-check passes 4 of 5; the tests' in-memory storage leaves no way to trust the publisher first | installVSIX, install from Open VSX, uninstall, Install from VSIX and their errors: PORT_GALLERY=1 port/tools/extensions-check 5 ok; enablement: cargo test -p app extension_enablement; trusted publishers (`checkForTrustedPublishers` before a gallery install, `extensions.trustedPublishers`, Manage Trusted Extension Publishers: workbench/trusted_publishers.rs, cargo test -p app trusted_publishers; ui-pair port/fixtures/ui-steps/trusted-publisher.json against REF=~/Developer/vscode-ref-openvsx: the "Do you trust the publisher "MS-CEINTL"?" dialog matches, 3% of the dialog crop off where the product name rewraps the text) |
+| workbench/services/extensionManagement | workbench service | M18 | verified | | installVSIX, install from Open VSX, uninstall, Install from VSIX and their errors: PORT_GALLERY=1 port/tools/extensions-check 5 ok; enablement: cargo test -p app extension_enablement; trusted publishers (`checkForTrustedPublishers` before a gallery install, `extensions.trustedPublishers`, product.json `trustedExtensionPublishers`, Manage Trusted Extension Publishers: workbench/trusted_publishers.rs, cargo test -p app trusted_publishers; ui-pair port/fixtures/ui-steps/trusted-publisher.json against REF=~/Developer/vscode-ref-openvsx: the "Do you trust the publisher "MS-CEINTL"?" dialog matches, 3% of the dialog crop off where the product name rewraps the text) |
| workbench/services/extensionRecommendations | workbench service | M18 | verified | | workspaceExtensionsConfig.ts from `.vscode/` and `.vsrustium/` (`.vsrustium/` wins per key), ignored recommendations: cargo test -p app recommendation; ui-pair port/fixtures/extensions/ui-recommendations.json |
| workbench/services/extensions | workbench service | M18 | verified | | extensionsProposedApi.ts `enabledApiProposals` filtering with product.json's allow-list and `--enable-proposed-api`, one policy per window (cargo test -p exthost proposed_api, cargo test -p app a_host_restart_gives_the_extensions); `_deltaExtensions` with `_activateAddedExtensionIfNeeded` and configuration defaults: port/tools/extensions-check, exthost-probe --install-vsix/--uninstall; other extension points the workbench reads (icon themes, static status bar items) are read at startup only |
| workbench/services/files | workbench service | M12 | verified | | the disk provider and watcher client run in process: native/crates/files (disk provider, FSEvents watcher, cargo test -p files); elevatedFileService.ts writeElevated is text_files.rs write_elevated of milestone 8 (port-integrate); verified: api-tests MOCHA_GREP="vscode API - (workspace|file system|env|types|tasks)" at 44a309311e1: every workspace, workspace-fs, workspace events, workspace-watcher and file system test passes, api-workspace 4/0/0 (port/results/api-tests.md "M12 verification"), workspace-fs and file system |
diff --git a/port/tools/extensions-check b/port/tools/extensions-check
index 21192833c5a..6abff54b548 100755
--- a/port/tools/extensions-check
+++ b/port/tools/extensions-check
@@ -11,9 +11,15 @@ for fixture in port/fixtures/extensions/vsix-*; do
done
(cd native && cargo build --release -q -p app)
source port/tools/gui-lock.sh
+source port/tools/vscode-src.sh
tests=$PWD/port/fixtures/extensions/install-tests
+# The tests refuse the publisher trust dialog, so the product trusts the Open VSX case's publisher (bootstrap-meta.ts).
+overrides=$VSCODE_SRC/product.overrides.json
+[ -e "$overrides" ] && { echo "$overrides exists, not overwriting it"; exit 1; }
+trap 'rm -f "$overrides"; rm -rf "$port_gui_lock"' EXIT
+echo '{"trustedExtensionPublishers":["redhat"]}' >"$overrides"
code=0
-PORT_VSIX_DIR=$out VSCODE_GPUI_EXTENSIONS=$REF/extensions timeout 120 native/target/release/vsrustium --user-data-dir "$out/user-data" \
+PORT_VSIX_DIR=$out VSCODE_DEV=1 VSCODE_GPUI_EXTENSIONS=$REF/extensions timeout 120 native/target/release/vsrustium --user-data-dir "$out/user-data" \
--extensionDevelopmentPath="$tests" --extensionTestsPath="$tests/tests" >"$out/log" 2>&1 || code=$?
grep -E '^(ok|FAILED) ' "$out/log" || cat "$out/log"
echo "exit $code"