Thumbnail logo detection ignores logos already recorded in manifest.shared

Đang mở Phù hợp với người mới
#246 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ó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
84/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
backend, data

Hướng nghiên cứu

Đọc vòng lặp đưa logo dùng chung vào site/thumbs.mjs:311-318 và sharedImageIds trong site/lib/thumbs.mjs:162-172, sau đó xem bài kiểm thử sharedImageIds hiện có trong site/lib/lib.test.mjs. Thêm một bài kiểm thử cho bản ghi mới có hash đã tồn tại trong shared, rồi chạy npm test. Hoàn thành khi bản ghi mới được chuyển vào shared và bài kiểm thử chạy thành công.

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

Mô tả

bug good first issue priority: medium

Summary

The three-or-more shared-hash rule that keeps publisher logos out of thumbnails only counts records fetched in the current run, so a logo that was already dropped into manifest.shared is accepted again when a single new entry from the same site is fetched.

Where

  • site/thumbs.mjs:311-318 (logo drop loop)
  • site/thumbs.mjs:263-266 (shared skip)
  • site/lib/thumbs.mjs:162-172 (sharedImageIds)

Details

for (const id of sharedImageIds(thumbs)) {   // counts hashes in `thumbs` only
  shared[id] = thumbs[id];
  delete thumbs[id];
  pending.delete(id);
}
for (const id of Object.keys(thumbs)) delete shared[id];

Records dropped in an earlier run live in shared, not thumbs, so they never count toward the limit again. The existing test (site/lib/lib.test.mjs, the sharedImageIds case) only covers three records sitting in thumbs together.

Impact

A publisher's site-wide logo or social card is published as an asset preview with a "Preview image shown under " credit, which is the case the shared-hash rule (#132) exists to block.

Steps to reproduce

  1. Entries A, B and C on one site share an og:image; a run drops them into manifest.shared.
  2. Add entry D from the same site (or change A's url).
  3. Run node site/thumbs.mjs: D's image hash appears once in thumbs, below the limit, so D keeps the logo. Pure check: sharedImageIds({ D: { hash: "h" } }) is empty even when shared holds three records with hash h.

Suggested fix

Count hashes across { ...shared, ...thumbs } and drop only the ids that are in thumbs; or keep a set of known logo hashes and reject any fetched image whose hash is in it.

Acceptance criteria

  • A newly fetched record whose hash matches a hash already in shared is moved to shared
  • Unit test: one new record plus an already recorded shared hash

Getting started

  • Relevant files: site/thumbs.mjs, site/lib/thumbs.mjs, site/lib/lib.test.mjs
  • Run the tests: npm test; the full local gate is npm run check (Node 22+, no install step)
  • Related docs: CONTRIBUTING.md, site/README.md

Related: #232, #132


Filed by repo-audit/full-audit at 4adb944. Severity: medium. Effort: S. audit-key: bug|site/thumbs.mjs|sharedImageIds

Ngôn ngữ chính
JavaScript
Star
58
Fork
15
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
12

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.