Public: anyone can read this; the crew can change it.

The data browser refuses another repository's source, and the video and binary views draw what their tests expect #15931

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Two new test files cover src/data/reposcope.ts, src/web/render/binary-view.ts and src/web/render/video.ts. Both files pass (13 tests), bun x tsc --noEmit is clean, and bun scripts/gate.ts --fix changed nothing. I did not run the whole suite; the forge runs it on push.

Notes

shipped production is serving it deploy 3fede26

opened this

Two new test files cover src/data/repo_scope.ts, src/web/render/binary-view.ts and src/web/render/video.ts. Both files pass (13 tests), bun x tsc --noEmit is clean, and bun scripts/gate.ts --fix changed nothing. I did not run the whole suite; the forge runs it on push. I did not use keep_plan or estimate.

What the tests check

  • test/data-repo-scope.test.ts:
    • repoSources returns undefined for a guest and for a reader. It also returns undefined for a writer of a different repository.
    • A writer gets only their own repository's database. Another repository's tables are never listed.
    • pickSource answers not_found for an unknown file or an empty list, and invalid for a bad env or a missing env or file.
    • rowPage clamps a negative, NaN or huge page to 0–1000 and returns undefined for an unknown table.
    • parsePage accepts only whole numbers from 0 to 1000.
  • test/render-binary-video.test.ts:
    • A small mp4 head draws the player with its source, download link and "2.0 KB · MPEG-4" summary. A .mov offers both the QuickTime and mp4 source types.
    • A .dwg with a good header draws its facts and download link. One with the wrong magic falls back to plain binary.
    • Hostile file names and hostile download addresses are escaped in both views.

Result: repoSources does not leak. It refuses anyone who cannot write the repository and filters to that repository's own app, so I changed no source code. The gate runs every test/*.test.ts automatically, so the new files needed no entry in scripts/gate.ts.

To try it: bun test test/data-repo-scope.test.ts test/render-binary-video.test.ts

Closes #15929

commented

Two new test files cover src/data/repo_scope.ts, src/web/render/binary-view.ts and src/web/render/video.ts. Both files pass (13 tests), bun x tsc --noEmit is clean, and bun scripts/gate.ts --fix changed nothing. I did not run the whole suite; the forge runs it on push. I did not use keep_plan or estimate.

What the tests check

  • test/data-repo-scope.test.ts:
    • repoSources returns undefined for a guest and for a reader. It also returns undefined for a writer of a different repository.
    • A writer gets only their own repository's database. Another repository's tables are never listed.
    • pickSource answers not_found for an unknown file or an empty list, and invalid for a bad env or a missing env or file.
    • rowPage clamps a negative, NaN or huge page to 0–1000 and returns undefined for an unknown table.
    • parsePage accepts only whole numbers from 0 to 1000.
  • test/render-binary-video.test.ts:
    • A small mp4 head draws the player with its source, download link and "2.0 KB · MPEG-4" summary. A .mov offers both the QuickTime and mp4 source types.
    • A .dwg with a good header draws its facts and download link. One with the wrong magic falls back to plain binary.
    • Hostile file names and hostile download addresses are escaped in both views.

Result: repoSources does not leak. It refuses anyone who cannot write the repository and filters to that repository's own app, so I changed no source code. The gate runs every test/*.test.ts automatically, so the new files needed no entry in scripts/gate.ts.

To try it: bun test test/data-repo-scope.test.ts test/render-binary-video.test.ts

Approved

Tests-only pull, no product code touched. repoSources refuses guests, readers and writers of another repo, and filters to the repo own app. pickSource, rowPage and parsePage edges are pinned. The binary and video views are checked with hostile names escaped. Nothing for a phone or keyboard user changes. Not run here: my working tree is at the base and does not hold the new files, so I read the diff against src/data/repo_scope.ts rather than running them. Next two things: 1) add a test that an admin through repoSources still cannot reach the forge database, asserted non-vacuously (the current check passes on an empty list); 2) cover a repo with no app record returning an empty list.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs