Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

build.mjs and thumbs.mjs trust `meta.id` for file paths, and the id regex lives in three copies

Đã đóng
#135 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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ó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
52/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, node.js
Lĩnh vực
build-system, security

Hướng nghiên cứu

Read site/build.mjs around lines 104 and 446, then inspect site/thumbs.mjs, site/validate.mjs, site/lib/scaffold.mjs, and site/checks.mjs for the repeated ID checks and file writes. The issue suggests a shared loader in site/lib/entry-files.mjs and pairing the change with #85. Done means one ID regex definition remains in site/, and a fixture with id: ../x makes node site/build.mjs exit 1 naming the file without touching disk.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

hardening priority: low

Why it matters

validate is the only place that enforces the id charset and id === filename. npm run build on its own, and thumbs.yml (which runs thumbs.mjs before validate), write files whose names come straight from frontmatter. CI order protects main, but a local node site/build.mjs with a bad id writes outside site/dist/.

Evidence (at 69387df)

  • site/build.mjs:446: writeOut(path.join("entry", entry.id, "index.html"), html) with entry.id = String(meta.id) (build.mjs:104). path.join("entry", "../../x", "index.html") resolves under the parent of DIST (build.mjs:292), and produced/pruneDist never see it.
  • site/thumbs.mjs:123-124, 244: ${entry.id}.src, ${entry.id}.webp in the temp dir and in site/public/thumbs/.
  • The same regex is written three times: site/validate.mjs:65, site/lib/scaffold.mjs:30 (exported ID_RE), site/checks.mjs:806 (inline).

Suggested approach

Give site/lib/entry-files.mjs one loader that reads the file, parses frontmatter, and refuses an entry whose id fails ID_RE or differs from the basename; have build, thumbs, check-links and reverify-batch use it. Export ID_RE from one module and import it everywhere. This pairs naturally with #85.

Done when

One definition of the id regex in site/; a fixture entry with id: ../x makes node site/build.mjs exit 1 naming the file, without touching the disk.

Ngôn ngữ chính
JavaScript
Star
58
Fork
15
Merge trung bình
18 giờ 42 phút
Pull request đã merge (30 ngày)
11

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TMHSDigital/Free-Game-Dev-Assets

Tất cả issue của TMHSDigital/Free-Game-Dev-Assets

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.