Upload check: `isValidGlbMagic` skips the declared-length check the server enforces
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 88/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript
- 領域
- frontend
調査の方向性
src/shared/glb-magic.js から始めてください。isValidGlbMagic はマジックとバージョンを検証していますが、バイトオフセット 8 にある宣言された長さを読んでいません。参照として api/_lib/glb-inspect.js のサーバー側チェックを使ってください。宣言された長さが 20 未満、または file.size より大きい場合は拒否します。読み取るのは引き続き file.slice(0, 12) のみです。まず issue の probe を実行してください。修正後は、両方のヘッダーに対して false を返すはずです。新しい tests/glb-magic.test.js が npx vitest run で通り、受け入れ基準を満たせば完了です。
索引モデルが issue の本文から書いたものです。
説明
Context
Before a user's 3D model is uploaded, the browser checks its 12-byte GLB header so a misnamed JPEG is rejected instantly instead of after a full upload. That check is isValidGlbMagic in src/shared/glb-magic.js, used by src/create-agent.js and src/agent-edit.js.
Its header comment says it "mirrors the server-side isValidGlbHeader() in api/_lib/glb-inspect.js" and that it checks "that the declared file length field is at least the minimum GLB size". It does not check the length field at all. It checks the magic bytes and the version, then returns true.
The server version in api/_lib/glb-inspect.js does more:
const declaredLen = view.getUint32(8, true);
if (declaredLen > buf.length || declaredLen < 20) return false;
So a truncated or corrupted GLB (a valid 12-byte header whose declared length is larger than the file, or smaller than 20) passes the browser check and is only rejected after it has been uploaded. The two checks are supposed to agree, and today they do not. There is also no test for glb-magic.js.
Verified on main:
node --input-type=module -e "
import { isValidGlbMagic } from './src/shared/glb-magic.js';
const header = (declared) => { const b = new ArrayBuffer(12); const v = new DataView(b); v.setUint32(0, 0x46546c67, true); v.setUint32(4, 2, true); v.setUint32(8, declared, true); return b; };
console.log('declares 5000 bytes, file is 12:', await isValidGlbMagic(new File([header(5000)], 'a.glb')));
console.log('declares 8 bytes:', await isValidGlbMagic(new File([header(8)], 'a.glb')));
"
declares 5000 bytes, file is 12: true
declares 8 bytes: true
Both should be false, because the server rejects both.
What to change
In isValidGlbMagic, read the declared length (little-endian uint32 at byte offset 8) and return false when it is below 20 or larger than file.size, matching the server. Keep reading only the first 12 bytes; the point of the function is that it never buffers the whole file. Make the header comment match what the code does.
Add tests/glb-magic.test.js. Node 20 and later have a global File, so tests can build headers the way the probe above does.
Acceptance criteria
- A valid header whose declared length equals the file size returns
true. - Declared length larger than
file.sizereturnsfalse. - Declared length below 20 returns
false. - Wrong magic, version 1, a file under 12 bytes, and a missing file all return
false(these already do; lock them in). - The function still reads only
file.slice(0, 12). - The header comment describes exactly the checks the code performs.
How to test
npx vitest run tests/glb-magic.test.js
npm test
Good first issue: a small, well-bounded correctness fix with a clear reference implementation next door. Comment "taking this" before you start.
- 主要言語
- JavaScript
- スター
- 230
- フォーク
- 63
- 平均マージ
- 15時間 43分
- マージ済み PR(30日)
- 225
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nirholas/three.ws のほかの issue
-
enhancement triage
難易度 1/5 1時間未満 初心者へのやさしさ 87/100
メンテナーはふだん 1 日以内に返信
-
Money Pulse: compact numbers roll over into the wrong unit (`$1000`, `1000.0k`)再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンbug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
nirholas/three.ws#344 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug triage
難易度 4/5 1〜2日 初心者へのやさしさ 12/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 1〜2日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 10/100
メンテナーはふだん 1 日以内に返信
nirholas/three.ws の issue をすべて見る
似ている issue
-
Band: compact mode never draws on Claude Code 2.1.292 (level Button has a Text child)対応中かも @Bunty9 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
DietrichGebert/ponytail#1437 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
huggingface/transformers.js#1945 ·
メンテナーはふだん 1 日以内に返信
-
ACK_WAITING HELP_WANTED UPDATE_CS
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
OWASP/CheatSheetSeries#2977 ·
メンテナーはふだん 1 日以内に返信
-
backend bug frontend
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
freshframework/fresh#3920 ·