[Duplicate Code] Cloud Hypervisor development-artifact bypass gate duplicated in runtime-validation and preflight-artifact-trust
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- security
Research direction
Read the existing checks in src/cloud-hypervisor/runtime-validation.ts and src/cloud-hypervisor/preflight-artifact-trust.ts, then inspect src/cloud-hypervisor/artifact-trust.ts as the proposed helper location. Keep each caller's guarding condition and consolidate the environment check and error message; done when both paths use the shared helper and still require the variable to equal '1'.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- TypeScript
- Stars
- 169
- Forks
- 89
- Avg merge
- 5h 18m
- Merged PRs (30d)
- 450
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
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
github/gh-aw-firewall#12415 ·
Maintainers usually reply within 1 day
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
github/gh-aw-firewall#12345 ·
Maintainers usually reply within 1 day
-
[Duplicate Code] Repeated lstat identity-swap stub and fixture setup in src/nvx/live-mount-policy.test.tsPossibly taken @lpcox claimed this 1 day ago. Opencode-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
github/gh-aw-firewall#12023 · 1 reaction · 2 assignees ·
Maintainers usually reply within 1 day
-
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
All issues in github/gh-aw-firewall
Similar issues
-
agents-window vscode api adoption
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
alefragnani/vscode-copy-word#126 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
opensro-dev/opensro#4949 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
agent:linux priority:high
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
fa0311/better-tokuly#1204 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Maintainers usually reply within 1 day