From 1e008f300b6e223439022fe0e3573a294a1f52c3 Mon Sep 17 00:00:00 2001 From: aamott <54421854+aamott@users.noreply.github.com> Date: Thu, 12 Nov 2026 23:16:48 -0700 Subject: [PATCH 1/6] fix: resolve open SonarQube findings across code, CI, and scripts App code: - Propagate or report async Disposable.dispose() results instead of dropping the promise (bootstrap, extensionPanelMount, panelRegistryModel, tabRegistry). - Replace JSX autoFocus with the dialog system's data-initial-focus / ref-focus equivalents, and give interactive ARIA roles the focus behavior they require (tree tabIndex, menu tabIndex=-1, scrollable region role+tabIndex). - Drop pointless lazy quantifiers in the wiki-link pattern and collapse the inline-code alternation into a single-class lookahead. - Prefer Number.NaN; wrap .map callbacks explicitly; void two floating promises in the example extension. CI: - Pin third-party GitHub Actions to full commit SHAs and scope contents: write to the jobs that publish releases. - cargo build --locked for the CodeQL Rust analysis; commit the keyring-migration probe's lockfile so its deps are reproducible. Scripts: use bash [[ ]] conditional tests in rust-env.sh and sync-cross-android.sh. Remaining findings were triaged in SonarQube as accepted where the flag is intentional or generated (Tauri gen/, plan mockups, dev scripts' PATH resolution, single-class anchored regexes). --- .github/workflows/ci.yml | 14 +- .github/workflows/codeql.yml | 6 +- .github/workflows/nightly.yml | 24 +- .github/workflows/release.yml | 27 +- .gitignore | 1 - apps/desktop/src/extensions/bootstrap.ts | 8 +- apps/desktop/src/journal/AddFieldRow.tsx | 2 +- apps/desktop/src/journal/JournalPanel.tsx | 1 + apps/desktop/src/journal/JournalRow.tsx | 2 +- apps/desktop/src/journal/MetadataField.tsx | 2 +- .../src/panels/extensionPanelMount.tsx | 4 +- .../desktop/src/panels/panelRegistryModel.tsx | 11 +- .../src/settings/controls/UiScaleControl.tsx | 2 +- apps/desktop/src/shell/Menu.tsx | 3 + .../src/shell/phone/PhoneBreadcrumb.tsx | 7 +- .../desktop/src/tabs/editorDisplaySettings.ts | 2 +- apps/desktop/src/tabs/tabRegistry.ts | 12 +- .../src/workspace/DeleteWorkspaceDialog.tsx | 2 +- .../src/workspace/WorkspaceSwitching.tsx | 2 +- examples/extensions/hello-notes/extension.js | 4 +- packages/core/src/markdown.ts | 10 +- scripts/rust-env.sh | 8 +- scripts/sync-cross-android.sh | 16 +- tools/keyring-migration-probe/Cargo.lock | 1526 +++++++++++++++++ 24 files changed, 1633 insertions(+), 63 deletions(-) create mode 100644 tools/keyring-migration-probe/Cargo.lock diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 28096056..949bc02b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: # Install pnpm at the exact version pinned in package.json's # `packageManager` field so local and CI environments match. - name: Install pnpm - uses: pnpm/action-setup@v4 + uses: pnpm/action-setup@f40ffcd9367d9f12939873eb1018b921a783ffaa # v4 with: version: 11.8.0 run_install: false @@ -69,7 +69,7 @@ jobs: uses: actions/checkout@v4 - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable + uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable # Tauri v2 on Linux links against WebKit2GTK, GTK, libsoup and related # system libraries. The build-script crates (glib-sys, gtk-sys, @@ -100,7 +100,7 @@ jobs: run: sudo apt-get install -y sccache mold clang - name: Cache cargo - uses: Swatinem/rust-cache@v2 + uses: Swatinem/rust-cache@e9d7b9f1e587218970671bac74e5511ed9506e6a # v2 with: workspaces: apps/desktop/src-tauri @@ -124,10 +124,10 @@ jobs: uses: actions/checkout@v4 - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable + uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable - name: Cache cargo - uses: Swatinem/rust-cache@v2 + uses: Swatinem/rust-cache@e9d7b9f1e587218970671bac74e5511ed9506e6a # v2 with: workspaces: apps/desktop/src-tauri key: windows @@ -165,7 +165,7 @@ jobs: uses: actions/checkout@v4 - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable + uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable with: targets: ${{ matrix.target }} @@ -180,7 +180,7 @@ jobs: echo "CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$TOOLCHAIN/aarch64-linux-android21-clang" >> "$GITHUB_ENV" - name: Cache cargo - uses: Swatinem/rust-cache@v2 + uses: Swatinem/rust-cache@e9d7b9f1e587218970671bac74e5511ed9506e6a # v2 with: workspaces: apps/desktop/src-tauri key: ${{ matrix.target }} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 9a787e9d..5afcaeeb 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -46,7 +46,7 @@ jobs: uses: actions/checkout@v4 - name: Install pnpm - uses: pnpm/action-setup@v4 + uses: pnpm/action-setup@f40ffcd9367d9f12939873eb1018b921a783ffaa # v4 with: version: 11.8.0 run_install: false @@ -58,7 +58,7 @@ jobs: cache: pnpm - name: Install Rust stable - uses: dtolnay/rust-toolchain@stable + uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable - name: Install Tauri Linux system dependencies run: | @@ -93,7 +93,7 @@ jobs: - name: Build (Rust only) if: matrix.language == 'rust' - run: cargo build --manifest-path apps/desktop/src-tauri/Cargo.toml --lib + run: cargo build --locked --manifest-path apps/desktop/src-tauri/Cargo.toml --lib - name: Perform CodeQL analysis uses: github/codeql-action/analyze@v4 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 78e77859..73463af2 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -17,8 +17,10 @@ on: - cron: "0 2 * * *" workflow_dispatch: +# Least privilege: `check` only reads; the write grants live on the two jobs +# that publish the rolling prerelease. permissions: - contents: write + contents: read jobs: # ───────────────────────────── Check for changes ──────────────────────── @@ -59,6 +61,9 @@ jobs: # ───────────────────────────── Desktop (Linux / macOS / Windows) ──────── desktop: name: ${{ matrix.label }} + # tauri-action creates/overwrites the nightly prerelease. + permissions: + contents: write needs: check if: needs.check.outputs.should-build == 'true' strategy: @@ -86,7 +91,7 @@ jobs: ref: main - name: Install pnpm - uses: pnpm/action-setup@v4 + uses: pnpm/action-setup@f40ffcd9367d9f12939873eb1018b921a783ffaa # v4 with: version: 11.8.0 run_install: false @@ -98,7 +103,7 @@ jobs: cache: pnpm - name: Install Rust stable - uses: dtolnay/rust-toolchain@stable + uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable with: targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} @@ -123,7 +128,7 @@ jobs: patchelf - name: Cache cargo - uses: swatinem/rust-cache@v2 + uses: swatinem/rust-cache@e9d7b9f1e587218970671bac74e5511ed9506e6a # v2 with: workspaces: apps/desktop/src-tauri @@ -131,7 +136,7 @@ jobs: run: pnpm install --frozen-lockfile - name: Build and publish - uses: tauri-apps/tauri-action@v0.6.2 + uses: tauri-apps/tauri-action@1ddc7b49b13c3038297360482fcb3e058764d7c9 # v0.6.2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} @@ -178,6 +183,9 @@ jobs: name: Android needs: check if: needs.check.outputs.should-build == 'true' && vars.ANDROID_RELEASE_ENABLED == 'true' + # Uploads the APK to the nightly prerelease via `gh release upload`. + permissions: + contents: write runs-on: ubuntu-latest steps: @@ -187,7 +195,7 @@ jobs: ref: main - name: Install pnpm - uses: pnpm/action-setup@v4 + uses: pnpm/action-setup@f40ffcd9367d9f12939873eb1018b921a783ffaa # v4 with: version: 11.8.0 run_install: false @@ -199,7 +207,7 @@ jobs: cache: pnpm - name: Install Rust stable - uses: dtolnay/rust-toolchain@stable + uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable with: targets: aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android @@ -239,7 +247,7 @@ jobs: done - name: Cache cargo - uses: swatinem/rust-cache@v2 + uses: swatinem/rust-cache@e9d7b9f1e587218970671bac74e5511ed9506e6a # v2 with: workspaces: apps/desktop/src-tauri key: android diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1a8e27c8..515b716c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,9 +30,10 @@ on: workflow_dispatch: # `contents: write` is needed by tauri-action to create the GitHub Release and -# by the Android job to `gh release upload` assets to it. +# by the Android job to `gh release upload` assets to it — so it is granted on +# those two jobs, not workflow-wide. permissions: - contents: write + contents: read jobs: # ───────────────────────────── Desktop (Linux / macOS / Windows) ──────── @@ -41,6 +42,9 @@ jobs: # only uploads workflow artifacts (`tagName` is empty so no release is made). desktop: name: ${{ matrix.label }} + # tauri-action drafts the release and uploads bundles on tag pushes. + permissions: + contents: write strategy: fail-fast: false matrix: @@ -71,7 +75,7 @@ jobs: run: node scripts/version.mjs --check --tag "${{ github.ref_name }}" - name: Install pnpm - uses: pnpm/action-setup@v4 + uses: pnpm/action-setup@f40ffcd9367d9f12939873eb1018b921a783ffaa # v4 with: version: 11.8.0 run_install: false @@ -83,7 +87,7 @@ jobs: cache: pnpm - name: Install Rust stable - uses: dtolnay/rust-toolchain@stable + uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable with: # macOS builds target both architectures; other platforms build natively. targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} @@ -109,7 +113,7 @@ jobs: patchelf - name: Cache cargo - uses: swatinem/rust-cache@v2 + uses: swatinem/rust-cache@e9d7b9f1e587218970671bac74e5511ed9506e6a # v2 with: workspaces: apps/desktop/src-tauri @@ -120,7 +124,7 @@ jobs: # Pinned to v0.6.2 (released 2026-03-14). The @v1 major alias does not # resolve in GitHub Actions (tauri-apps/tauri-action#1311), so we pin to # an explicit, vetted tag instead of a floating major version. - uses: tauri-apps/tauri-action@v0.6.2 + uses: tauri-apps/tauri-action@1ddc7b49b13c3038297360482fcb3e058764d7c9 # v0.6.2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Signs the updater artifacts. The app only accepts an update signed @@ -200,6 +204,9 @@ jobs: # point building an unsigned release bundle for distribution, and failing # loudly here is better than shipping an unsigned artifact by accident. if: ${{ vars.ANDROID_RELEASE_ENABLED == 'true' }} + # Uploads the APK to the release via `gh release upload`. + permissions: + contents: write runs-on: ubuntu-latest steps: @@ -213,7 +220,7 @@ jobs: run: node scripts/version.mjs --check --tag "${{ github.ref_name }}" - name: Install pnpm - uses: pnpm/action-setup@v4 + uses: pnpm/action-setup@f40ffcd9367d9f12939873eb1018b921a783ffaa # v4 with: version: 11.8.0 run_install: false @@ -225,7 +232,7 @@ jobs: cache: pnpm - name: Install Rust stable - uses: dtolnay/rust-toolchain@stable + uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable with: # All four Android ABIs Tauri builds by default. targets: aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android @@ -275,7 +282,7 @@ jobs: done - name: Cache cargo - uses: swatinem/rust-cache@v2 + uses: swatinem/rust-cache@e9d7b9f1e587218970671bac74e5511ed9506e6a # v2 with: workspaces: apps/desktop/src-tauri key: android @@ -357,7 +364,7 @@ jobs: sudo udevadm trigger --name-match=kvm - name: Smoke-test minified Android release - uses: reactivecircus/android-emulator-runner@v2 + uses: reactivecircus/android-emulator-runner@4c44018e59b437e86cdfc41da381398f93ed8808 # v2 with: api-level: 35 target: google_apis diff --git a/.gitignore b/.gitignore index b9e681c3..13331d56 100644 --- a/.gitignore +++ b/.gitignore @@ -67,5 +67,4 @@ ehthumbs.db temp/ tmp/ tools/keyring-migration-probe/target/ -tools/keyring-migration-probe/Cargo.lock .zvec-grep diff --git a/apps/desktop/src/extensions/bootstrap.ts b/apps/desktop/src/extensions/bootstrap.ts index aa229f08..282b47a8 100644 --- a/apps/desktop/src/extensions/bootstrap.ts +++ b/apps/desktop/src/extensions/bootstrap.ts @@ -106,7 +106,13 @@ export function bootstrapExtensions(options: BootstrapOptions = {}): ExtensionBo const failedManifests: BootstrapEntry[] = []; const disposeAll = (disposables: Disposable[]): Disposable[] => { - for (const disposable of disposables) disposable.dispose(); + for (const disposable of disposables) { + // Dispose may settle async, but this rollback helper is synchronous — + // report failures and keep unwinding rather than dropping the promise. + void Promise.resolve(disposable.dispose()).catch((error: unknown) => { + console.error("[extensions] Failed to dispose a bootstrap resource.", error); + }); + } return []; }; diff --git a/apps/desktop/src/journal/AddFieldRow.tsx b/apps/desktop/src/journal/AddFieldRow.tsx index ae0daea2..c2998979 100644 --- a/apps/desktop/src/journal/AddFieldRow.tsx +++ b/apps/desktop/src/journal/AddFieldRow.tsx @@ -88,7 +88,7 @@ export function AddFieldRow({ available, existingKeys, onAdd, readOnly = false } return (
el?.focus()} aria-label="New field name" value={draft} onChange={(event) => setDraft(event.target.value)} diff --git a/apps/desktop/src/journal/JournalPanel.tsx b/apps/desktop/src/journal/JournalPanel.tsx index 2552ed10..4f5b6c02 100644 --- a/apps/desktop/src/journal/JournalPanel.tsx +++ b/apps/desktop/src/journal/JournalPanel.tsx @@ -354,6 +354,7 @@ export function JournalPanel({
el?.focus()} aria-label="Rename entry" value={renaming.draft} onChange={(e) => onRenameChange?.(e.target.value)} diff --git a/apps/desktop/src/journal/MetadataField.tsx b/apps/desktop/src/journal/MetadataField.tsx index 981cdda2..157f6182 100644 --- a/apps/desktop/src/journal/MetadataField.tsx +++ b/apps/desktop/src/journal/MetadataField.tsx @@ -110,7 +110,7 @@ export function MetadataField({ definition, value, size = "compact", onSet, read {adding ? ( el?.focus()} disabled={readOnly} aria-label={`New value for ${definition.label}`} value={draft} diff --git a/apps/desktop/src/panels/extensionPanelMount.tsx b/apps/desktop/src/panels/extensionPanelMount.tsx index 92c6f249..642df39e 100644 --- a/apps/desktop/src/panels/extensionPanelMount.tsx +++ b/apps/desktop/src/panels/extensionPanelMount.tsx @@ -144,7 +144,9 @@ export function ExtensionPanelMountPoint({ try { if (typeof teardown === "function") (teardown as () => void)(); else if (typeof (teardown as Disposable).dispose === "function") { - (teardown as Disposable).dispose(); + // Dispose may settle later; this teardown contract is sync, so a + // rejected promise still has to reach the console. + void Promise.resolve((teardown as Disposable).dispose()).catch(reportToConsole); } else { throw new TypeError( "A panel mount cleanup must be a function, a Disposable, or a list of them." diff --git a/apps/desktop/src/panels/panelRegistryModel.tsx b/apps/desktop/src/panels/panelRegistryModel.tsx index 28f63768..dd4bb9b4 100644 --- a/apps/desktop/src/panels/panelRegistryModel.tsx +++ b/apps/desktop/src/panels/panelRegistryModel.tsx @@ -417,20 +417,25 @@ export function createDesktopPanelRegistry( const placeholderHandles = new Map(); const register = (contribution: DesktopPanelContribution): Disposable => { if (coreRegistry.get(contribution.id)?.placeholder === true) { - placeholderHandles.get(contribution.id)?.dispose(); + // Registration is synchronous, so an async placeholder disposal can + // only be reported, not awaited. + void Promise.resolve(placeholderHandles.get(contribution.id)?.dispose()).catch( + (error: unknown) => + console.error(`[panels] Failed to dispose placeholder "${contribution.id}".`, error) + ); } const handle = coreRegistry.register(contribution); if (contribution.placeholder !== true) return handle; placeholderHandles.set(contribution.id, handle); let disposed = false; return { - dispose: (): void => { + dispose: (): void | Promise => { if (disposed) return; disposed = true; if (placeholderHandles.get(contribution.id) === handle) { placeholderHandles.delete(contribution.id); } - handle.dispose(); + return handle.dispose(); } }; }; diff --git a/apps/desktop/src/settings/controls/UiScaleControl.tsx b/apps/desktop/src/settings/controls/UiScaleControl.tsx index b7f24221..bafa33e8 100644 --- a/apps/desktop/src/settings/controls/UiScaleControl.tsx +++ b/apps/desktop/src/settings/controls/UiScaleControl.tsx @@ -18,7 +18,7 @@ import { UI_SCALE_PRESETS } from "../uiModuleDefaults"; * in sorted order so the selection always names what is actually applied. */ export function UiScaleControl({ definition, value, onChange }: ControlProps) { - const current = typeof value === "number" && Number.isFinite(value) ? value : NaN; + const current = typeof value === "number" && Number.isFinite(value) ? value : Number.NaN; const options = !Number.isNaN(current) && !UI_SCALE_PRESETS.includes(current) ? [...UI_SCALE_PRESETS, current].sort((a, b) => a - b) diff --git a/apps/desktop/src/shell/Menu.tsx b/apps/desktop/src/shell/Menu.tsx index 41f773b1..277696e0 100644 --- a/apps/desktop/src/shell/Menu.tsx +++ b/apps/desktop/src/shell/Menu.tsx @@ -157,6 +157,9 @@ export function Menu({ placement.className )} role="menu" + // Items own the tab stop; -1 makes the menu itself focusable for + // programmatic focus, which ARIA's menu pattern requires. + tabIndex={-1} aria-label={label} style={placement.style} onKeyDown={handleKeyDown} diff --git a/apps/desktop/src/shell/phone/PhoneBreadcrumb.tsx b/apps/desktop/src/shell/phone/PhoneBreadcrumb.tsx index dc94c043..690e01df 100644 --- a/apps/desktop/src/shell/phone/PhoneBreadcrumb.tsx +++ b/apps/desktop/src/shell/phone/PhoneBreadcrumb.tsx @@ -99,7 +99,7 @@ export function PhoneBreadcrumb({ segments }: { readonly segments: readonly stri overflowed ? "left-full -translate-x-full" : "left-1/2 -translate-x-1/2" )} > - {crumbs.map(crumb)} + {crumbs.map((segment, index) => crumb(segment, index))}
{overflowed && ( Current location
-
{crumbs.map(crumb)}
+
{crumbs.map((segment, index) => crumb(segment, index))}
diff --git a/apps/desktop/src/tabs/editorDisplaySettings.ts b/apps/desktop/src/tabs/editorDisplaySettings.ts index 6dd9af74..0ac2c026 100644 --- a/apps/desktop/src/tabs/editorDisplaySettings.ts +++ b/apps/desktop/src/tabs/editorDisplaySettings.ts @@ -25,7 +25,7 @@ const EDITOR_FONT_SIZE_DEFAULT = 16; export function resolveEditorFontSize(value: unknown): number { // Numeric-only: the settings contract stores a number, and a coerced // non-number ("" → 0) must never shrink the editor toward the floor. - const parsed = typeof value === "number" ? value : NaN; + const parsed = typeof value === "number" ? value : Number.NaN; if (!Number.isFinite(parsed)) return EDITOR_FONT_SIZE_DEFAULT; return Math.min( EDITOR_FONT_SIZE_MAX, diff --git a/apps/desktop/src/tabs/tabRegistry.ts b/apps/desktop/src/tabs/tabRegistry.ts index c3d34dd3..f8323b04 100644 --- a/apps/desktop/src/tabs/tabRegistry.ts +++ b/apps/desktop/src/tabs/tabRegistry.ts @@ -139,7 +139,12 @@ export function createDesktopTabRegistry( const register = (view: DesktopTabView): Disposable => { if (views.get(view.kind)?.placeholder === true) { - placeholderHandles.get(view.kind)?.dispose(); + // Registration is synchronous, so an async placeholder disposal can + // only be reported, not awaited. + void Promise.resolve(placeholderHandles.get(view.kind)?.dispose()).catch( + (error: unknown) => + console.error(`[tabs] Failed to dispose placeholder "${view.kind}".`, error) + ); } const registration: TabRegistration = { kind: view.kind, @@ -160,7 +165,7 @@ export function createDesktopTabRegistry( let disposed = false; const handle: Disposable = { - dispose: (): void => { + dispose: (): void | Promise => { if (disposed) return; disposed = true; if (placeholderHandles.get(view.kind) === handle) { @@ -168,8 +173,9 @@ export function createDesktopTabRegistry( } // Core fires subscribers here; entries() derives from core so the // removed view is already absent before we clean up `views`. - coreHandle.dispose(); + const coreDisposal = coreHandle.dispose(); if (views.get(view.kind) === view) views.delete(view.kind); + return coreDisposal; } }; if (view.placeholder === true) placeholderHandles.set(view.kind, handle); diff --git a/apps/desktop/src/workspace/DeleteWorkspaceDialog.tsx b/apps/desktop/src/workspace/DeleteWorkspaceDialog.tsx index b17f7bd4..c229ef9e 100644 --- a/apps/desktop/src/workspace/DeleteWorkspaceDialog.tsx +++ b/apps/desktop/src/workspace/DeleteWorkspaceDialog.tsx @@ -61,7 +61,7 @@ export function DeleteWorkspaceDialog({