Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Duplicate Code] Extract repeated trusted enclave storage invocation plan fixture

Open Beginner friendly
#10,362 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
testing

Research direction

Read src/cloud-hypervisor/trusted-enclave-storage.test.ts around lines 341-357 and 430-446 to compare the repeated plan and storage-root setup. Extract a shared test helper while preserving any scenario-specific values. Done when both tests use the shared setup and the existing trusted enclave storage tests pass.

Written by the indexing model from the issue text.

Description

code-quality refactoring

Duplicate Code Opportunity

Summary
  • Pattern: Trusted enclave storage tests duplicate construction of the same HostExecutorInvocationPlan and derivation of its storage root.
  • Locations: src/cloud-hypervisor/trusted-enclave-storage.test.ts lines 341-357 and 430-446.
  • Impact: The repeated security-sensitive identity and invocation-path fixture can drift between mount-propagation and privatization tests; a shared builder would reduce maintenance and preserve consistent path assumptions.
Evidence

Both tests create the same plan fields and storage root:

Location A

  • src/cloud-hypervisor/trusted-enclave-storage.test.ts: lines 341-357
const plan = {
  runId: 'a'.repeat(32), entryId: 'script', invocationId: 'b'.repeat(32), executorKind: 'script',
  invocationHostDir: '/private/SECRET/invocations/script/invocation',
} as HostExecutorInvocationPlan;
const root = hostExecutorStorageDirectory(hostExecutorVmRunId(plan));

Location B

  • src/cloud-hypervisor/trusted-enclave-storage.test.ts: lines 430-446
const plan = {
  runId: 'a'.repeat(32), entryId: 'script', invocationId: 'b'.repeat(32), executorKind: 'script',
  invocationHostDir: '/private/SECRET/invocations/script/invocation',
} as HostExecutorInvocationPlan;
const root = hostExecutorStorageDirectory(hostExecutorVmRunId(plan));
Suggested Refactoring

Extract a createInvocationPlan(overrides = {}) test helper that returns the canonical HostExecutorInvocationPlan, and a small invocationStorageRoot(plan) helper or fixture wrapper for the derived root. Allow tests to override only the identity/path fields needed by a specific scenario.

Affected Files
  • src/cloud-hypervisor/trusted-enclave-storage.test.ts — lines 341-357
  • src/cloud-hypervisor/trusted-enclave-storage.test.ts — lines 430-446
Effort Estimate

Low


Detected by Duplicate Code Detector workflow. Run date: 2026-10-20

Generated by Duplicate Code Detector · copilot · gpt54mini · 1.03 AIC · ⊞ 30.1K · ◷

  • expires on Nov 19, 2026, 9:52 PM UTC
Dominant language
TypeScript
Stars
149
Forks
77
Avg merge
4h 19m
Merged PRs (30d)
445

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from github/gh-aw-firewall

All issues in github/gh-aw-firewall

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.