[Duplicate Code] Cloud Hypervisor development-artifact bypass gate duplicated in runtime-validation and preflight-artifact-trust
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 76/100
- Tipo de issue
- Refactorización
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- typescript
- Área
- security
Línea de trabajo
Lee las comprobaciones existentes en src/cloud-hypervisor/runtime-validation.ts y src/cloud-hypervisor/preflight-artifact-trust.ts; después, revisa src/cloud-hypervisor/artifact-trust.ts como ubicación propuesta para el helper. Conserva la condición de protección de cada llamador y consolida la comprobación de la variable de entorno y el mensaje de error; el trabajo estará terminado cuando ambas rutas usen el helper compartido y sigan exigiendo que la variable sea igual a '1'.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- TypeScript
- Estrellas
- 169
- Forks
- 89
- Merge medio
- 5 h 18 min
- PR fusionados (30 d)
- 450
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de github/gh-aw-firewall
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
github/gh-aw-firewall#12415 ·
Los mantenedores suelen responder en 1 día
-
code-quality refactoring
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
github/gh-aw-firewall#12345 ·
Los mantenedores suelen responder en 1 día
-
[Duplicate Code] Repeated lstat identity-swap stub and fixture setup in src/nvx/live-mount-policy.test.tsPosiblemente ocupada @lpcox la tomó hace 1 día. Abiertocode-quality refactoring
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
github/gh-aw-firewall#12023 · 1 reacción · 2 asignados ·
Los mantenedores suelen responder en 1 día
-
awf-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
github/gh-aw-firewall#11612 ·
Los mantenedores suelen responder en 1 día
-
agentic-workflows automated dependencies
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
github/gh-aw-firewall#3837 ·
Los mantenedores suelen responder en 1 día
Todos los issues de github/gh-aw-firewall
Issues similares
-
area: documentation status: in progress type: documentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 76/100
Oddmash/oddmash-ui#222 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
appium/appium-wincore-driver#169 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 3 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
india-ultimate/hub#715 ·
Los mantenedores suelen responder en 1 día
-
documentation Entwickler
Dificultad 1/5 Menos de una hora Aptitud para principiantes 89/100
Los mantenedores suelen responder en 1 día