fix(anatomy): V1-2.2 review findings, PIs and HTML refused, bounds

Security audit (PASS, 2 MEDIUM, 2 LOW) and verifier (ECARTS 6) on
741c25c: processing instructions and HTML fetchers refused, active
content under a long title classified, linear review groups, full
fixpoint check, bounded preview drawings, missing cap fixtures and
property checks, record wordings.
This commit is contained in:
bchanot committed 2026-10-29 13:38:33 +01:00
1 parent 741c25c464
commit 8294d5471c
15 files changed
+448 -72

No files matched your search

+17 -2
View File
@@ -3,8 +3,9 @@
//! and `packages/core-wasm/pkg-proofs` (with the trap exports, tests only); loaded lazily by
//! the application behind the sheet and import paths (`packages/core-wasm/src/runtime.ts`).
use faunosteo_core::domain::archive::SnapshotCaps;
use faunosteo_core::domain::sheet::LoadedSheet;
use faunosteo_core::domain::sheet::preview::PreviewDrawing;
use faunosteo_core::domain::sheet::preview::{MAX_HELD_DRAWINGS, PreviewDrawing};
use faunosteo_core::pdf::read::MAX_PDF_BYTES;
use wasm_bindgen::prelude::{JsError, wasm_bindgen};
@@ -71,6 +72,8 @@ impl SheetHandle {
#[wasm_bindgen]
pub struct PreviewBuilder {
drawings: Vec<PreviewDrawing>,
/// A drawing was refused: the build answers `caps`.
refused: bool,
}
#[wasm_bindgen]
@@ -79,21 +82,33 @@ impl PreviewBuilder {
pub fn new() -> PreviewBuilder {
PreviewBuilder {
drawings: Vec::new(),
refused: false,
}
}
pub fn add_drawing(&mut self, asset_id: &str, sha256: &str, bytes: &[u8]) {
/// `false` (nothing kept) past the preview's drawing count or a drawing over 2 MiB; the
/// build then refuses with `caps` as the core does.
pub fn add_drawing(&mut self, asset_id: &str, sha256: &str, bytes: &[u8]) -> bool {
let full = self.drawings.len() >= MAX_HELD_DRAWINGS;
if full || bytes.len() > SnapshotCaps::ASSET_BYTES {
self.refused = true;
return false;
}
self.drawings.push(PreviewDrawing {
asset_id: asset_id.to_owned(),
sha256: sha256.to_owned(),
bytes: bytes.to_vec(),
});
true
}
/// Consumes the builder; throws an `Error` worded `<kind>: <detail>` (`invalid_document`,
/// `drawing_missing`, `drawing_hash_mismatch`, `fingerprint_mismatch`, `caps`, or
/// `invalid_shape` / `invalid_json` for the input).
pub fn build(self, input: &str) -> Result<PreviewSheet, JsError> {
if self.refused {
return Err(JsError::new("caps: drawings"));
}
faunosteo_core::facade::load_preview(input, self.drawings)
.map(|sheet| PreviewSheet { sheet })
.map_err(|failure| JsError::new(&format!("{}: {}", failure.kind, failure.detail)))