[Duplicate Code] assertGithubCapabilityLifetime duplicated across host-enclave modules
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
Research direction
Read src/cloud-hypervisor/host-enclave-executor-policy.ts and src/cloud-hypervisor/host-enclave-workload-profile.ts, then inspect the existing tests for assertGithubCapabilityLifetime. Consolidate the duplicated validation into one implementation while preserving any needed exports; run the relevant tests. Done when both modules use the shared check and the existing lifetime tests pass.
Written by the indexing model from the issue text.
Description
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-86src/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-86src/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
- Dominant language
- TypeScript
- Stars
- 165
- Forks
- 84
- Avg merge
- 5h 57m
- Merged PRs (30d)
- 390
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from github/gh-aw-firewall
-
awf-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
github/gh-aw-firewall#11612 ·
Maintainers usually reply within 1 day
-
agentic-workflows automated dependencies
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
github/gh-aw-firewall#3837 ·
Maintainers usually reply within 1 day
-
agentic-workflows
Difficulty 3/5 1-2 days Newbie friendliness 48/100
github/gh-aw-firewall#11802 ·
Maintainers usually reply within 1 day
-
automation otel smoke-test tracing
Difficulty 1/5 Under an hour Newbie friendliness 1/100
github/gh-aw-firewall#11801 ·
Maintainers usually reply within 1 day
-
automation otel smoke-test tracing
Difficulty 3/5 1-2 days Newbie friendliness 68/100
github/gh-aw-firewall#11800 ·
Maintainers usually reply within 1 day
All issues in github/gh-aw-firewall
Similar issues
-
bug documentation
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Potential Bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Comfy-Org/ComfyUI_frontend#23773 ·
Maintainers usually reply within 1 day
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 85/100
lingdojo/kana-dojo#34301 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
code-yeongyu/senpi#7007 ·
Maintainers usually reply within 1 day
-
area/renderer bug plugin/echarts priority/P3
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day