[Duplicate Code] Cloud Hypervisor development-artifact bypass gate duplicated in runtime-validation and preflight-artifact-trust
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 76/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- security
Hướng nghiên cứu
Đọc các kiểm tra hiện có trong src/cloud-hypervisor/runtime-validation.ts và src/cloud-hypervisor/preflight-artifact-trust.ts, sau đó xem src/cloud-hypervisor/artifact-trust.ts là vị trí đề xuất cho helper. Giữ nguyên điều kiện bảo vệ của từng bên gọi và hợp nhất phần kiểm tra biến môi trường cùng thông báo lỗi; hoàn tất khi cả hai đường dẫn đều dùng helper dùng chung và vẫn yêu cầu biến có giá trị bằng '1'.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- TypeScript
- Star
- 169
- Fork
- 89
- Merge trung bình
- 5 giờ 18 phút
- Pull request đã merge (30 ngày)
- 450
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của github/gh-aw-firewall
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
github/gh-aw-firewall#12415 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
code-quality refactoring
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
github/gh-aw-firewall#12345 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Duplicate Code] Repeated lstat identity-swap stub and fixture setup in src/nvx/live-mount-policy.test.tsCó thể đã có người làm @lpcox đã nhận 1 ngày trước. Đang mởcode-quality refactoring
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
github/gh-aw-firewall#12023 · 1 reaction · 2 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
awf-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
github/gh-aw-firewall#11612 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agentic-workflows automated dependencies
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
github/gh-aw-firewall#3837 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của github/gh-aw-firewall
Issue tương tự
-
area: documentation status: in progress type: documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 76/100
Oddmash/oddmash-ui#222 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
appium/appium-wincore-driver#169 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
india-ultimate/hub#715 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation Entwickler
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 89/100
Maintainer thường phản hồi trong vòng 1 ngày