GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Stage 1: ファイル I/O を本物実装し path-guard で workspace 防御を導入 by ymnao · Pull Request #6 · ymnao/scripta

Conversation

@ymnao

@ymnao ymnao commented May 3, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Owner

概要

Stage 1 のスコープ完了。Tauri → Electron 全書き直しの過程で、Stage 0b ではメモリ Map ダミーだった fs IPC / settings IPC を Node.js の本物実装に置換し、複数ウィンドウ対応の workspace 単位パストラバーサル防御を導入する。

これにより、旧 Tauri 版で開いていたワークスペースを新 Electron 版でも開いて .md を読み書き保存できるようになる(移行ロードマップの Stage 1 完了判定)。

関連 Issue

なし

移行 Stage

  • Stage 0: 雛形 + フロント表示確認
  • Stage 1: ファイル I/O
  • Stage 2: ワークスペース・ファイルツリー・ファイル監視
  • Stage 3: 全文検索(ripgrep sidecar)
  • Stage 4: Git Sync
  • Stage 5: OGP / PDF / アップデート
  • Stage 6: 仕上げ・配布・切り替え

変更内容

fs IPC の本物実装

  • electron/main/ipc/fs.ts を fs/promises ベースに書き換え。read / write / writeNew / list / createFile / createDirectory / pathExists / fileExists / rename / delete を実装
  • writeNewFile は fs.open(..., "wx") で同名既存時に EEXIST を投げる atomic open
  • createFile / createDirectory は事前 existence check を撤去し EEXIST catch に置換(race-free + syscall 削減)
  • 削除は shell.trashItem を使用(unlink フォールバックは取らない —「削除されない」より「データ消失」の方が悪い)
  • 全 read/list/create/rename/delete impl が senderId を受け取り、IPC ハンドラで event.sender.id を渡す(cross-window 漏洩防止)
  • 旧 Tauri 互換のエラーメッセージプレフィックス(Already exists: / Source not found: / Target already exists: / Not found:)を electron/main/utils/fs-errors.ts のファクトリに集約
  • フロント src/lib/errors.ts に Node エラーコード対応を追加(ENOENT / EACCES / EPERM / EEXIST / ENOSPC / EROFS / EAGAIN / EBUSY / ENAMETOOLONG / ENOTEMPTY / EMFILE / Permission denied / Invalid path)。EMFILE / "too many open files" は non-transient(無駄リトライ防止)

path-guard(パストラバーサル防御)

  • electron/main/utils/path-guard.ts を新設
  • validatePath: 絶対パス / null byte / 空文字列の構造チェック
  • 対象パスを realpathBestEffort(最も近い実在祖先を realpath し suffix 付与)で正規化し、登録ルート配下かを path.relative ベースで判定。.. プレフィックス偽陽性も rel === ".." または rel.startsWith("..${sep}") で厳密化(..backup のような正当パスを誤拒否しない)
  • symlink-in-the-middle や macOS の /var → /private/var の解決ズレを吸収。realpath 結果は LRU キャッシュ(256 entries)で同期 I/O のオーバーヘッドを軽減
  • fail-closed: ウィンドウ未登録時はすべて拒否
  • window-scoped: allowedRoots は Map<webContentsId, Set<string>> 構造。isPathAllowed / assertPathAllowed / assertWritePathAllowed がすべて windowId を受け取り、別ウィンドウの workspace は read/list/rename/delete/write どれでも見えない
  • isPathAllowed は boolean 契約(不正入力でも例外を飲んで false)、assertPathAllowed は validate エラーを Invalid path: ... として伝播
  • 違反時は汎用「Permission denied: outside workspace」のみ throw(違反パスは main 側 console.warn だけに記録、情報漏洩防止)
  • dialog.showSaveDialog でユーザーが明示選択した保存先は transient write path として 1 回限り許可(HTML / Prompt エクスポートが Desktop / Downloads でも動く)。transient は (a) ダイアログを開いた window のスコープのみ、(b) 書き込み成功後 に consume(withRetry の再試行と整合)、(c) window close で cleanup される短命 capability

workspace 管理(複数ウィンドウ対応)

  • electron/main/ipc/workspace.ts の workspace:set IPC で各ウィンドウが現在開いている workspace を申告
  • 各 window が自分の root Set を持つ(旧設計の ref-count は撤廃。複数ウィンドウが同じ path を共有しても、それぞれ独立に register/unregister される)
  • ウィンドウ close で unregisterWindow(webContentsId) が allowedRoots と transientWritePaths をまとめて cleanup
  • workspace:set は 承認済みパスのみ 受け付ける(renderer 任意 path での権限昇格を防ぐ):
    • dialog:open-directory を通過した path は approveWorkspacePath で approve 集合に追加
    • 起動時に saved workspacePath も approve(approveSavedWorkspaceFromSettings)
    • 未承認 path は throw
  • Sidebar.tsx / AppLayout.tsx で setWorkspacePath の前に await workspaceSet(path) を呼び、FileTree が listDirectory を打ち始める前に main 側 register を完了させる(race 解消)
  • 復元失敗時は workspaceSet(null) で main 側状態も巻き戻す
  • ダイアログの親ウィンドウは BrowserWindow.fromWebContents(event.sender) で sender 由来に統一(focused / first との不整合を解消)

settings の永続化

  • electron/main/ipc/settings.ts を app.getPath('userData')/settings.json への永続化に置換
  • write-file-atomic で tmp → fsync → rename を保証(renameSync 単独だと OS バッファ未 flush でクラッシュすると 0 バイトや旧データが残る事故あり)
  • load の fallback は ENOENT(初回起動)と JSON 破損のみに限定。EACCES / EIO 等は throw して呼び出し側に伝播(黙って空にすると後続 save で既存設定を上書き消失させる)
  • electron-store は v10 ESM-only で CJS ビルドからの利用に摩擦が大きく、v8 系は実質メンテ停止のため不採用
  • prototype pollution 対策: cache を Object.create(null) で null-prototype 化、getValue を Object.hasOwn ベースに、isSafeSettingsKey で識別子相当のキー(^[A-Za-z_][A-Za-z0-9_]*$)かつ __proto__ / constructor / prototype を拒否
  • 承認境界の保護: RESERVED_KEYS = {"workspacePath"} を導入し、renderer から settings:set / settings:delete で書き換え不能化。永続化は workspace:set 経由でのみ行う persistWorkspacePath を main 専用に

テスト基盤の拡張

  • vitest.config.ts を projects 構成に変更し、main プロセス(node 環境)と renderer(jsdom)でテスト環境を分離
  • 各 project に extends: true を付け plugins / alias を継承

その他

  • Stage 0b 一時用の DemoView と ?demo=1 経路を撤去

動作確認

  • pnpm format / pnpm lint / pnpm typecheck 全 pass
  • pnpm test — 64 ファイル / 1316 通過 / 2 skipped
  • pnpm vitest run --sequence.shuffle --sequence.seed=42 / 999 / 1234 で shuffle 安定
  • pnpm build — main / preload / renderer 全 build OK
  • path-guard: symlink 抜け / .. プレフィックス偽陽性 / fail-closed / window-scoped 隔離 / transient write capability の retry-friendly consume / 違反パスのエラー漏洩なし を単体テストで検証
  • workspace: 単一・複数ウィンドウ独立・close 時 cleanup・approve 境界・symlink alias を単体テストで検証
  • settings: ENOENT / 破損 JSON は空 fallback、EACCES(chmod 0o000)は throw、prototype pollution 防御、reserved key reject を単体テストで検証

スクリーンショット

UI 変更なし。

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ymnao and others added 9 commits May 2, 2026 13:34
@ymnao @claude
chore: vitest を main(node) / renderer(jsdom) の projects 構成に拡張
c4fdde0
- main プロセス(electron/)と renderer(src/)でテスト環境を分離
- 各 project に extends: true を付け plugins/alias を継承

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao @claude
feat: パストラバーサル防御の path-guard を追加(symlink 対策の realpath ベース)
1fd34cb
- validatePath: 絶対パス / null byte / 空文字列の構造チェック
- registerWorkspaceRoot: ワークスペースルートを realpath で正規化して登録
- isReadAllowed / isWriteAllowed: 対象パスを realpath best-effort で正規化し
  登録ルート配下かを path.relative ベースで判定
- 未存在パスは「最も近い実在する祖先を realpath して suffix 付与」する
  best-effort 戦略で、symlink-in-the-middle や macOS の /var → /private/var
  といった symlink 解決状態のズレを吸収する
- assertReadAllowed / assertWriteAllowed: 違反時はパスをエラーに含めず
  汎用「Permission denied: outside workspace」のみ throw(情報漏洩防止)。
  違反パスは main 側 console.warn のみに記録
- watcher.ts の startWatcher / stopWatcher で workspace ルートを自動登録 / 解除

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao @claude
feat: fs IPC を fs/promises ベースの本物実装に置換
045ef00
- read/write/writeNew/list/createFile/createDirectory/pathExists/fileExists
  /rename/delete を Node.js fs/promises で実装
- writeNewFile は fs.open(..., "wx") で同名既存時に EEXIST を投げる atomic open
- write 系は path-guard の assertWriteAllowed、read 系は assertReadAllowed を
  全ハンドラで実行
- 削除は shell.trashItem を使用(unlink フォールバックは取らない —
  「削除されない」より「データ消失」の方が悪いため)
- 旧 Tauri と互換のエラーメッセージを維持:
  Already exists: / Source not found: / Target already exists: / Not found:
- errors.ts に Node エラーコード対応を追加:
  ENOENT / EACCES / EPERM / EEXIST / ENOSPC / EROFS / EAGAIN / EBUSY /
  ENAMETOOLONG / ENOTEMPTY / EMFILE
- errors.ts に Permission denied: / Invalid path: のパターンを追加
- isTransientError の non-transient リストに Node コードと
  Permission denied / Invalid path を追加

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao @claude
feat: settings を write-file-atomic で永続化
626fe8e
- メモリ Map ダミーから app.getPath('userData')/settings.json への永続化に置換
- write-file-atomic を採用し tmp への書き込み → fsync → rename を保証
  (renameSync 単体では OS バッファ未 flush のままクラッシュすると
  0 バイトや旧データが残る事故が起こりうる)
- 起動後一度だけ JSON を読み込んでメモリキャッシュし、settings:save で flush
- 破損 JSON や非オブジェクト値は空オブジェクトにフォールバック
- settings:get は未設定キーで null を返す(旧 Tauri 版との互換)
- electron-store は v10 ESM-only で CJS ビルドからの利用に摩擦が大きく、
  v8 系は実質メンテ停止のため不採用

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao @claude
chore: Stage 0b 一時用の DemoView と ?demo=1 経路を撤去
4984fb5
- src/components/demo/DemoView.tsx と sample-markdown.ts を削除
- App.tsx から demo クエリ分岐を削除
- DemoView は Stage 0b で「Live Preview のすべてのデコレーションが
  Chromium で破綻なく描画される」ことを確認するための一時ビューだった。
  Stage 1 で実ファイル編集が可能になるため役目を終えたので撤去する

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao @claude
refactor: レビュー指摘を反映してシンプル化
9ccd0a1
- fs-errors.ts を新設し、Already exists / Source not found / Target already exists /
  Not found のエラーメッセージプレフィックスをファクトリ関数に集約。
  生文字列の散らばりを解消(タイポで翻訳が落ちる事故を防ぐ)+ isErrnoCode ヘルパーも提供
- createFileImpl / createDirectoryImpl の事前 existence check を撤去し、
  open("wx") / 非 recursive mkdir の EEXIST catch に置換(race-free + syscall 削減)
- path-guard: isReadAllowed / isWriteAllowed のロジックは完全重複していたため
  isPathAllowed 1 本に統合。assertReadAllowed / assertWriteAllowed も
  assertPathAllowed に統一
- settings.ts: 不要な existsSync を削除し、readFileSync の ENOENT catch で
  ENOENT も JSON 破損も同じく空オブジェクトにフォールバックする形に統一
- fs.test.ts: 何も検証していない path normalization describe を削除、
  shell.trashItem mock を rm 副作用付きから pure な mockResolvedValue(undefined) に変更

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao @claude
fix: path-guard の fail-open と settings load の異常握りつぶしを修正
1f145e1
レビュー指摘 2 件への対応。

【1. path-guard の fail-open (High)】

allowedRoots.size === 0 のときに任意 path を許可していたため、
アプリ起動直後 / ワークスペース未選択時 / watcher:stop 後は
preload 経由で fs:* IPC を叩けば /etc やホームディレクトリも
読めてしまう抜け穴があった。本変更の目的(workspace 外を拒否する)と
逆方向だったので塞ぐ。

- isPathAllowed を fail-closed に変更(allowedRoots.size === 0 → false)
- main/index.ts の app.whenReady で saved workspacePath を auto-register
  する bootstrap を追加。前回までのワークスペースは利用継続できる
- path-guard.test.ts の back-compat テストを fail-closed テストに置換

【2. settings load の異常握りつぶし (Medium)】

readFileSync / JSON.parse の失敗をすべて空オブジェクトにフォールバック
していたため、EACCES や一時 I/O 異常で既存設定が見えなくなり、
その後の settings:set + settings:save で上書き消失する事故が起こりうる。

- ENOENT (初回起動) と JSON 破損のみ空オブジェクトにフォールバック
- それ以外(EACCES / EIO 等)は throw して呼び出し側に伝播
- chmod 0o000 で読み取り不可のファイルを作って throw を検証するテストを追加
  (Windows は chmod の意味が薄いため skip)
- path-guard の bootstrap 用に getWorkspacePathFromSettings を追加。
  load() が throw した場合は null を返し、未登録のまま起動を続行する

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao @claude
fix: workspace 切替 race とエクスポート保存の Permission denied を修正
9458b98
レビュー指摘 2 件への対応。

【1. エクスポートが workspace 外に保存できない (High)】

exportAsHtml / exportAsPrompt は dialog.showSaveDialog でユーザーが
明示選択した保存先(Desktop, Downloads 等)に writeFile するが、
fs:write が常に assertPathAllowed を通すようになったことで
workspace 外への通常エクスポートが Permission denied で失敗していた。

- path-guard に「1 回限り許可される transient write path」機構を追加
- dialog:save ハンドラでユーザー承認済みの filePath を transient register
- assertPathAllowed が transient マッチで consume(Set.delete)して return
- 「ワークスペース制約付き fs:*」と「ユーザー意図的な保存先」を明確に分離

【2. 新規 workspace 選択時の race (High)】

Sidebar.tsx の handleOpenFolder は openDirectoryPicker → setWorkspacePath
だけで、main 側 root 登録は watcher:start にしかなかった。
一方で workspacePath が変わると FileTree が即 listDirectory を打つため、
register より listDirectory が先行して Permission denied が混ざる設計になっていた。

- workspace:set IPC を新設(electron/main/ipc/workspace.ts)。
  setActiveWorkspace で旧 unregister + 新 register を 1 ステップで完了
- watcher.ts から register 処理を削除し「監視のみ」の責務に戻す
  (Stage 2 で chokidar 実装に置き換えるための土台)
- bootstrap も同じ setActiveWorkspace 経路を通すよう統一
- Sidebar.tsx と AppLayout.tsx で setWorkspacePath の前に
  await workspaceSet(path) を呼ぶ。これで FileTree や他 hook が
  fs:* を打ち始める前に main 側 register が完了する
- preload/api.ts、preload/index.ts、commands.ts、api-mock.ts に
  workspaceSet を追加

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao @claude
fix: workspace 管理を window 単位 + ref-count 化、復元失敗時に main 側状態を巻き戻し
fbb0d27
レビュー指摘 2 件への対応。

【1. 複数ウィンドウ時の workspace 権限相互破壊 (High)】

setActiveWorkspace はプロセス全体で単一 activeWorkspace しか持たず、
ウィンドウ A で /A、ウィンドウ B で /B を開くと、片方の workspace:set が
もう片方の root を unregisterWorkspaceRoot で剥がしてしまっていた。
複数ウィンドウ対応として後退になっていた。

- windowWorkspaces: Map<webContentsId, string> で window 単位の workspace を保持
- setActiveWorkspaceForWindow: 旧パスは「他 window で使われていなければ」のみ
  unregister、新パスは「まだ register されていなければ」register(ref-count)
- workspace:set ハンドラは event.sender.id で window を識別
- unregisterWindow: ウィンドウ close 時の cleanup。同じく ref-count で判定
- main/index.ts の closed ハンドラで unregisterWindow を呼ぶ

【2. 保存済み workspace 復元失敗時に main 側 root が残る (Medium)】

bootstrapWorkspaceFromSettings で setActiveWorkspace(savedPath) → 失敗時は
renderer 側 listDirectory が catch して saveWorkspacePath(null) するだけで、
main 側に register された root が残り続けていた。fail-closed の建前と
ランタイム状態が一致しない。

- bootstrapWorkspaceFromSettings を削除。registration は renderer 側
  AppLayout が settings から読み込んだ workspacePath を workspaceSet で
  申告した時点で行う(window 単位の管理に統一)
- AppLayout.tsx の listDirectory 失敗 catch で workspaceSet(null) を呼び、
  main 側状態も巻き戻す
- 不要になった getWorkspacePathFromSettings を settings.ts から削除

ref-count とウィンドウ分離を検証する 10 ケースのテストを workspace.test.ts に追加。

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings May 3, 2026 14:09
Copilot started reviewing on behalf of ymnao May 3, 2026 14:09
View session
Copilot AI reviewed May 3, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Pull request overview

Stage 1(ファイル I/O)として、Electron main 側の fs/settings IPC を実ファイル実装へ置き換えつつ、workspace 単位の path traversal 防御(path-guard)と複数ウィンドウ対応の workspace 登録を導入する PR です。

Changes:

  • fs IPC を fs/promises ベースの実装へ移行し、read/write/list/rename/delete 等を提供
  • path-guard を新設し、workspace 配下のみ許可(+ SaveDialog 選択先は 1 回限り許可)を実装
  • settings を userData/settings.json に永続化し、Vitest を renderer/main 分離でテスト拡張

Reviewed changes

Copilot reviewed 27 out of 28 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
vitest.config.ts renderer/jsdom と main/node のテストプロジェクト分離
src/lib/errors.ts Node errno / path-guard 系エラーの翻訳パターン追加
src/lib/errors.test.ts 追加したエラー翻訳・transient 判定のテスト追加
src/lib/commands.ts workspaceSet コマンドを renderer から呼べるよう追加
src/components/layout/Sidebar.tsx フォルダ選択時に workspaceSet を先に実行して race 回避
src/components/layout/AppLayout.tsx hydrate 時に workspaceSet を行い、失敗時に main 側登録も巻き戻し
src/components/layout/AppLayout.test.tsx commands mock に workspaceSet 追加
src/components/demo/sample-markdown.ts Stage 0b デモ用サンプルの削除
src/components/demo/DemoView.tsx Stage 0b デモビューの削除
src/test-utils/api-mock.ts window.api.workspaceSet のデフォルトモック追加
src/App.tsx ?demo=1 経路の削除
package.json write-file-atomic と型定義を追加
pnpm-lock.yaml 依存追加に伴う lock 更新
electron/preload/index.ts preload API に workspaceSet を公開
electron/preload/api.ts Api 型に workspaceSet を追加
electron/main/utils/path-guard.ts workspace root/transient write path 管理とガード実装追加
electron/main/utils/path-guard.test.ts path-guard の単体テスト追加
electron/main/utils/fs-errors.ts 旧 Tauri 互換の fs エラーメッセージ生成を集約
electron/main/ipc/workspace.ts ウィンドウ単位 workspace 登録 + ref-count 管理の IPC 実装追加
electron/main/ipc/workspace.test.ts workspace IPC ロジックの単体テスト追加
electron/main/ipc/watcher.ts Stage 1 の no-op 明示コメント追加
electron/main/ipc/settings.ts settings を settings.json へ永続化(atomic write)
electron/main/ipc/settings.test.ts settings 永続化の単体テスト追加
electron/main/ipc/index.ts workspace IPC の登録を追加
electron/main/ipc/fs.ts fs IPC を実ファイル I/O + path-guard 前提に置換
electron/main/ipc/fs.test.ts fs IPC 実装の単体テスト追加
electron/main/ipc/dialog.ts SaveDialog の選択先を transient write path として登録
electron/main/index.ts window close 時の workspace cleanup と bootstrap 方針コメント追加
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread electron/main/ipc/workspace.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread electron/main/utils/path-guard.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread electron/main/utils/path-guard.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread electron/main/ipc/fs.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ymnao @claude
fix: PR #6 レビュー指摘 4 件への対応
75b1ae0
【1. workspace ref-count のパス比較が表記揺れに弱い (must)】

windowWorkspaces は raw 文字列で path を持っており、symlink 経由 / 大文字小文字差 /
/var → /private/var などで「同じ実体なのに ref-count で別物扱い」となり、
他 window がまだ使っているのに unregister が走る事故があった。

- path-guard に canonicalize() を export(validatePath + realpath 正規化)
- workspace.ts は Map に canonical 形だけを保存し、比較もすべて canonical 同士
- symlink 経由で別パスを送っても同一 workspace と扱われることを ref-count テストで検証

【2. path-guard.ts のコメントが現状と矛盾 (nits)】

旧 bootstrap 経路の説明が残っていたため、現状(renderer 側 AppLayout が
workspaceSet で申告する)に合わせて書き直し。

【3. path-guard が validatePath を呼ばずフットガン (recommend)】

isPathAllowed / assertPathAllowed が realpath だけ呼んでいたため、呼び出し側が
誤って相対パスを渡すと cwd 解釈で false-positive になりうる API だった。
内部で validatePath を呼ぶように修正。fs IPC 側の validate と二重になるが冪等。
相対パスで throw するテストも追加。

【4. fs.ts の pathExistsAt が ENOENT 以外も握りつぶす (recommend)】

EACCES / EPERM 等でも false を返していたため、rename/delete が「実際は
権限問題なのに Source not found / Not found」と誤分類するバグがあった。
ENOENT のみ false 扱いにし、他は呼び出し側に伝播するよう修正。
fileExistsImpl も同様に修正。

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao
ymnao requested a review from Copilot May 3, 2026 15:40
Copilot started reviewing on behalf of ymnao May 3, 2026 15:40
View session
Copilot AI reviewed May 3, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

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 27 out of 28 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread electron/main/ipc/workspace.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread electron/main/utils/path-guard.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread electron/main/utils/path-guard.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread electron/main/ipc/workspace.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ymnao @claude
fix: workspace:set を承認済み path のみに制限 + Windows 不安定テストを skip
e771bf0
【1. workspace:set IPC が renderer から任意 path を許す権限昇格 (must)】

renderer が侵害された場合、workspaceSet("/") のような任意絶対パスで
allowedRoots を拡張し path-guard を迂回できる経路があった。
ユーザーの OS ネイティブな folder picker を経由しない権限昇格を防ぐ。

- workspace.ts に approvedWorkspacePaths Set + approveWorkspacePath /
  isWorkspacePathApproved を追加。承認は canonical 形で記録する
- workspace:set IPC ハンドラで「approved 集合内 OR null」のみ通し、
  未承認 path は throw(path === null は unregister なので常に許可)
- dialog:open-directory が成功した時点で main 側が approveWorkspacePath を
  呼ぶ。「OS ネイティブ folder picker を通った」事実が承認の根拠
- 起動時に saved workspacePath を approve する approveSavedWorkspaceFromSettings
  を main/index.ts に追加(register はせず approve のみ)
- settings.ts に getWorkspacePathFromSettings を復活(前回削除したが
  この用途で再度必要)
- 内部 API setActiveWorkspaceForWindow は approve チェックを行わない
  (テスト・bootstrap 用、信頼できる呼び出し元限定)

【2. POSIX 固定パス test が Windows で落ちる (recommend)】

validatePath("/tmp/test.md") を expected "/tmp/test.md" で比較する describe を
describe.skipIf(process.platform === "win32") で skip。

【3-4. fs.symlink を使うテストが Windows で EPERM になる (recommend)】

Developer Mode 無効の Windows で symlink が EPERM になり pnpm test が不安定に
なる問題。各 symlink 利用 it を it.skipIf(process.platform === "win32") で skip。
- path-guard.test.ts: 「blocks symlink-based escape from the workspace」
  「blocks symlink-based escape via intermediate directories」
- workspace.test.ts: 「ref-counts via canonical path so symlink-aliased ...」
  + 新規 「treats symlink-aliased paths as the same approval」

approveWorkspacePath / isWorkspacePathApproved の動作を検証する 6 ケースの
テストを workspace.test.ts に追加。

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao
ymnao requested a review from Copilot May 3, 2026 16:38
Copilot started reviewing on behalf of ymnao May 3, 2026 16:39
View session
Copilot AI reviewed May 3, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

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 27 out of 28 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread electron/main/utils/path-guard.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread electron/main/ipc/fs.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread electron/main/ipc/dialog.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ymnao @claude
fix: transient write path を window スコープ + 成功後 consume + write 専用に再設計
1ec7b8e
レビュー指摘 3 件はすべて transient write path 機構の同根の問題だったので
統合的に再設計する。

【1. consume タイミングが早すぎて withRetry でリトライ不能 (must)】

旧設計は assertPathAllowed 内で「チェック時点」に consume していたため、
書き込みが EBUSY/EAGAIN 等で失敗→ renderer 側 withRetry が再試行すると
2 回目以降は Permission denied になり、SaveDialog 経由のエクスポートが
リトライ不能だった。

- assertWritePathAllowed を新設し、check のみで consume しない
- consumeTransientWritePath を別関数として export し、書き込み成功後に
  fs.ts 側で明示的に呼ぶ
- 失敗時は consume されず、withRetry の再試行で同じ transient が使える

【2. transient が write 以外の IPC にも適用されていた (must)】

旧 assertPathAllowed は read/list/rename/delete でも transient を見て
許可してしまっていた。transient は本来「ユーザー意図的な書き込み」用の
capability なので write 系のみで参照すべき。

- assertPathAllowed (read 系用) は transient を見ず allowedRoots のみ判定
- assertWritePathAllowed (write 系用) のみ transient を考慮
- fs.ts: writeFile / writeNewFile のみ assertWritePathAllowed を使い、
  read/list/createFile/createDirectory/rename/delete は assertPathAllowed のまま

【3. 未使用 transient が累積し cleanup されない (must)】

旧設計はプロセス全体の Set に入れていたため、SaveDialog をキャンセル
/中断しただけでも transient が残り、別ウィンドウからも消費可能で、
window close 時の cleanup もなかった。

- transientWritePaths を Map<webContentsId, Set<string>> に変更
- registerTransientWritePath(windowId, path) で window 単位に管理
- dialog:save は event.sender.id を使って ownership を持たせる
- main/index.ts の window.on("closed") で
  clearTransientWritePathsForWindow を呼び、未消費 capability を破棄
- 別ウィンドウの transient は assertWritePathAllowed で reject される
  (cross-window leakage 防止)

fs.ts の writeFile/writeNewFile は senderId を受け取るシグネチャに変更
(IPC ハンドラが event.sender.id を渡す)。

retry-friendly / window 隔離 / read 系で transient 不可視 を検証する
テスト 7 ケースを追加。

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao
ymnao requested a review from Copilot May 3, 2026 16:57
Copilot started reviewing on behalf of ymnao May 3, 2026 16:57
View session
Copilot AI reviewed May 3, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

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 27 out of 28 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/lib/errors.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread electron/main/index.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread electron/main/ipc/dialog.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ymnao @claude
fix: EMFILE 無駄リトライ / settings 経由の approve バイパス / dialog 親ウィンドウのズレを修正
f277955
【1. EMFILE が NON_TRANSIENT に無く無駄リトライ (must)】

src/lib/errors.ts の isTransientError は NON_TRANSIENT に含まれないエラーを
すべて transient 扱いでリトライするが、EMFILE(FD 枯渇)はリトライしても
回復しないことが多く、無駄なリトライが続いていた。

- NON_TRANSIENT に \\bEMFILE\\b と /too many open files/i を追加
- isTransientError("EMFILE: ...") / "Too many open files" が false を返す
  ことを検証するテストを追加

【2. settings 経由の workspacePath 改ざんで承認境界を迂回できる (must)】

bootstrap で settings.json の workspacePath を無条件で approveWorkspacePath
していたため、renderer から settings:set("workspacePath", "/") のように
任意値を書き込めると(あるいは settings.json が改ざんされると)、次回起動で
任意ディレクトリが「承認済み」になる抜け穴があった。

- settings.ts に RESERVED_KEYS = {"workspacePath"} を導入し、settings:set /
  settings:delete ハンドラで該当キーを reject(renderer から書き込み不能化)
- persistWorkspacePath を main 専用 export として追加
- workspace:set ハンドラで approve 通過後に persistWorkspacePath(path) を呼び、
  「承認済み path だけが永続化される」整合性を保つ
- フロント側 saveWorkspacePath を廃止:
  - src/lib/store.ts から export 削除(settings:set("workspacePath", ...) は
    今や reject される)
  - AppLayout.tsx の saveWorkspacePath 呼び出し 2 箇所を削除
  - AppLayout.tsx の userSetWorkspaceRef も用途消失で削除
  - 関連テスト(store.test.ts / AppLayout.test.tsx mock)も更新

【3. SaveDialog の親ウィンドウと sender がズレる (recommend)】

dialog.ts の getParentWindow は focused / first を使っていたため、複数ウィンドウ時に
「event.sender の window」と「dialog の親ウィンドウ」がズレ、SaveDialog の
transient capability 所有者と UI 上の親が食い違う可能性があった。

- BrowserWindow.fromWebContents(event.sender) を最優先する getOwnerWindow に変更
- showOpenDialog / showSaveDialog の signature に event を追加し、
  全ハンドラで sender 由来の window を親に使う

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao
ymnao requested a review from Copilot May 3, 2026 17:10
Copilot started reviewing on behalf of ymnao May 3, 2026 17:10
View session
Copilot AI reviewed May 3, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

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 29 out of 30 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread electron/main/ipc/settings.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread electron/main/ipc/settings.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ymnao @claude
fix: settings の prototype pollution / own-property semantics を修正
fe37898
レビュー指摘 2 件への対応。両方とも settings store の prototype pollution 系。

【1. getValue が `key in data` で Object.prototype 由来も拾う (must)】

`getValue("toString")` のような Object.prototype 由来のキーで true となり、
IPC 経由で関数(structured clone 不可)を返して例外/DoS になる可能性があった。
__proto__ と絡むと prototype pollution の足掛かりにもなる。

- getValue を Object.hasOwn(data, key) ベースに変更(own property のみ)
- store cache を Object.create(null) で null-prototype object として作成
  (`emptyStore()` ヘルパーに集約)
- load() が JSON.parse 結果から「安全なキー」だけを cache に取り込む
  (別バージョン / 手書き改ざんで __proto__ 等が入っていても無視)

【2. settings:set / delete が任意キー名で prototype pollution 可能 (must)】

renderer から __proto__ / constructor / prototype を指定すると main プロセスの
状態を汚染できる経路があった。

- isSafeSettingsKey(key) を導入(識別子相当 ^[A-Za-z_][A-Za-z0-9_]*$ のみ許可、
  かつ FORBIDDEN_SETTINGS_KEYS = {"__proto__","constructor","prototype"} を
  明示的に拒否、非文字列も拒否)
- settings:set / settings:delete ハンドラで isSafeSettingsKey を通らないキーを
  throw(reserved-key の reject の前段に配置)
- settings:get は throw せず null を返す(renderer 側は「未設定」で defaults に
  フォールバックする既存挙動と整合)
- 引数型を `key: unknown` にして type-level でも信用しないことを明示

isSafeSettingsKey / 危険キー拒否 / load() のフィルタ / Object.hasOwn セマンティクス
をそれぞれ検証する 8 ケースのテストを追加。

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao
ymnao requested a review from Copilot May 4, 2026 06:59
@ymnao
ymnao requested a review from Copilot May 4, 2026 10:37
Copilot started reviewing on behalf of ymnao May 4, 2026 10:38
View session
Copilot AI reviewed May 4, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

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 29 out of 30 changed files in this pull request and generated 5 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/components/layout/Sidebar.tsx Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/components/layout/AppLayout.tsx Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread electron/main/utils/path-guard.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread electron/main/ipc/workspace.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread electron/main/utils/path-guard.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ymnao @claude
fix: 過剰ロールバック / unmount 後副作用 / Windows 非互換テストを修正
8356e57
【1. Sidebar の workspaceSet(null) ロールバックが既存 workspace を破壊 (must)】

workspace:set ハンドラは既に atomic(permission 通過 → persistWorkspacePath →
setActiveWorkspaceForWindow)で、失敗時は main 側 state が変化しない。
それなのに Sidebar.handleOpenFolder の catch で workspaceSet(null) を呼ぶと、
別 workspace が開いていた window で「新規切替に失敗しただけなのに、開いて
いた既存 workspace まで un-register + settings から削除」されてしまう。

- catch 内の workspaceSet(null) を撤去。失敗時は既存状態を維持
- toast 通知は維持

【2. AppLayout hydrate の workspaceSet(null) が unmount 後にも実行されうる (recommend)】

cancelled = true(unmount / window close)の状態でも try/catch の catch ブロックは
走るため、ユーザーの保存済み workspacePath を意図せず削除する副作用が起こりうる。

- catch ブロック先頭に `if (cancelled) return;` を追加
- 「このウィンドウがまだ生きている時のみ」main 側 state を巻き戻す形に

【3. path-guard.test.ts:101 の POSIX 固定パスが Windows で落ちる (must)】

`/this/path/does/not/exist` を path.resolve すると Windows では drive 付きの
パスになり、`toEqual([phantom])` が失敗する。

- このケースを `it.skipIf(process.platform === "win32")` で Windows skip
- realpathBestEffort の fall-through 経路自体は OS 非依存。Windows 用テストは
  drive 付き assertion で別途書き起こす必要があるが、必要になった時点で追加

【4-5. test のパス区切り依存(split("/"))を basename() に置換 (recommend)】

`dirB.split("/").slice(-1)[0]` のような split("/") は Windows パス(\)で
意図した basename にならない。

- workspace.test.ts と path-guard.test.ts の split("/") を `node:path` の
  basename() に置換
- import に basename を追加

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao
ymnao requested a review from Copilot May 4, 2026 12:11
Copilot started reviewing on behalf of ymnao May 4, 2026 12:11
View session
Copilot AI reviewed May 4, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

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 29 out of 30 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread electron/main/ipc/fs.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread electron/main/ipc/fs.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ymnao @claude
fix: path-guard が canonical を返し fs IPC は判定 = I/O で同一パスを使う
3b27a95
レビュー指摘 2 件はどちらも fs IPC の path 正規化に関する同根の問題。

【1. TOCTOU: 判定と I/O で違うパスを使っていた (must)】

旧実装は assertPathAllowed / assertWritePathAllowed が「内部で realpath
正規化したパスで判定」する一方、実 I/O は `validatePath` の戻り値(symlink を
含み得るパス)に対して行っていた。チェック後に symlink が差し替えられると、
workspace 外への read/write が成立する余地があった。

【2. 重複正規化: assert 内と impl 内で validatePath/realpath が二重 (recommend)】

writeFileImpl 等の hot path で、validatePath → assertWritePathAllowed の流れで
realpath syscall(cache 経由でも Map look up + LRU 更新)が二重に走っていた。

両者を一括で解消する設計変更:

- assertPathAllowed / assertWritePathAllowed の戻り値を `void` から `string`
  (canonical = validatePath + realpathBestEffort 済みパス)に変更。判定で使った
  実体を呼び出し側に返す
- fs.ts の全 impl は assert 系から canonical を受け取り、実 I/O(fsp.readFile,
  fsp.writeFile, fsp.rename, shell.trashItem 等)にもこの canonical を使う。
  判定と I/O が同一パスになるので TOCTOU で symlink 差し替え攻撃が成立しない
- impl 内の `validatePath(path)` 呼び出しを撤去し、二重正規化を解消
- listDirectoryImpl の entry.path も canonical 基準で組み立てる
  (fs.test.ts の期待値も canonicalize した workspaceDir で計算)
- deleteEntryImpl が shell.trashItem に canonical を渡すことで、symlink 差し替え
  攻撃で workspace 外のファイルを誤削除しないことを test で担保

isPathAllowed(boolean 副作用なし版)は引き続き try/catch で false に寄せる契約。

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao
ymnao requested a review from Copilot May 4, 2026 13:02
Copilot started reviewing on behalf of ymnao May 4, 2026 13:03
View session
Copilot AI reviewed May 4, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

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 29 out of 30 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread electron/main/ipc/fs.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread electron/main/utils/path-guard.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ymnao @claude
fix: listDirectory の戻り値表記を input ベースに揃えて FileTree との整合を回復
0350612
【1. listDirectoryImpl の path 表記が renderer の workspacePath とズレる (must)】

前 commit で listDirectoryImpl が assertPathAllowed から canonical を受け取り
I/O 安全性は得たが、戻り値の FileEntry.path も `join(canonical, entry.name)` に
してしまったため、renderer 側 workspacePath(raw 入力)との表記がズレ、
macOS の /var → /private/var や symlink workspace で FileTree の
`replacePrefix(workspacePath, ...)` / `startsWith(workspacePath)` 等が崩れる
(絶対パス扱いされる)回帰があった。

- I/O は引き続き canonical で行う(TOCTOU 防止は維持)
- 戻り値の path は `resolve(path)` した入力表記を base に組み立てる
  (symlink 解決はせず、renderer が保持している workspacePath と整合させる)
- fs.test.ts の listDirectoryImpl 期待値も入力 (workspaceDir) base に戻す

【2. cachedRealpathSync の同期 I/O によるブロッキング (recommend)】

Stage 1 のスコープ内では現状の sync + LRU で実用上問題ないと判断(cache hit 率
が高い、Stage 1 完了判定の機能パリティに直接影響しない)。将来課題として
コメントに明記:

- 深いパス階層 / network FS / 大量ファイルアクセス時のブロックは認識
- `fs.promises.realpath` への async 化は assertPathAllowed / canonicalize /
  全 fs IPC ハンドラまで波及する API 変更を伴うため Stage 2 以降で検討
- 現状は LRU 256 entries + 通常運用での hit 率の高さで実用上の問題を回避

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao
ymnao requested a review from Copilot May 4, 2026 13:51
Copilot started reviewing on behalf of ymnao May 4, 2026 13:52
View session
Copilot AI reviewed May 4, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

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 29 out of 30 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/components/layout/AppLayout.tsx Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread electron/main/utils/path-guard.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ymnao
ymnao requested review from Copilot and removed request for Copilot May 4, 2026 14:05
Copilot started reviewing on behalf of ymnao May 4, 2026 14:05
View session
@ymnao @claude
fix: AppLayout のロールバックを段階別に + consumeTransientWritePath を canonical 前提化
a0ab437
【1. AppLayout 初期復元の catch が workspaceSet 失敗時にも保存値を削除 (must)】

旧実装は catch 内で常に workspaceSet(null) を呼んでいたため、最初の
workspaceSet(settings.workspacePath) 自体が失敗(settings 永続化失敗・
未承認扱い等)したケースでも、保存済み workspacePath を消してしまっていた。
workspace:set ハンドラが atomic(permission OK → persist → register)に
なっているので、初期段階の失敗時は main 側 state が変わっておらず、
ロールバックは不要かつ有害。

- registeredOnMain フラグで「workspaceSet が成功して main 側 state が
  更新されたか」を追跡
- catch 内では `if (registeredOnMain)` の場合のみ workspaceSet(null) で巻き戻す
  - workspaceSet 失敗 → 何もしない(既存設定を維持)
  - listDirectory 失敗 → main 側 state を巻き戻し、fail-closed の整合性を保つ
- cancelled チェックは引き続き先頭で行い、unmount 後の副作用を防ぐ

【2. consumeTransientWritePath が canonical 受け取り時にも再正規化 (recommend)】

呼び出し側(fs.ts の write 系 impl)は assertWritePathAllowed の戻り値
(既に canonical)を渡しているのに、関数内部で再度 canonicalize(realpath
sync)を呼んでいた。fs:write 成功は hot path なので無駄。

- consumeTransientWritePath を「canonical 前提」API に変更:内部の
  canonicalize 呼び出しを撤去し、引数名も canonicalPath に
- ドキュメントコメントで「assertWritePathAllowed の戻り値や canonicalize() の
  結果を渡すこと、raw は silently false を返す」と明示
- fs.ts の呼び出し側は既に canonical を渡しているので変更不要
- path-guard.test.ts の consume テストを `canonicalize(target)` を渡す形に更新

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao
ymnao requested a review from Copilot May 4, 2026 14:17
Copilot started reviewing on behalf of ymnao May 4, 2026 14:18
View session
Copilot AI reviewed May 4, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

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 29 out of 30 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ymnao
ymnao merged commit bbad33d into main May 4, 2026
8 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@ymnao
ymnao deleted the feature/stage-1-fs branch May 4, 2026 14:25
@ymnao ymnao mentioned this pull request May 26, 2026
chore: 依存関係まとめ更新 + brace-expansion DoS 対応 (Dependabot 8 PR + alert #6) #75
Merged
5 of 7 tasks
ymnao added a commit that referenced this pull request May 26, 2026
@ymnao @claude
chore: 依存関係まとめ更新 + brace-expansion DoS 対応 (Dependabot 8 PR + alert #6) (
2666f9d
#75)

* chore: 依存関係をまとめて更新 + brace-expansion DoS 対応 (Dependabot)

Dependabot 8 PR と Dependabot alert #6 を統合:

- @codemirror/view: ^6.42.1 → ^6.43.0 (#69)
- @uiw/react-codemirror: ^4.25.9 → ^4.25.10 (#69)
- dompurify: ^3.4.2 → ^3.4.5 (#71)
- lucide-react: ^1.8.0 → ^1.16.0 (#65)
- zustand: ^5.0.12 → ^5.0.13 (#67)
- @types/node: ^25.7.0 → ^25.9.1 (#72)
- @types/react: ^19.2.7 → ^19.2.15 (#68)
- @vitejs/plugin-react: ^6.0.1 → ^6.0.2 (#64)
- vite: ^8.0.12 → ^8.0.13 (#64)
- vitest: ^4.1.6 → ^4.1.7 (#70)

加えて pnpm overrides に brace-expansion: ^5.0.6 を追加し
GHSA-jxxr-4gwj-5jf2 (DoS, >=5.0.0 <5.0.6) に対応。transitive dep
として minimatch 等から間接的に入るため override で強制する。

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix: @codemirror/view を self-ref override で transitive 強制統一

CI typecheck で 6.42.1 と 6.43.0 が共存し EditorView の private property
declaration (dispatchTransactions) が衝突していた。@codemirror/autocomplete /
commands / lang-html 等の transitive 依存が古い 6.42.1 を pin していたため、
state と同じ self-ref パターン (`$@codemirror/view`) で direct dep 6.43.0
へ強制統一する。

lockfile で @codemirror/[email protected] が 0 件 (6.43.0 のみ 6 箇所) になることを確認。

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix: brace-expansion override の selector を v5 系に scope (Copilot 指摘)

PR #75 Copilot レビュー対応 (must):

`brace-expansion: ^5.0.6` の package-name-only override は、advisory 対象
(GHSA-jxxr-4gwj-5jf2, >=5.0.0 <5.0.6) 範囲外の v1/v2 系を要求する transitive
dep も強制的に v5.0.6 にマージしてしまい、semver 互換性が破壊されていた
(実際 override 前は v1.1.14 / v2.1.1 が transitive で要求されていた)。

selector を `brace-expansion@^5.0.0` に絞り、v5 系のみ 5.0.6 へ固定する形に
変更。lockfile では v1.1.14 / v2.1.1 / v5.0.6 が共存し、advisory 対象範囲
だけが scope 外の 5.0.6 に強制される正しい状態に戻る。

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
ymnao added a commit that referenced this pull request May 31, 2026
@ymnao @claude
chore: PR #103 code-review 7 件反映 (CI ガード設計欠陥修正)
9a1ff5e
/code-review で検出した 7 件全てに対応。最重要は self-counting 解消
(scripts/check-tauri-residue.sh → scripts/check-legacy-residue.sh)。

Fix #1: self-counting で Phase 5 green 化が原理的に不可能だった問題:
- scripts/check-tauri-residue.sh → check-legacy-residue.sh にリネーム
- ci.yml job tauri-residue → legacy-residue にリネーム
- package.json check:tauri-residue → check:legacy-residue にリネーム
- ci.yml コメントから "Tauri" / "WKWebView" verbatim を排除
- 結果: 88 行 (うち 4 行 self-reference) → 84 行 baseline と一致

Fix #2: pnpm verify が CI と divergence していた問題:
- verify chain に typecheck:e2e + build を追加
- check:legacy-residue は意図 fail のため verify には含めない (CLAUDE.md
  で「補助」として別行案内)

Fix #3: PATHS の coverage gap:
- pnpm-workspace.yaml (CLAUDE.md 上 canonical config) 追加
- vite.config.e2e.ts 追加
- tsconfig.json (root) 追加
- docs/tauri-purge-inventory.md §2.1 にも追従

Fix #4: WebKit 扱いの inventory との非整合:
- script ヘッダで WebKit 除外の意図を明記 (-webkit- prefix FP 回避)
- inventory §2.1 / §2.5 / §2.6 で CI ガードとの差分を明記
  (ime.ts:4 等 WebKit 系コメントは CI 非対象 → Phase 3 で手動チェック)

Fix #5: git grep exit ≥2 (pathspec error / 非 git repo 等) を silently
success として扱っていた問題:
- if RESULT=$(...) を捨て、明示的に EXIT=$? を捕捉
- case 0 / 1 / *) で 3 分岐 (match / no-match / error)
- error 時は stderr 出力 + exit 2

Fix #6: continue-on-error は workflow 成否にのみ作用し job の check-run
は failure のまま残るため、branch protection の required status checks
に追加すると merge blocking される:
- workflow コメントに caveat を追記
- 「Phase 5 完了まで required 化しない」運用を明示

Fix #7: :(exclude)scripts/check-tauri-residue.sh の dead code 化:
- 新ファイル名 :(exclude)scripts/check-legacy-residue.sh に更新
- 「PATHS に scripts/ を含めないため現状 no-op、defensive 配置」コメント
  追記

検証:
- bash scripts/check-legacy-residue.sh → 84 行検出 (PR 直前と一致)
- pnpm verify (format / lint / typecheck / typecheck:e2e / test /
  test:e2e / build) 全 pass

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ymnao added a commit that referenced this pull request May 31, 2026
@ymnao @claude
chore: Tauri 残骸検出 CI ガードを追加 (#82 Phase 1 PR-2) (#103)
d0f3a7b
* chore: Tauri 残骸検出 CI ガードを追加 (#82 Phase 1 PR-2)

Issue #82 サブタスク D。Phase 2-5 の削除・置換進捗を質的に追跡する
CI ガードを設置する。

変更:
- scripts/check-tauri-residue.sh: 13 種の FORBIDDEN keyword
  (tauri / wkwebview / __TAURI / webviewWindow / @tauri-apps /
  src-tauri / tauri:// / tauri-plugin / data-tauri- /
  convertFileSrc / WebviewWindow / appWindow / tauri.conf) を
  git grep で検出。1 hit でも exit 1。対象スコープは
  docs/tauri-purge-inventory.md §2.1 と同期。-webkit- prefix CSS
  の false positive は keyword に WebKit を含めないことで除外
- package.json: check:tauri-residue script + verify script を追加
  (verify = format && lint && typecheck && test && test:e2e の
  chain を codify。check:tauri-residue は Phase 5 完了時に verify
  へ合流予定)
- .github/workflows/ci.yml: tauri-residue job を追加。Phase 1 時点
  では既存残骸 84 行が検出され意図 fail するため continue-on-error:
  true で merge を blocking しない運用。Phase 5 完了 PR で除去
- CLAUDE.md: 「コミット前の検証」を pnpm verify に集約

ローカル実行: 84 行検出で exit 1 (期待動作)。inventory §2.2 の
集計 (B 14 行 + 残り A/C/D) と整合。

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* chore: PR #103 code-review 7 件反映 (CI ガード設計欠陥修正)

/code-review で検出した 7 件全てに対応。最重要は self-counting 解消
(scripts/check-tauri-residue.sh → scripts/check-legacy-residue.sh)。

Fix #1: self-counting で Phase 5 green 化が原理的に不可能だった問題:
- scripts/check-tauri-residue.sh → check-legacy-residue.sh にリネーム
- ci.yml job tauri-residue → legacy-residue にリネーム
- package.json check:tauri-residue → check:legacy-residue にリネーム
- ci.yml コメントから "Tauri" / "WKWebView" verbatim を排除
- 結果: 88 行 (うち 4 行 self-reference) → 84 行 baseline と一致

Fix #2: pnpm verify が CI と divergence していた問題:
- verify chain に typecheck:e2e + build を追加
- check:legacy-residue は意図 fail のため verify には含めない (CLAUDE.md
  で「補助」として別行案内)

Fix #3: PATHS の coverage gap:
- pnpm-workspace.yaml (CLAUDE.md 上 canonical config) 追加
- vite.config.e2e.ts 追加
- tsconfig.json (root) 追加
- docs/tauri-purge-inventory.md §2.1 にも追従

Fix #4: WebKit 扱いの inventory との非整合:
- script ヘッダで WebKit 除外の意図を明記 (-webkit- prefix FP 回避)
- inventory §2.1 / §2.5 / §2.6 で CI ガードとの差分を明記
  (ime.ts:4 等 WebKit 系コメントは CI 非対象 → Phase 3 で手動チェック)

Fix #5: git grep exit ≥2 (pathspec error / 非 git repo 等) を silently
success として扱っていた問題:
- if RESULT=$(...) を捨て、明示的に EXIT=$? を捕捉
- case 0 / 1 / *) で 3 分岐 (match / no-match / error)
- error 時は stderr 出力 + exit 2

Fix #6: continue-on-error は workflow 成否にのみ作用し job の check-run
は failure のまま残るため、branch protection の required status checks
に追加すると merge blocking される:
- workflow コメントに caveat を追記
- 「Phase 5 完了まで required 化しない」運用を明示

Fix #7: :(exclude)scripts/check-tauri-residue.sh の dead code 化:
- 新ファイル名 :(exclude)scripts/check-legacy-residue.sh に更新
- 「PATHS に scripts/ を含めないため現状 no-op、defensive 配置」コメント
  追記

検証:
- bash scripts/check-legacy-residue.sh → 84 行検出 (PR 直前と一致)
- pnpm verify (format / lint / typecheck / typecheck:e2e / test /
  test:e2e / build) 全 pass

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@ymnao ymnao mentioned this pull request Jul 22, 2026
検索/スキャン系 IPC のキャッシュ化 + 段階的転置インデックス化 (Phase A-D) #394
Closed
24 tasks
@ymnao ymnao mentioned this pull request Oct 6, 2026
fix: 折りたたみ中に外部変更を取りこぼしたフォルダを再展開時に取り直す #610
Merged
3 of 10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@ymnao
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.