[Duplicate Code] assertGithubCapabilityLifetime duplicated across host-enclave modules

オープン 初心者向け
#11,797 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
75/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
backend, security

調査の方向性

src/cloud-hypervisor/host-enclave-executor-policy.ts と src/cloud-hypervisor/host-enclave-workload-profile.ts を読み、その後 assertGithubCapabilityLifetime の既存テストを確認してください。重複した検証を単一の実装にまとめ、必要なエクスポートは維持してください。関連するテストを実行してください。両方のモジュールが共通のチェックを使い、既存の有効期間テストが成功すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

code-quality refactoring

Duplicate Code Opportunity

Summary
  • Pattern: assertGithubCapabilityLifetime(policy, timeoutMs) (GitHub credential/capability lifetime validation for host enclave executors) is defined in two files with identical signature and leading logic (if (!policy) return; const hasCredentials = policy.githubAgentId !== undefined || policy.githubBearer !== undefined;).
  • Locations: see below. jscpd reports a 58-line clone.
  • Impact: ~58 duplicated lines removed. This is a security-critical credential-lifetime check, so the two copies can drift. One copy could then enforce a weaker bound than the other.
Evidence
  • src/cloud-hypervisor/host-enclave-executor-policy.ts: lines 29-86
  • src/cloud-hypervisor/host-enclave-workload-profile.ts: lines 20-77

Both contain:

export function assertGithubCapabilityLifetime(
  policy: HostExecutorAgentPolicy | undefined,
  timeoutMs: number,
): void {
  if (!policy) return;
  const hasCredentials = policy.githubAgentId !== undefined || policy.githubBearer !== undefined;
  ...
Suggested Refactoring

Keep a single exported assertGithubCapabilityLifetime in host-enclave-executor-policy.ts, or in a small shared module such as host-enclave-github-lifetime.ts. Have host-enclave-workload-profile.ts import it, and re-export it if needed to preserve the public API. Keep the existing tests pointed at the single implementation.

Affected Files
  • src/cloud-hypervisor/host-enclave-executor-policy.ts — lines 29-86
  • src/cloud-hypervisor/host-enclave-workload-profile.ts — lines 20-77
Effort Estimate

Low


Detected by Duplicate Code Detector workflow.

Generated by Duplicate Code Detector · copilot · auto (Claude Sonnet 5.5) · ~20 AIC · ⊞ 23.6K · ◷

  • expires on Dec 18, 2026, 9:50 PM UTC
主要言語
TypeScript
スター
165
フォーク
84
平均マージ
5時間 57分
マージ済み PR(30日)
390

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

github/gh-aw-firewall のほかの issue

github/gh-aw-firewall の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。