From e6decfa9bd660f706d714eb6dbd8947d37422e95 Mon Sep 17 00:00:00 2001 From: owa <20108042+owayo@users.noreply.github.com> Date: Mon, 19 Oct 2026 09:14:48 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20pnpm=20=E3=81=AE=E6=9C=AA=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E3=83=AC=E3=82=B8=E3=82=B9=E3=83=88=E3=83=AA=E3=81=AE?= =?UTF-8?q?=E7=A9=BA=E5=87=BA=E5=8A=9B=E3=82=92=E5=8F=97=E3=81=91=E5=85=A5?= =?UTF-8?q?=E3=82=8C=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pnpm 11 が未設定のスコープに返す空出力を JSON として読み、age 監査が失敗していた。 成功かつ標準エラーが空のときだけ、空出力を未設定として既定レジストリへ戻す。 既定レジストリの未確認時は公開 npm へ照会しない。 --- docs/usage.ja.md | 2 ++ docs/usage.md | 2 ++ src/node_lock.rs | 4 ++++ src/node_lock/tests.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+) diff --git a/docs/usage.ja.md b/docs/usage.ja.md index b9278d3..e93d0ca 100644 --- a/docs/usage.ja.md +++ b/docs/usage.ja.md @@ -429,6 +429,8 @@ age が有効な `--install` では、直接依存・推移依存・開発依存 取得元が公開 npm レジストリだと確認できるパッケージだけを照会します。pnpm が生成した依存グラフの URL だけを根拠にせず、実際に有効なレジストリ設定も確認します。alias は実パッケージ名を使います。ローカル・workspace・Git 依存は公開日の監査対象外です。private や取得元が不明のレジストリ依存は、その名前を公開 npm へ送らず未確認として報告します。公開日不明、読み込み・照会の失敗、監査中の lock の変更、180 秒の時間切れも終了コード 2 になります。公開日は更新候補のフィルターと別に検証するため、deprecated や latest 以外のロックされた版も確認できます。 +pnpm のレジストリ確認では、`pnpm config get --json` が成功し、標準エラーが空で、標準出力が空または空白だけなら、JSON の `null` と同じ未設定として扱います。スコープのレジストリが未設定なら、確認済みの既定レジストリを使います。既定レジストリも未設定なら未確認のままとし、そのパッケージ名を公開 npm へ送りません。 + Node の監査では lock を書き換えません。違反は実際のロック版・公開日・基準日時を、未確認の依存は理由を常に表示します。PM 自身の age フィルターで新規の解決を制限できる場合も、最後の検証を省略しません。 age が有効な `--install` では、更新を書き込む前にも既存の `pnpm-lock.yaml` を監査します。install・最終監査と同じ workspace の共有設定を使い、更新のないメンバーの厳しい設定も含めます。Node 自身に更新がなくても、つながる Node/Cargo install のどちらかに実更新があれば確認します。違反・未確認・lock の読み込みや依存グラフの取得失敗・age 設定の読み込みや解釈失敗があれば、その scope のマニフェストと install を止めます。予定した更新は失敗として数え、終了コード 2 で通知します。独立した scope は処理を続けます。Tauri は共有 Node/Cargo workspace でつながるプロジェクトもまとめて止め、同期した片側だけの書き込みを防ぎます。Cargo の所属判定が失敗した manifest は、成功した Cargo の実行環境から読み取り専用の `locate-project` で再確認します。成功した回答が同じ root を示せば所属を確定し、回答が食い違う場合や成功がない場合は未確認のまま扱います。独立と確認できない Rust と対応する Node を止め、判定エラーの理由を表示します。別の root と確認できた scope は、同じ Node install を共有していなければ続行します。通常の Rust helper の所属が不明なだけでは、確認済みの別 root 同士をつなぎません。停止した Node/Cargo scope は install 後の監査と Cargo lock の差し戻しから除外します。残る独立した Rust install は、確認済みの root で full cargo update を実行します。root の判定が失敗した場合は、停止した Tauri ディレクトリを選ばずエラーを表示します。確認を通った scope と、更新のない独立した既存 lock の最終監査は維持します。dry-run と `--install` を付けない実行では、この事前監査を行いません。 diff --git a/docs/usage.md b/docs/usage.md index d211680..5377e10 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -426,6 +426,8 @@ With an active age policy, `--install` checks the actual resolved versions of di Only packages whose registry source can be confirmed as public npm are queried. For pnpm, generated graph URLs alone are not source evidence; the effective registry configuration is checked too. Aliases use the real package name. Local, workspace, and Git dependencies are outside this release-date audit. Private or unknown registry sources are reported as unverified without querying public npm for their names. Missing publication dates, read or lookup failures, changed lock contents during the audit, and the 180-second time limit also produce exit code 2. Publication dates are checked independently of the update-candidate filters, so deprecated or non-latest locked versions can be verified. +For pnpm registry checks, a successful `pnpm config get --json` with no stderr and empty or whitespace-only stdout is treated as unset, just like JSON `null`. An unset scoped registry falls back to the verified default registry. An unset default registry remains unverified; depup does not query public npm for those package names. + Node auditing does not rewrite the lockfile. Violations always show the actual locked version, publication date, and cutoff; unverified entries always show their reason. Native age filtering helps prevent new resolutions, but does not replace this final verification. Before writing updates for `--install`, depup also audits an existing `pnpm-lock.yaml` when age is active. It uses the same shared workspace policy as install and the final audit, including stricter settings in members without updates. An update on either side of a connected Node/Cargo install can trigger this check, even if the Node project has no update of its own. A violation, unverified entry, lock read or graph error, or unreadable/invalid age setting stops that scope: its manifests remain unchanged, its install is skipped, and its planned updates are counted as failed (exit code 2). Independent scopes continue. Tauri projects connected through the same Node or Cargo workspace are stopped together so synchronization cannot be applied to just one side. When a Cargo lookup fails, depup rechecks the manifest from successful Cargo execution contexts using read-only `locate-project`. Consistent successful answers confirm its root; conflicting answers or no successful answer leave it unverified. Rust and associated Node scopes whose independence remains unverified are stopped with the lookup reasons. Confirmed separate roots continue unless a shared Node install connects them; an unresolved Rust helper alone does not connect confirmed roots. Stopped Node and Cargo scopes are excluded from post-install auditing and Cargo lock rollback. Remaining independent Rust installs run a full cargo update at their confirmed roots; a failed root lookup is reported instead of selecting a stopped Tauri directory. Clean scopes and unchanged independent locks retain their final audits. Dry runs and runs without `--install` do not perform this preflight. diff --git a/src/node_lock.rs b/src/node_lock.rs index ff39902..072849b 100644 --- a/src/node_lock.rs +++ b/src/node_lock.rs @@ -278,6 +278,10 @@ async fn read_pnpm_registry( if !output.status.success() || !output.stderr.is_empty() { return Err("effective registry configuration could not be verified".into()); } + // pnpm 11 emits no JSON for unset keys; newer versions emit null. + if output.stdout.trim_ascii().is_empty() { + return Ok(None); + } match serde_json::from_slice::(&output.stdout) .map_err(|_| "effective registry configuration was not valid JSON".to_string())? { diff --git a/src/node_lock/tests.rs b/src/node_lock/tests.rs index 363e7e7..34edd96 100644 --- a/src/node_lock/tests.rs +++ b/src/node_lock/tests.rs @@ -629,12 +629,52 @@ async fn pnpm_scoped_registry_overrides_default_and_private_tarballs_remain_unve assert!(!requests.iter().any(|name| name.contains("private"))); } +#[cfg(unix)] +#[tokio::test] +async fn pnpm_unset_scoped_registry_falls_back_to_verified_default() { + let directory = tempfile::tempdir().unwrap(); + for unset in ["", " \t\r\n", "null"] { + let program = fake_pnpm( + directory.path(), + &format!( + "case \"$3\" in registry) printf '\"https://registry.npmjs.org/\"';; *) printf '%s' '{unset}';; esac" + ), + ); + let mut snapshot = parse_pnpm_snapshot(&json!([{"dependencies":{ + "@example/public":package("@example/public","1.0.0") + }}])) + .unwrap(); + verify_pnpm_registry_sources( + directory.path(), + &program, + &mut snapshot, + Instant::now() + Duration::from_secs(2), + ) + .await + .unwrap(); + let provider = FakeDates { + dates: HashMap::from([( + "@example/public".into(), + dates(&[("1.0.0", "2026-09-01T00:00:00Z")]), + )]), + ..Default::default() + }; + let result = check(snapshot, &provider).await; + assert!(!result.has_failures(), "{unset:?}: {result:?}"); + assert_eq!(result.checked, 1); + assert_eq!(*provider.requests.lock().unwrap(), vec!["@example/public"]); + } +} + #[cfg(unix)] #[tokio::test] async fn pnpm_unreadable_registry_config_never_sends_names_to_public_npm() { let directory = tempfile::tempdir().unwrap(); for script in [ "exit 7", + "exit 0", + "printf ' \t\r\n'", + "printf warning >&2", "printf 'not JSON'", "printf null", "printf '\"https://registry.npmjs.org/\"'; printf warning >&2",