[Duplicate Code] Cloud Hypervisor development-artifact bypass gate duplicated in runtime-validation and preflight-artifact-trust
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 76/100
- issue の種類
- リファクタリング
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- typescript
- 領域
- security
調査の方向性
既存のチェックをsrc/cloud-hypervisor/runtime-validation.tsとsrc/cloud-hypervisor/preflight-artifact-trust.tsで確認し、次にsrc/cloud-hypervisor/artifact-trust.tsをヘルパーの配置候補として調べてください。各呼び出し元のガード条件を維持し、環境変数のチェックとエラーメッセージを集約してください。両方の経路が共有ヘルパーを使い、引き続き変数が'1'と等しいことを要求すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Duplicate Code Opportunity
Summary
- Pattern: The
AWF_CLOUD_HYPERVISOR_DEVELOPMENT_ALLOW_UNATTESTED_ARTIFACTS=1opt-in check and its identical error message are repeated in two artifact-trust validation paths. - Locations:
src/cloud-hypervisor/runtime-validation.tsandsrc/cloud-hypervisor/preflight-artifact-trust.ts - Impact: About 8 duplicated lines per copy. This is a security control (the gate that permits unattested artifacts). If the variable name, the required value, or the message changes in one copy but not the other, the two validation paths can disagree about whether the bypass is permitted.
Evidence
src/cloud-hypervisor/runtime-validation.ts: lines 110-117
if (
process.env.AWF_CLOUD_HYPERVISOR_DEVELOPMENT_ALLOW_UNATTESTED_ARTIFACTS !== '1'
) {
throw new Error(
'Cloud Hypervisor development artifact bypass requires ' +
'AWF_CLOUD_HYPERVISOR_DEVELOPMENT_ALLOW_UNATTESTED_ARTIFACTS=1',
);
}
src/cloud-hypervisor/preflight-artifact-trust.ts: lines 73-81
if (
developmentBypass &&
process.env.AWF_CLOUD_HYPERVISOR_DEVELOPMENT_ALLOW_UNATTESTED_ARTIFACTS !== '1'
) {
throw new Error(
'Cloud Hypervisor development artifact bypass requires ' +
'AWF_CLOUD_HYPERVISOR_DEVELOPMENT_ALLOW_UNATTESTED_ARTIFACTS=1',
);
}
Both copies have the same env check, the same error text, and the same thrown error. Only the guarding condition differs (developmentAllowUnattestedArtifacts versus developmentBypass).
Suggested Refactoring
- Add
assertDevelopmentArtifactBypassAllowed(env = process.env)tosrc/cloud-hypervisor/artifact-trust.ts, which already reads env for artifact trust decisions. It should throw the canonical message when the variable is not'1'. - Replace both inline checks with a call to this helper, keeping each caller's own guarding condition unchanged.
- Optionally add a unit test in
artifact-trustcovering the message and the'1'requirement, so both call sites are covered by one test.
Affected Files
src/cloud-hypervisor/runtime-validation.ts— lines 110-117src/cloud-hypervisor/preflight-artifact-trust.ts— lines 73-81src/cloud-hypervisor/artifact-trust.ts— target for the shared helper
Effort Estimate
Low
Detected by Duplicate Code Detector workflow. Run date: 2026-11-30
Generated by Duplicate Code Detector · copilot · routed: haiku55 xhigh · ~2 AIC · ⊞ 18.3K · history
- expires on Dec 30, 2026, 9:54 PM UTC
- 主要言語
- TypeScript
- スター
- 169
- フォーク
- 89
- 平均マージ
- 5時間 18分
- マージ済み PR(30日)
- 450
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
github/gh-aw-firewall のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
github/gh-aw-firewall#12415 ·
メンテナーはふだん 1 日以内に返信
-
code-quality refactoring
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
github/gh-aw-firewall#12345 ·
メンテナーはふだん 1 日以内に返信
-
[Duplicate Code] Repeated lstat identity-swap stub and fixture setup in src/nvx/live-mount-policy.test.ts対応中かも @lpcox が 1 日前に担当しました。 オープンcode-quality refactoring
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
github/gh-aw-firewall#12023 · リアクション 1 件 · 担当者 2 名 ·
メンテナーはふだん 1 日以内に返信
-
awf-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
github/gh-aw-firewall#11612 ·
メンテナーはふだん 1 日以内に返信
-
agentic-workflows automated dependencies
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
github/gh-aw-firewall#3837 ·
メンテナーはふだん 1 日以内に返信
github/gh-aw-firewall の issue をすべて見る
似ている issue
-
area: documentation status: in progress type: documentation
難易度 1/5 1時間未満 初心者へのやさしさ 76/100
Oddmash/oddmash-ui#222 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
appium/appium-wincore-driver#169 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
india-ultimate/hub#715 ·
メンテナーはふだん 1 日以内に返信
-
documentation Entwickler
難易度 1/5 1時間未満 初心者へのやさしさ 89/100
メンテナーはふだん 1 日以内に返信