Skip to content

fix(viewer): the wasm import audit reads each import and its shim, and can fail (VW1-21, C6) - #735

Merged
DrunkOnJava merged 4 commits into
mainfrom
ci/c6-viewer
Oct 18, 2026
Merged

DrunkOnJava merged 4 commits into
mainfrom
ci/c6-viewer

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

The VW1-21 privacy audit, which checks that the viewer's wasm imports no network primitive, could never fail. This PR fixes it and finishes C6's deploy-viewer items.

The defect. Every copy of the audit grepped wasm-objdump -j Import -x for "fetch" and similar names, with the quotes. That covers deploy-viewer, publish.yml, the Playwright spec, tools/check-local.sh and .cursor/install.sh. wabt prints an import as <- module.field, with no quotes (src/binary-reader-objdump.cc:1607), so none of those patterns can match.

Red on draft #734, Deploy viewer run 37379307824. The canary imports ./rvt_bg.js.__wbg_fetch_0, and the old audit printed the import and still missed it:

 - func[0] sig=0 <./rvt_bg.js.__wbg_fetch_0> <- ./rvt_bg.js.__wbg_fetch_0
Error: the audit missed the canary's fetch import

The fix: viewer/scripts/audit-wasm-imports.mjs, which needs only Node, so the deploy no longer installs wabt.

  • It reads the imports with WebAssembly.Module.imports() and checks each one twice:
    • By name. wasm-bindgen names a binding of fetch or sendBeacon __wbg_fetch_<hash> and so on.
    • By the body of its shim in the glue. A constructor only shows there: new WebSocket(...) imports as __wbg_new_<hash>.
  • The glue's own fetch() of the .wasm file sits in its init function, outside every shim, so it is not flagged.
  • The audit fails when:
    • the wasm or the glue is missing;
    • an import has no shim it can read;
    • its built-in canary isn't flagged as it should be.

What it found. I ran it on the deployed viewer's wasm and glue from Pages:

  • all 52 imports read, and no network primitive among them;
  • the canary is caught;
  • with one __wbg_new_ shim edited to new WebSocket(...), the audit flags it.

The spec change. viewer/tests/wasm-no-network-imports.spec.ts now reads imports through the script, in its own commit.

  • It keeps its assertion, that hits equals [].
  • It no longer skips when wabt is missing.
  • It also fails on an unreadable shim, or when the wasm has no imports at all.
  • The advisor approved this reader change, as the commit records.

Other deploy-viewer items from C6

  • The pnpm store is cached with cache: pnpm keyed on viewer/pnpm-lock.yaml. setup-node's explicit cache takes precedence over package-manager-cache (src/main.ts:74).
  • Playwright browsers are cached at ~/.cache/ms-playwright, keyed on the Playwright version. The OS packages are still installed each run.
  • When a browser test fails, playwright-report/ and test-results/ are uploaded and kept for 14 days.

The README, AGENTS.md, the privacy-posture and build-pipeline docs, viewer/README.md and the CHANGELOG now describe the new audit.


Note

Medium Risk
Strengthens a privacy-critical CI gate and changes how deploy/publish enforce VW1-21; incorrect shim parsing could false-pass or false-fail builds, but the canary and unread-shim failures mitigate that.

Overview
Fixes VW1-21: the viewer’s wasm network-import gate could never fail because every path grepped wasm-objdump for quoted names like "fetch", which wabt does not emit.

New audit: viewer/scripts/audit-wasm-imports.mjs (Node only) replaces wasm-objdump/wabt in .cursor/install.sh, tools/check-local.sh, deploy-viewer.yml, publish.yml, and the Playwright spec. It lists imports via WebAssembly.Module.imports(), flags network primitives by import name and by each import’s shim body in viewer/pkg/rvt.js, fails on missing artifacts or unreadable shims, and self-checks with a built-in canary. wasm-no-network-imports.spec.ts imports the script directly and adds a canary test (no skip when wabt is absent).

Deploy workflow (C6): drops wabt install; runs the audit after Node/pnpm setup; enables pnpm lockfile caching; caches Playwright browsers by version; uploads playwright-report/ and test-results/ for 14 days on failure.

Docs (README, AGENTS.md, CHANGELOG, privacy/build docs, viewer/README.md) describe the new check.

Reviewed by Cursor Bugbot for commit a5aa488. Configure here.

… (VW1-21 canary)

A canary for the VW1-21 audit: a module importing `./rvt_bg.js.__wbg_fetch_0`
(wasm-bindgen names a binding of fetch `__wbg_fetch_<hash>`), run through the
audit's own `wasm-objdump -j Import -x` and quoted pattern. An audit that
misses it cannot fail on the real wasm either.

Red on draft #734, Deploy viewer run 37379307824 (job 111996809427):

  ✘  14 [chromium] › tests/wasm-no-network-imports.spec.ts:57:1 › the import audit flags a module that imports fetch (VW1-21 canary) (11ms)

    Error: the audit missed the canary's fetch import:

    canary.wasm:	file format wasm 0x1

    Section Details:

    Import[1]:
     - func[0] sig=0 <./rvt_bg.js.__wbg_fetch_0> <- ./rvt_bg.js.__wbg_fetch_0

    expect(received).not.toEqual(expected) // deep equality

    Expected: not []

  1 failed
  20 passed (2.4m)

wabt prints an import with no quotes, so the pattern
`"(fetch|XMLHttpRequest|WebSocket|EventSource|sendBeacon)"` never matches,
and the real-wasm test beside it passed (16ms) whatever the wasm imports.
…d can fail (VW1-21, C6)

The audit grepped `wasm-objdump -j Import -x` for `"fetch"` and the like,
quoted. wabt prints an import as ` - func[N] sig=M <- module.field`, with no
quotes (src/binary-reader-objdump.cc:1607), so no import could ever match:
the deploy step, the release step, check-local.sh and the Cursor setup all
passed whatever the wasm imported.

viewer/scripts/audit-wasm-imports.mjs reads the imports with Node's
WebAssembly.Module.imports() (the C6 item: no wabt install) and checks each
one twice: its name, which shows a binding of fetch or sendBeacon
(`__wbg_fetch_<hash>`), and the body of the shim wasm-bindgen's glue gives
it, which is the only place a constructor shows (`new WebSocket` imports as
`__wbg_new_<hash>`). The glue's own fetch of the .wasm is in its init
function, outside every shim. The audit fails when the wasm or the glue is
missing, when an import has no shim it can read, or when its canary (a
module importing `__wbg_fetch_0`, `__wbg_new_1` and `__wbg_now_2`) is not
flagged as it should be.

On the deployed viewer (Pages, rvt_bg-Cn9tN_Wt.wasm and its glue chunk): 52
imports read, none a network primitive, the canary caught; the same glue
with one `__wbg_new_` shim edited to `new WebSocket(...)` is flagged.

Also in deploy-viewer (C6): the pnpm store cached through setup-node
(`cache: pnpm`, keyed on viewer/pnpm-lock.yaml; an explicit `cache` takes
precedence over `package-manager-cache`, setup-node src/main.ts:74), the
Playwright browsers cached on the Playwright version, and
playwright-report/ and test-results/ uploaded when a browser test fails.
…dit script

Both tests now read imports with scripts/audit-wasm-imports.mjs instead of
wasm-objdump, whose output the old pattern could never match. The existing
assertion is kept as it was (`hits` equals `[]`), and so is the canary's
(`hits` is not `[]`). The test no longer skips when wabt is missing, since
Node is all it needs. It also fails when an import has no shim the audit can
read, or when the wasm has no imports at all; either would make the audit
vacuous again.

Decision (advisor, 2026-10-05): this changes how a pre-existing test reads
its input, makes it stricter, and keeps its assertion. Under the standing
guidance such a reader change is an engineering call for the advisor rather
than one for the maintainer. It is in its own commit.
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 18, 2026 08:44
@DrunkOnJava
DrunkOnJava merged commit b24931a into main Oct 18, 2026
27 checks passed
@DrunkOnJava
DrunkOnJava deleted the ci/c6-viewer branch October 18, 2026 08:48
DrunkOnJava added a commit that referenced this pull request Oct 18, 2026
The README had drifted from main and from the documents it summarises.
Corrected against the sources each statement depends on:

- Release support: Revit 2026 element records are experimental on main
  (support matrix, RE-124), while two later summaries still said "not
  yet", and 2023 has typed elements since 0.4.0, while one summary said
  to treat everything but 2024 and 2025 as scaffold. Each statement now
  names its release and status; docs/supported-profile.md's 2026 row
  and docs/status.md's summary say the same.
- The browser viewer is built from main (deploy-viewer.yml), not from
  0.4.0, and the WebAssembly bindings are the rvt-wasm crate built with
  `wasm-pack build rvt-wasm ...`, not a `wasm` feature of the root crate.
- Privacy: the README and docs/viewer-privacy-posture.md say what each
  check covers (the wasm import audit repaired in #735, the Playwright
  no-network test on Einhoven, the Content-Security-Policy) and that
  they are checks, not a proof; the posture document no longer speaks
  of the viewer as planned.
- Capability summaries: field-type classification is all but 9 to 12
  fields per release since #410 (the library table and CONTRIBUTING
  still said 100%); the walker does use the 7 MVP_TYPED_CLASSES
  decoders; the ElemTable and IFC rows of the reverse-engineering table
  describe today's layout and status; Q4 is answered by RE-146, which
  also corrects the HostObjAttr tag example (the tag a class record
  carries is its base's).
- What main adds since 0.4.0 is summarised from CHANGELOG [Unreleased];
  the README listed one item.
- A short "Start here" table routes readers to the viewer, install,
  Python, input support, the library and contribution before the
  measured tables, which keep their depth. Headings go H1 then H2.
- Scope and tone: the April 2026 probe count, class-record count and
  timing are dated or replaced; quotations disparaging another exporter,
  novelty claims and a guess about an Autodesk workstation are removed;
  the UUID's timestamp is stated as it decodes. The licence section
  keeps the licence, non-affiliation and provenance statements and
  drops the case-law conclusions; NOTICE is unchanged.
- Contributors: the gate and the verification policy match
  tools/ci/test-targets.txt and verify-real-files.sh (unit tests that
  predate the policy are kept but not run), and CONTRIBUTING says that
  approval to run a first-time contributor's checks is separate from
  approval to merge.

All same-page links resolve to headings, every relative link exists,
code fences balance, and the "Nineteen CLIs ship" sentence that
tests/binary_inventory.rs pins is unchanged.


## Testing

- Rendered by GitHub's own renderer (the `readme` API with the HTML media type, on this branch): one H1, 18 H2s, 4 H3s, all 7 tables, and every same-page link resolves to a heading id.
- Every relative link in the README exists in the tree, and code fences balance.
- No command changed except the WebAssembly build line, which now matches `.github/workflows/deploy-viewer.yml`, `docs/install.md` and `viewer/README.md`; CI's viewer build runs that exact command.
- No code changes. `tests/binary_inventory.rs`, the only test that reads the README, pins the CLI sentence, which is unchanged.

## Legal and contribution hygiene

- [x] I agree this work is licensable under Apache-2.0.
- [x] No Autodesk proprietary source, decompiled internals or NDA material.
- [x] No fixtures added.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant