fix(anatomy): V1-2.2 read url() references in their strict spelling only
Security review BLOCK(1): url(#%61) passed the dangling check and the per-view scoping and resolved in browsers. One strict reading now, other spellings are active content; glued names are other functions; the composer refuses an unscoped reference; owner export procedure.
This commit is contained in:
1 parent
5281337412
commit
a678faaa23
13 files changed
+553
-70
No files matched your search
@@ -0,0 +1,193 @@
|
||||
# Security gate, V1-2.2 owner arbitrations (diff 17d9199..HEAD)
|
||||
|
||||
Mode: audit. Branch `feature/v1-2-anatomical-sheets`, worktree `v1-2`. Date 2026-10-29.
|
||||
|
||||
```
|
||||
SECURITY — VERDICT: BLOCK(1)
|
||||
TOOL: semgrep 1.168.0 present but NOT RUN (p/security-audit, p/secrets, p/owasp-top-ten are fetched from the registry at run time and the brief forbids network) — effectively DEGRADED: checklist + guardrails scanner + manual attack review + probes on the built wasm module and on headless browsers
|
||||
SCOPE: 40 files
|
||||
BLOCKING:
|
||||
1. [HIGH] url-reference-spelling-mismatch (reader and composer read fewer `url(#…)` spellings than browsers resolve) — crates/core/src/anatomy/svg/sanitize.rs:488 (url_targets), :502 (scope_url_targets), :523 (urls_are_local), :528 (calls_only_local_url); crates/core/src/anatomy/svg/refs.rs:115 (reference_ids); crates/core/src/anatomy/compose.rs:98 (scope_ids) — `fill="url(#%66v.main.g)"` (also `url(#%61)`, and in Chromium `url('#<TAB>a')`) passes the sanitiser, is invisible to `check_targets`, `check_references` and `scope_url_targets`, and is resolved by Chromium and Firefox after percent-decoding: it defeats B1 (dangling check), B2 (view scoping, it reaches another view's `fv.main.g`) and the expansion budget (a 5 KB drawing hangs Chromium for 45 s) — hint: refuse in `urls_are_local` any `url(` whose target is not `#` + `[A-Za-z_][\w.:-]*` followed by optional space or the closing quote then `)` (so `url(#)`, `%`, tab, `/`, non-ASCII after `#` are refused as active), so the sanitiser admits exactly what `url_targets` reads; add a fail-closed check in `compose_canvas` that every composed `url(` target starts with the view scope
|
||||
REPORTED (non-blocking):
|
||||
- [MEDIUM] scope-key-is-view-id-only — crates/core/src/anatomy/compose.rs:92 — two documents that share a view id (every sheet has `main`) and are inlined in one page share the scope `fv.main.`; the first element in tree order wins, so §10 "never in another view" holds inside one document only
|
||||
- [LOW] colour-function-not-whole-value — crates/core/src/anatomy/svg/sanitize.rs:547 — strict `rgb()` is stripped wherever it sits in the value, so `rgb(1,2,3)rgb(4,5,6)` and `url(#a rgb(1,2,3))` (refused before) now pass; invalid CSS the browser drops, no fetch found in 19 hostile values
|
||||
- [LOW] test-oracle-shares-the-blind-spot — crates/core/tests/svg_scope.rs:107, apps/app/tests/helpers/svgTree.ts:112 — the oracles read references with `url_targets` / `replaceAll('url(#'`, so they cannot see a reader/browser divergence; no test uses `%`, tab or a non-id first character
|
||||
- [LOW] new-lint-allow (context, not a security suppression) — crates/core/tests/svg_scope.rs:6 — `#![allow(clippy::disallowed_methods, clippy::unwrap_used, clippy::expect_used)]`, same header as 49 other test files
|
||||
- [LOW] mutation-script-rewrites-sources — .claude/audits/2026-10-29-v1-2-2-mutations-arbitrations.py — edits source files in place and restores them in `finally`; a SIGKILL leaves a mutant in the tree (read only, not run)
|
||||
PROOF: semgrep 0 rules on 0 files (not run, no network) → 0 findings; checklist 9 checks (secrets, SQL concatenation, unsanitised render, authz, error surfaces, logging, tracked .env, guardrails scanner, new suppressions) → 1 context finding; manual attack review of 12 files + 3 probe families (built wasm module, Chromium 1248, Firefox 1555) → 1 HIGH, 1 MEDIUM, 3 LOW
|
||||
```
|
||||
|
||||
REPORT_WRITTEN: .claude/audits/2026-10-29-v1-2-2-arbitrations-security.md
|
||||
|
||||
## 1. The blocking finding
|
||||
|
||||
### What the code does
|
||||
|
||||
`sanitize::value_acceptable` (sanitize.rs:417) lets a `url(` through when the text after the
|
||||
opening, the CSS space and the optional quote starts with `#` (`urls_are_local`, :523), and
|
||||
when no other `(` remains (`calls_only_local_url`, :528). It does not look at what follows
|
||||
the `#`.
|
||||
|
||||
Three readers then work on the same value, each with its own idea of "the id":
|
||||
|
||||
- `url_targets` (:488) takes the longest run of `[A-Za-z0-9_.:-]` after `#`, and drops an
|
||||
empty one.
|
||||
- `scope_url_targets` (:502) writes the view scope after `#` only when the next character is
|
||||
in that set.
|
||||
- `refs::reference_ids` (refs.rs:115), which feeds `check_targets` (B1) and
|
||||
`check_references` (cycle and expansion budget), calls `url_targets`.
|
||||
|
||||
When the first character after `#` is outside the set, all three see "no reference" and the
|
||||
value is stored and composed byte for byte. A browser does not: it percent-decodes the
|
||||
fragment (Chromium and Firefox, measured below), and Chromium also drops a tab inside a
|
||||
quoted CSS string (URL Standard: tab and newline are removed from the input).
|
||||
|
||||
### Probes (all throwaway, in the session scratchpad, nothing written in the worktree)
|
||||
|
||||
1. Built wasm module of the worktree (`packages/core-wasm/pkg`, built 16:28, after the last
|
||||
source edit at 16:18), `clean_svg` on a one-rect drawing:
|
||||
- `fill="url(#nope)"` gives `rejected dangling_reference`.
|
||||
- `fill="url(#%6eope)"` gives `clean`. The dangling check is bypassed.
|
||||
- `fill="url(#%66v.main.g)"` with a local `<linearGradient id="g"/>` gives `clean`.
|
||||
2. Same module, `PreviewBuilder` on the equine draft document with that drawing as the
|
||||
horse asset, `view.canvas`:
|
||||
- view `main`: `<linearGradient id="fv.main.g"/>` and `<rect fill="url(#%66v.main.g)">`.
|
||||
- view `head`: `<linearGradient id="fv.head.g"/>` and `<rect fill="url(#%66v.main.g)">`.
|
||||
The reference is not rewritten. In the page the `head` rectangle resolves into the
|
||||
`main` canvas.
|
||||
3. Browsers, inline SVG in an HTML page, `fill="url(#a)"` control painted red:
|
||||
|
||||
| spelling | Chromium 1248 | Firefox 1555 |
|
||||
|---|---|---|
|
||||
| `url(#a)` | resolves | resolves |
|
||||
| `url(#%61)` | resolves | resolves |
|
||||
| `style="fill:url(#%61)"` | resolves | resolves |
|
||||
| `url(#%66v.other.x)` (another view's scoped id) | resolves | resolves |
|
||||
| `url('#<TAB>a')` (`	`) | resolves | does not |
|
||||
| `url(#nope)` | none | none |
|
||||
|
||||
WebKit was not tested.
|
||||
4. Budget bypass, Chromium 1248, nested masks written with `url(#%6dN)`, fan-out 10 per
|
||||
level, one root rectangle masked by level 0:
|
||||
|
||||
| levels | size | render time |
|
||||
|---|---|---|
|
||||
| 5 | 3.3 KB page | 0.5 s |
|
||||
| 6 | 4.1 KB page | 4.6 s |
|
||||
| 7 | 4.8 KB page | 44.8 s |
|
||||
|
||||
Each level costs ten times more. The same structure with plain `url(#mN)` is refused by
|
||||
`expanded_size` (10^7 against 50,000). In the core, a value of 250k `url(#a)` gives
|
||||
`too_complex` in 58 ms, the same value with `url(#%61)` gives `clean` in 107 ms.
|
||||
Firefox timing was not measured.
|
||||
|
||||
### Impact
|
||||
|
||||
- B2 is not met: a drawing can resolve into another view of the page (paint servers,
|
||||
filters, masks, clip paths). Into the page itself the reach is theoretical today: no
|
||||
page-level SVG resource with an id exists in `apps/app/src` (the brand logos are loaded
|
||||
as `<img>` or rasterised, not inlined). Visual only, no fetch, no script.
|
||||
- B1 is not met: a reference to an id the drawing does not define is accepted when spelled
|
||||
this way.
|
||||
- The R3 expansion budget is bypassed. An editor uploads under 5 KB, the verdict and the
|
||||
preview say `ok`, the reviewer's or any practitioner's tab freezes when the view draws.
|
||||
The PDF export rasterises the same view.
|
||||
- The budget bypass exists at 17d9199 (the old `urls_are_local` is the same). The diff does
|
||||
not create it, but B1 and B2 are written to close exactly this class and rest on the same
|
||||
reader, so they ship with the hole.
|
||||
|
||||
### Fix direction (no code written, report only)
|
||||
|
||||
1. Make the sanitiser the authority. In `urls_are_local` (or a new check called first in
|
||||
`value_acceptable`), require for every `url(`: CSS space, optional quote, `#`, one id
|
||||
that satisfies `is_reference_name` (first character `[A-Za-z_]`), then space, the same
|
||||
quote if one was opened, and `)`. Anything else is non-local and therefore active
|
||||
(rejected), which also removes `url(#)`. Then the set the sanitiser admits and the set
|
||||
`url_targets` reads are the same by construction.
|
||||
2. Fail closed in the composer: after `scope_ids`, walk the composed tree and refuse the
|
||||
canvas (`ComposeError`) when a `url(` target does not start with the view scope, or an
|
||||
`href` does not start with `#fv.<view>.`. A future reader divergence then cannot produce
|
||||
an unscoped reference silently.
|
||||
3. Tests with an independent oracle: for every accepted value, normalise the way the URL
|
||||
Standard does (strip tab and newline, percent-decode the fragment) and assert it equals
|
||||
the `url_targets` list; cases `url(#%61)`, `url(#%66v.x.g)`, `url('#<TAB>a')`, `url(#)`,
|
||||
`url(#é)`, `url(#a%2Eb)` (allowed only if the first character rule holds).
|
||||
4. After the fix, correct the statements that are false today: docs/development/
|
||||
V1-2_ANATOMICAL_SHEETS.md §9.2 and §10 ("a reference resolves only inside its own view"),
|
||||
docs/development/RUST.md, docs/ANNOTATION-RENDERING.md.
|
||||
|
||||
## 2. Reported findings
|
||||
|
||||
- MEDIUM, scope key. `id_scope` (compose.rs:92) is `fv.<view id>.`. View ids are unique inside
|
||||
one document, not across sheets. A catalogue grid, a comparison or a preview next to the
|
||||
editor puts two `main` canvases in one page; ids collide and `getElementById` takes the
|
||||
first. Sheet B can then draw with sheet A's gradient or mask. Not verified against the
|
||||
V1-2.3+ screens (they are not in this diff). Add a per-handle token, or state in §10 that
|
||||
one sheet is mounted at a time.
|
||||
- LOW, colour function. `without_colour_functions` (:547) removes a strict `rgb()` anywhere in
|
||||
the text. Probed: 19 hostile values around a colour (`url(http://…)`, `expression(`,
|
||||
`image-set(`, `src(`, `cross-fade(`, `\72`, `/**/url(//…)`, `behavior:`, `@import`, `var(`,
|
||||
`attr(`, `element(`, `-moz-element(`, `paint(`, `RGB(`, nested `url(#a)` as an argument) are
|
||||
all refused or removed. The remaining looseness is cosmetic: `rgb(1,2,3)rgb(4,5,6)` and
|
||||
`url(#a rgb(1,2,3))` pass and are invalid CSS (bad-url token), dropped by the browser.
|
||||
- LOW, test oracle. See table line above.
|
||||
- LOW, lint allow and mutation script. See table lines above.
|
||||
|
||||
## 3. What was attacked and held
|
||||
|
||||
- Colour exception, `smuggle url(`, `expression(`, escape, `image-set(`, fetch: a backslash is
|
||||
refused for every attribute before the colour code runs; `style_forbidden` runs on the
|
||||
original text; a `(` that is neither a local `url(#` nor a strict colour function stays and
|
||||
refuses the value. The colour parser admits only ASCII digits, `.`, `%`, comma, CSS space
|
||||
and `)` between `rgb(` and the end, so nothing can hide inside it. `glued` blocks `xrgb(`,
|
||||
`-rgb(`, `\rgb(`. Uppercase is refused (safe side). No index can leave the slice
|
||||
(`digits(end + 1)` only after a `.` at `end`; `index += 1` only after a matched separator).
|
||||
Probe table: 17 `fill` and 5 `style` values (19 hostile, 3 valid controls), all as expected.
|
||||
- Parsing cost, measured through the built module, attribute values near 2 MiB: `rgb(1,2,3)`
|
||||
x150k 132 ms, `rgb(` x400k 35 ms, `rgb(1,` x300k 37 ms, `rgb(` plus 1.9M spaces 26 ms, plus
|
||||
1.9M digits 23 ms, mixed spacing 84 ms, `url(#` x400k 97 ms, `url(` x400k 15 ms. By reading:
|
||||
each failed colour attempt scans one run of digits and spaces that cannot contain `rgb`,
|
||||
and `from` always advances at least 3.
|
||||
- `check_targets`, `scope_ids`, `references_resolve`: one pass, recursion bounded by the
|
||||
prescan depth cap 64, one `HashSet`. Scoped output is bounded by the budget (50,000
|
||||
references) plus 20,000 ids, then by `MAX_COMPOSED_BYTES` (4 MiB) after serialisation.
|
||||
- Scoping, spellings: `url( '#x')`, `URL(#x)`, newline and tab before `#` or the quote,
|
||||
and `.` in ids all go through the same `url_openings` / `skip_url_prefix` for the checker
|
||||
and the composer, so they agree with each other (the unit test at sanitize.rs:715 covers it).
|
||||
`href` and `xlink:href` are strict (`#` + reference name after ASCII trim), so a `%`, a tab or
|
||||
an odd prefix cannot be kept: a prefixed `x:href` is not on the allowlist and the
|
||||
`xlink:href` must be in the xlink namespace. View ids match `[a-z0-9][a-z0-9_-]{0,63}`
|
||||
(js.rs:158, enforced at deserialisation), so no `.` in a view id and one scope is never the
|
||||
start of another's. The layer has no `id`, `href` or `url(`.
|
||||
- Checker versus composer, same reading: `reference_ids` (all attributes through `url_targets`,
|
||||
`href` / `xlink:href` apart) and `scope_ids` (same set, `id` added) differ only on `id`,
|
||||
which cannot hold `(`. No attribute is rewritten and unread, or read and unrewritten.
|
||||
The one divergence is browser against both (finding 1).
|
||||
- Stored form: verdict (verdict.rs:323) and preview (preview.rs:119) compare the whole text
|
||||
with `stored_form(root)` after a removal-free read, so a comment, CDATA, entity, PI, BOM,
|
||||
another declaration or spacing cannot reach a round; the sha256 is checked first. The
|
||||
upload tool (upload.rs) and `clean_svg` do the same. Compose works on the sanitised tree,
|
||||
never on stored text. The `xmlns:xlink` value is unchecked but inert (a rebinding drops the
|
||||
xlink attributes that depend on it).
|
||||
- `sheet.edit remove` (edit.rs:570): `dependents` runs after `locate`, before any mutation,
|
||||
so a refusal leaves the document unchanged; it is a client rule, no authorisation change.
|
||||
- Checklist greps on the added lines (secrets, SQL built by concatenation, innerHTML / eval /
|
||||
raw, logging, tracked `.env`): nothing. Guardrails scanner: 0 FAIL, 28 WARN, all in
|
||||
migrations the diff does not touch, so none kept (gate rule).
|
||||
|
||||
## 4. Not done, and limits
|
||||
|
||||
- semgrep did not run. The three packs come from the registry and the brief says no network.
|
||||
The Rust surface of those packs is thin; the manual review above is the substitute, it is
|
||||
not equivalent.
|
||||
- WebKit was not probed; the Firefox DoS time was not measured; the `<TAB>` form is
|
||||
Chromium only.
|
||||
- Probes ran headless browsers on local files and Node on the built module. No cargo, wasm or
|
||||
Docker build was started (the `check:all` in the worktree was left alone). The probe files
|
||||
(HTML pages, screenshots, two Node scripts, a Firefox profile) sit in the session
|
||||
scratchpad `/tmp/claude-1000/-home-bchanot-Documents-faunosteo/0cee2841-f2bb-4081-9e59-3e6fe9cc8112/scratchpad/probe-audit`;
|
||||
the `rm -rf` that would have removed them was refused by the permission rules and was not
|
||||
retried by another route. Nothing was written in the worktree besides this report; `git
|
||||
status` there shows only this file and the owner's `exports/owner/README.md`.
|
||||
- The verdict runs in the core, client or worker side; the SQL side cannot check the stored
|
||||
form. That trust boundary is outside this diff.
|
||||
@@ -1,4 +1,4 @@
|
||||
# V1-2.2 owner arbitrations, mutation run (evidence .claude/audits/2026-10-29-v1-2-2-evidence.md §7): each
|
||||
# V1-2.2 owner arbitrations, mutation run (evidence .claude/audits/2026-10-29-v1-2-2-evidence.md §7 (A1-A12 on 5281337, A13-A17 after the security review)): each
|
||||
# mutant is applied to its source file, its cargo suite runs (`lib` = the crate's unit tests), the file is
|
||||
# restored. Run from the repo root.
|
||||
import subprocess
|
||||
@@ -15,6 +15,11 @@ muts=[
|
||||
('A10 glued name accepted','crates/core/src/anatomy/svg/sanitize.rs',' _ if glued => return None,',' _ if false && glued => return None,','lib'),
|
||||
('A11 mixed units accepted','crates/core/src/anatomy/svg/sanitize.rs',' _ if *percentages.get_or_insert(percent) != percent => return None,',' _ if *percentages.get_or_insert(percent) != percent && false => return None,','lib'),
|
||||
('A12 rgba with three components','crates/core/src/anatomy/svg/sanitize.rs',' _ if rest.starts_with("rgba(") => (4, 5),',' _ if rest.starts_with("rgba(") => (3, 5),','svg_clean'),
|
||||
('A13 quote left unmatched','crates/core/src/anatomy/svg/sanitize.rs',' if bytes.get(index) != Some("e) {\n return None;\n }\n index += 1;',' if bytes.get(index) == Some("e) {\n index += 1;\n }','svg_clean'),
|
||||
('A14 any id after #','crates/core/src/anatomy/svg/sanitize.rs',' if !is_reference_name(&value[id_start..id_end]) {',' if false {','svg_clean'),
|
||||
('A15 glued url( read as url(','crates/core/src/anatomy/svg/sanitize.rs',' if !glued {\n return Some(from);',' if true || !glued {\n return Some(from);','svg_clean'),
|
||||
('A16 colour glued to what follows','crates/core/src/anatomy/svg/sanitize.rs',' ends.then_some(at + index)',' Some(at + index)','svg_clean'),
|
||||
('A17 percent-escaped id read as local','crates/core/src/anatomy/svg/sanitize.rs'," .take_while(|b| b.is_ascii_alphanumeric() || matches!(b, b'_' | b'.' | b':' | b'-'))"," .take_while(|b| b.is_ascii_alphanumeric() || matches!(b, b'_' | b'.' | b':' | b'-' | b'%'))",'svg_scope'),
|
||||
]
|
||||
for name,path,old,new,suite in muts:
|
||||
src=open(path).read()
|
||||
|
||||
@@ -93,3 +93,15 @@ Brief « V1-2.2 : arbitrages du propriétaire et finalisation » on `17d9199`. D
|
||||
- B7 Wasm: `--remove-name-section` only; the 600 000-byte cap and `size.test.ts` unchanged.
|
||||
- B8 Still: no SQL change, no protected reader modified (A13), the N-1 copies and frozen oracle files untouched (declared
|
||||
changes applied in tests only), no DEV operation, no merge.
|
||||
|
||||
### After the reviews of 5281337 (security BLOCK(1) HIGH, verifier ECARTS(2))
|
||||
|
||||
Delta under review: `5281337..HEAD`.
|
||||
|
||||
- B9 A `url(` is kept only in its strict spelling (`sanitize::local_url_target`); every other spelling a browser could
|
||||
normalise (`%XX`, tab, space or unbalanced quote inside, empty or non-ASCII id) is active content; `url(` or `rgb(`
|
||||
glued to a longer name (ASCII or not) is another function; a colour is not glued to what follows; the composer refuses,
|
||||
fail-closed, a canvas keeping a reference outside its scope (`unscoped_reference`). Tests written apart from the reader
|
||||
(`svg_clean::every_url_spelling_but_the_strict_one_is_refused`, `svg_scope::every_reference_a_browser_reads_stays_in_its_view`).
|
||||
- B10 The verifier's doc drift fixed (RUST.md §12.1, §12.4, §12.5, §12.6; exports README); the MEDIUM (scope unique per
|
||||
document only) recorded as a requirement for any page inlining two documents (contract §10, RUST.md §12.7).
|
||||
@@ -15,7 +15,7 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
use super::layer::{LayerError, find_view, render_layer, view_box_of};
|
||||
use super::svg::sanitize::{local_reference_text, scope_url_targets};
|
||||
use super::svg::sanitize::{local_reference_text, scope_url_targets, url_targets, urls_are_local};
|
||||
use super::svg::serialize::is_xml_text;
|
||||
use super::svg::{Element, Node};
|
||||
use crate::domain::sheet::AnatomicalSheetDocument;
|
||||
@@ -31,6 +31,9 @@ pub enum ComposeError {
|
||||
UnknownView,
|
||||
/// A label or a path of the layer holds a code point XML 1.0 cannot carry.
|
||||
InvalidCharacter,
|
||||
/// A reference of the drawing kept outside its view's scope after scoping (fail-closed:
|
||||
/// the reader keeps no such reference, so this never happens on a read drawing).
|
||||
UnscopedReference,
|
||||
}
|
||||
|
||||
impl From<LayerError> for ComposeError {
|
||||
@@ -81,7 +84,11 @@ pub fn compose_canvas(
|
||||
.or_else(|| asset.attr("viewBox").map(str::to_owned))
|
||||
.unwrap_or_else(|| CANVAS_FALLBACK_VIEW_BOX.to_owned());
|
||||
root.set_attr("viewBox", view_box);
|
||||
scope_ids(&mut root, &id_scope(view_id));
|
||||
let scope = id_scope(view_id);
|
||||
scope_ids(&mut root, &scope);
|
||||
if !references_scoped(&root, &scope) {
|
||||
return Err(ComposeError::UnscopedReference);
|
||||
}
|
||||
let layer = render_layer(document, view_id, &HashSet::new())?;
|
||||
root.children.push(Node::Element(checked(layer)?));
|
||||
Ok(root)
|
||||
@@ -93,6 +100,27 @@ pub fn id_scope(view_id: &str) -> String {
|
||||
format!("fv.{view_id}.")
|
||||
}
|
||||
|
||||
/// Every `href` / `xlink:href` names `#<scope>…`, and every value holding `url(` holds only
|
||||
/// local references whose ids start with `scope`.
|
||||
fn references_scoped(element: &Element, scope: &str) -> bool {
|
||||
let attrs_scoped = element.attrs.iter().all(|attr| match attr.qname.as_str() {
|
||||
"href" | "xlink:href" => local_reference_text(&attr.value)
|
||||
.strip_prefix('#')
|
||||
.is_some_and(|id| id.starts_with(scope)),
|
||||
_ if attr.value.to_ascii_lowercase().contains("url(") => {
|
||||
urls_are_local(&attr.value)
|
||||
&& url_targets(&attr.value)
|
||||
.iter()
|
||||
.all(|id| id.starts_with(scope))
|
||||
}
|
||||
_ => true,
|
||||
});
|
||||
attrs_scoped
|
||||
&& element
|
||||
.element_children()
|
||||
.all(|child| references_scoped(child, scope))
|
||||
}
|
||||
|
||||
/// Every `id`, every local `href` / `xlink:href` and every `url(#id)` of the drawing, with
|
||||
/// `scope` written in front of the id.
|
||||
fn scope_ids(element: &mut Element, scope: &str) {
|
||||
|
||||
@@ -453,75 +453,93 @@ pub fn is_reference_name(value: &str) -> bool {
|
||||
&& chars.all(|c| c.is_ascii_alphanumeric() || matches!(c, '_' | '.' | ':' | '-'))
|
||||
}
|
||||
|
||||
/// Byte offsets right after each case-insensitive `url(`.
|
||||
/// A character that continues a CSS identifier before a function name: `xurl(` or `érgb(` is
|
||||
/// another function, never `url(` or `rgb(` (V1-2.2 reviews).
|
||||
fn continues_identifier(c: char) -> bool {
|
||||
c.is_ascii_alphanumeric() || matches!(c, '_' | '-' | '\\') || !c.is_ascii()
|
||||
}
|
||||
|
||||
/// Byte offsets right after each case-insensitive `url(` that is not the end of a longer
|
||||
/// function name.
|
||||
fn url_openings(value: &str) -> impl Iterator<Item = usize> + '_ {
|
||||
let lower = value.to_ascii_lowercase();
|
||||
let mut from = 0;
|
||||
std::iter::from_fn(move || {
|
||||
let at = lower.get(from..)?.find("url(")? + from;
|
||||
from = at + 4;
|
||||
Some(from)
|
||||
loop {
|
||||
let at = lower.get(from..)?.find("url(")? + from;
|
||||
from = at + 4;
|
||||
let glued = value[..at]
|
||||
.chars()
|
||||
.next_back()
|
||||
.is_some_and(continues_identifier);
|
||||
if !glued {
|
||||
return Some(from);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// After `url(`: whitespace, an optional quote, whitespace; returns the offset of the next
|
||||
/// character. Only CSS whitespace is skipped, as the browser's CSS tokenizer skips it: the
|
||||
/// engine skipped JavaScript spaces, so a no-break space before `#a` read as local but the
|
||||
/// browser resolves it as a relative URL (security audit R3, pass 2).
|
||||
fn skip_url_prefix(value: &str, at: usize) -> usize {
|
||||
let rest = &value[at..];
|
||||
let mut chars = rest.char_indices().peekable();
|
||||
let skip_space = |chars: &mut std::iter::Peekable<std::str::CharIndices<'_>>| {
|
||||
while chars.peek().is_some_and(|&(_, c)| is_css_space(c)) {
|
||||
chars.next();
|
||||
}
|
||||
};
|
||||
skip_space(&mut chars);
|
||||
if chars.peek().is_some_and(|&(_, c)| c == '\'' || c == '"') {
|
||||
chars.next();
|
||||
/// A local reference after the `url(` opening ending at `at`, read as strictly as the reader
|
||||
/// keeps it (owner decision 2026-10-29 and its security review): CSS whitespace, an optional
|
||||
/// quote, `#`, an id in the reference grammar, the same quote, CSS whitespace, `)`. Anything a
|
||||
/// browser could read differently (`%61`, a tab or a space inside the quotes, an empty or
|
||||
/// non-ASCII id, an unbalanced quote) is not local. Answers the id's byte range in `value`.
|
||||
fn local_url_target(value: &str, at: usize) -> Option<(usize, usize)> {
|
||||
let bytes = value.as_bytes();
|
||||
let mut index = skip_css_spaces(bytes, at);
|
||||
let quote = bytes
|
||||
.get(index)
|
||||
.copied()
|
||||
.filter(|b| matches!(b, b'\'' | b'"'));
|
||||
index += usize::from(quote.is_some());
|
||||
if bytes.get(index) != Some(&b'#') {
|
||||
return None;
|
||||
}
|
||||
skip_space(&mut chars);
|
||||
at + chars.peek().map_or(rest.len(), |&(i, _)| i)
|
||||
let id_start = index + 1;
|
||||
let id_len = value[id_start..]
|
||||
.bytes()
|
||||
.take_while(|b| b.is_ascii_alphanumeric() || matches!(b, b'_' | b'.' | b':' | b'-'))
|
||||
.count();
|
||||
let id_end = id_start + id_len;
|
||||
if !is_reference_name(&value[id_start..id_end]) {
|
||||
return None;
|
||||
}
|
||||
index = id_end;
|
||||
if let Some(quote) = quote {
|
||||
if bytes.get(index) != Some("e) {
|
||||
return None;
|
||||
}
|
||||
index += 1;
|
||||
}
|
||||
index = skip_css_spaces(bytes, index);
|
||||
(bytes.get(index) == Some(&b')')).then_some((id_start, id_end))
|
||||
}
|
||||
|
||||
/// The ids of the value's `url(#id)` references, in order.
|
||||
/// The ids of the value's local `url(#id)` references, in order.
|
||||
pub fn url_targets(value: &str) -> Vec<String> {
|
||||
url_openings(value)
|
||||
.filter_map(|at| value[skip_url_prefix(value, at)..].strip_prefix('#'))
|
||||
.map(|rest| {
|
||||
rest.chars()
|
||||
.take_while(|c| c.is_ascii_alphanumeric() || matches!(c, '_' | '.' | ':' | '-'))
|
||||
.collect::<String>()
|
||||
})
|
||||
.filter(|id| !id.is_empty())
|
||||
.filter_map(|at| local_url_target(value, at))
|
||||
.map(|(start, end)| value[start..end].to_owned())
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The value with `scope` written after the `#` of each `url(#id)` that `url_targets` reads
|
||||
/// (a non-empty id), everything else kept byte for byte.
|
||||
/// The value with `scope` written in front of the id of each local `url(#id)` that
|
||||
/// `url_targets` reads, everything else kept byte for byte.
|
||||
pub fn scope_url_targets(value: &str, scope: &str) -> String {
|
||||
let mut out = String::with_capacity(value.len());
|
||||
let mut kept_from = 0;
|
||||
for at in url_openings(value) {
|
||||
let next = skip_url_prefix(value, at);
|
||||
let named = value[next..].strip_prefix('#').is_some_and(|rest| {
|
||||
rest.starts_with(|c: char| {
|
||||
c.is_ascii_alphanumeric() || matches!(c, '_' | '.' | ':' | '-')
|
||||
})
|
||||
});
|
||||
if named {
|
||||
out.push_str(&value[kept_from..=next]);
|
||||
out.push_str(scope);
|
||||
kept_from = next + 1;
|
||||
}
|
||||
for (start, _) in url_openings(value).filter_map(|at| local_url_target(value, at)) {
|
||||
out.push_str(&value[kept_from..start]);
|
||||
out.push_str(scope);
|
||||
kept_from = start;
|
||||
}
|
||||
out.push_str(&value[kept_from..]);
|
||||
out
|
||||
}
|
||||
|
||||
/// Every `url(` in the value points inside the document (`url(#…)`).
|
||||
fn urls_are_local(value: &str) -> bool {
|
||||
url_openings(value).all(|at| value[skip_url_prefix(value, at)..].starts_with('#'))
|
||||
/// Every `url(` in the value is a local reference (`local_url_target`).
|
||||
pub fn urls_are_local(value: &str) -> bool {
|
||||
url_openings(value).all(|at| local_url_target(value, at).is_some())
|
||||
}
|
||||
|
||||
/// No `(` once the `url(#` openings and the strict colour functions are taken out.
|
||||
@@ -529,10 +547,12 @@ fn calls_only_local_url(value: &str) -> bool {
|
||||
let mut cut = String::with_capacity(value.len());
|
||||
let mut kept_from = 0;
|
||||
for at in url_openings(value) {
|
||||
let next = skip_url_prefix(value, at);
|
||||
if value[next..].starts_with('#') {
|
||||
if let Some((_, id_end)) = local_url_target(value, at) {
|
||||
cut.push_str(&value[kept_from..at - 4]);
|
||||
kept_from = next + 1;
|
||||
cut.push(' ');
|
||||
kept_from = value[id_end..]
|
||||
.find(')')
|
||||
.map_or(value.len(), |i| id_end + i + 1);
|
||||
}
|
||||
}
|
||||
cut.push_str(&value[kept_from..]);
|
||||
@@ -569,7 +589,7 @@ fn colour_function_end(text: &str, at: usize) -> Option<usize> {
|
||||
let glued = text[..at]
|
||||
.chars()
|
||||
.next_back()
|
||||
.is_some_and(|c| c.is_ascii_alphanumeric() || matches!(c, '_' | '-' | '\\'));
|
||||
.is_some_and(continues_identifier);
|
||||
let rest = &text[at..];
|
||||
let (components, open) = match () {
|
||||
_ if glued => return None,
|
||||
@@ -600,7 +620,10 @@ fn colour_function_end(text: &str, at: usize) -> Option<usize> {
|
||||
}
|
||||
index += 1;
|
||||
}
|
||||
Some(at + index)
|
||||
// The function is a whole value of a list or a declaration, never glued to what follows.
|
||||
let after = bytes.get(index).copied();
|
||||
let ends = after.is_none_or(|b| is_css_space(char::from(b)) || matches!(b, b';' | b',' | b'!'));
|
||||
ends.then_some(at + index)
|
||||
}
|
||||
|
||||
fn skip_css_spaces(bytes: &[u8], mut index: usize) -> usize {
|
||||
|
||||
@@ -477,6 +477,7 @@ fn canvas_of<'a>(
|
||||
let canvas = compose_canvas(document, view_id, drawing).map_err(|e| match e {
|
||||
ComposeError::UnknownView => Failure::new("unknown_view", view_id),
|
||||
ComposeError::InvalidCharacter => Failure::new("invalid_character", view_id),
|
||||
ComposeError::UnscopedReference => Failure::new("svg_rejected", "unscoped_reference"),
|
||||
})?;
|
||||
let svg = serialize(&canvas);
|
||||
if svg.len() > MAX_COMPOSED_BYTES {
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ None is edited by hand.
|
||||
|
||||
| File | Tool | How | Expected |
|
||||
|---|---|---|---|
|
||||
| `cairo-1.18.4-pycairo-1.27.0-shapes.svg` | cairo 1.18.4 through pycairo 1.27.0 | `generate.sh`: curves, gradient, dash, clip, alpha, text as glyph paths | read with no removal: its colours are written `rgb(20%, 40%, 70%)`, the strict numeric colour function the reader keeps since the owner's decision of 2026-10-29 (before it, the four colours were removed) |
|
||||
| `cairo-1.18.4-pycairo-1.27.0-shapes.svg` | cairo 1.18.4 through pycairo 1.27.0 | `generate.sh`: curves, gradient, dash, clip, alpha, text as glyph paths | read with no removal: its colours are written `rgb(20%, 40%, 70%)`, the strict numeric colour function the reader keeps since the owner's decision of 2026-10-29 (before it, the five colours were removed) |
|
||||
| `cairo-1.18.4-pycairo-1.27.0-raster.svg` | same | `generate.sh`: an 8 × 8 image surface painted | refused, `svg_active_content` (an embedded raster `<image>`) |
|
||||
| `inkscape-1.4.3-inkscape-svg.svg` | Inkscape 1.4.3 (0d15f75042, 2025-12-25) | `generate-inkscape.sh`: `inkscape-source.svg` opened and exported as Inkscape SVG (`--export-type=svg`) | cleanable: `sodipodi:namedview`, the editor namespaces, `sodipodi:docname`, `xmlns:svg` and the `text` element removed and named; shapes, gradient, clip path, references and colours kept |
|
||||
| `inkscape-1.4.3-plain-svg.svg` | same | `generate-inkscape.sh`: Plain SVG (`--export-plain-svg`) | cleanable: `xmlns:svg` and `text` removed |
|
||||
|
||||
@@ -1 +1,47 @@
|
||||
Owner-supplied editor exports land here (see ../README.md).
|
||||
|
||||
# What to export (A6, contract §9.2 and §15)
|
||||
|
||||
One small drawing per tool, made in that tool, never retouched by hand afterwards. Same
|
||||
reference content as `../inkscape-source.svg`, so the results compare:
|
||||
|
||||
- an outline with a curve, filled with a two-stop linear gradient, a 2 px dashed stroke;
|
||||
- an ellipse with a flat colour;
|
||||
- a rounded rectangle at 50 % opacity;
|
||||
- the whole group clipped by a rectangle (Illustrator: clipping mask; Figma: a frame with
|
||||
« Clip content »);
|
||||
- the word « Garrot » as live text.
|
||||
|
||||
Artboard or frame 200 × 150 px. Note the exact version (Illustrator: Aide › À propos
|
||||
d'Illustrator; Figma: menu › Aide › À propos de Figma, or the desktop app's version).
|
||||
|
||||
## Illustrator
|
||||
|
||||
1. Fichier › Exporter › Exporter sous… › format SVG (`svg`), « Utiliser les plans de travail »
|
||||
ticked.
|
||||
2. Options SVG, two files:
|
||||
- `illustrator-<version>-export-as.svg`: Style « Attributs de présentation », Police
|
||||
« Vectoriser », Images « Incorporer », ID d'objet « Noms de calques », Décimales 2, Minifier
|
||||
off, Responsive on;
|
||||
- `illustrator-<version>-internal-css.svg`: the same with Style « CSS interne » (the export
|
||||
most users keep by default; expected cleanable, its `<style>` named as removed).
|
||||
3. If a third is easy: Fichier › Enregistrer sous… › SVG (`illustrator-<version>-save-as.svg`),
|
||||
the older dialog, default settings.
|
||||
|
||||
## Figma
|
||||
|
||||
1. Select the frame, right panel › Exporter › « + » › format SVG.
|
||||
2. Options, two files:
|
||||
- `figma-<version>-export.svg`: defaults (« Contours du texte » ticked, « Inclure
|
||||
l'attribut id » unticked);
|
||||
- `figma-<version>-ids.svg`: « Inclure l'attribut id » ticked (the layer names become ids).
|
||||
3. Exporter.
|
||||
|
||||
## Then
|
||||
|
||||
Copy the files here, unchanged, and tell Claude. The suite
|
||||
`cargo test -p faunosteo-core --test svg_clean the_owner_editor_exports` reads every `.svg` in
|
||||
this folder: each must be refused with a closed reason or cleaned into a stored form that reads
|
||||
back with no removal. A file whose name contains `-active-` must be refused for active content
|
||||
(useful if you want to try an export with a linked image or an animation). Nothing is uploaded
|
||||
anywhere: these are test fixtures, committed with the tool and version in their names.
|
||||
@@ -337,6 +337,78 @@ fn the_vector_tool_exports_are_read_or_refused_for_their_raster() {
|
||||
assert_eq!(raster.active, ["image"]);
|
||||
}
|
||||
|
||||
/// Security review of the arbitrations (2026-10-29): a `url(` is kept only when its target is
|
||||
/// `#` and an id in the reference grammar, an optional matching quote and `)`; every spelling
|
||||
/// a browser would normalise or read otherwise is active content, so the dangling check, the
|
||||
/// per-view scoping and the expansion budget cannot be walked around. Names glued to `url(` or
|
||||
/// `rgb(` are other functions, removed.
|
||||
#[test]
|
||||
fn every_url_spelling_but_the_strict_one_is_refused() {
|
||||
let svg = |value: &str| {
|
||||
format!(
|
||||
"<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 10 10\">\
|
||||
<linearGradient id=\"a\"/><path d=\"M0 0\" fill=\"{value}\"/></svg>"
|
||||
)
|
||||
};
|
||||
for value in [
|
||||
"url(#%61)",
|
||||
"url(#%66v.main.a)",
|
||||
"url(\'#\ta\')",
|
||||
"url(\'#a\tb\')",
|
||||
"url(#)",
|
||||
"url(# a)",
|
||||
"url(\'#a)",
|
||||
"url("#a\')",
|
||||
"url(#é)",
|
||||
"url(#1a)",
|
||||
"url(#a b)",
|
||||
"url(#a rgb(1,2,3))",
|
||||
"url(#/a)",
|
||||
"url(#a",
|
||||
] {
|
||||
let cleaning = clean_svg(svg(value).as_bytes());
|
||||
assert_eq!(
|
||||
outcome(&cleaning),
|
||||
(Rejected, Some("svg_active_content")),
|
||||
"{value}"
|
||||
);
|
||||
assert_eq!(cleaning.active, ["path@fill"], "{value}");
|
||||
}
|
||||
for value in [
|
||||
"url(#a)",
|
||||
"URL( \'#a\' )",
|
||||
"url("#a")",
|
||||
"url(\n#a)",
|
||||
] {
|
||||
assert_eq!(
|
||||
outcome(&clean_svg(svg(value).as_bytes())),
|
||||
(Clean, None),
|
||||
"{value}"
|
||||
);
|
||||
}
|
||||
for value in [
|
||||
"érgb(1,2,3)",
|
||||
"rgurl(#a(1,2,3)",
|
||||
"xurl(#a)",
|
||||
"rgb(1,2,3)rgb(4,5,6)",
|
||||
"rgb(1,2,3)x",
|
||||
] {
|
||||
let cleaning = clean_svg(svg(value).as_bytes());
|
||||
assert_eq!(outcome(&cleaning), (Cleanable, None), "{value}");
|
||||
assert_eq!(cleaning.removed, ["path@fill"], "{value}");
|
||||
}
|
||||
// The expansion budget holds whatever the spelling: 250 000 references written `%61` are
|
||||
// refused as active content, as the plain spelling is refused as too complex.
|
||||
let flood = format!(
|
||||
"<svg xmlns=\"http://www.w3.org/2000/svg\"><linearGradient id=\"a\"/><path d=\"M0 0\" fill=\"{}\"/></svg>",
|
||||
"url(#%61) ".repeat(25_000)
|
||||
);
|
||||
assert_eq!(
|
||||
outcome(&clean_svg(flood.as_bytes())).1,
|
||||
Some("svg_active_content")
|
||||
);
|
||||
}
|
||||
|
||||
/// Real Inkscape 1.4.3 exports (owner go 2026-10-29; `exports/generate-inkscape.sh`): its
|
||||
/// editor metadata and namespaces and the `text` it keeps as text are removed and named, so
|
||||
/// each is cleanable; shapes, gradient, clip path, internal references and colours stay; the
|
||||
|
||||
@@ -274,3 +274,71 @@ fn composition_is_deterministic_and_repeatable() {
|
||||
);
|
||||
assert_eq!(preview.drawing_reads(), 2);
|
||||
}
|
||||
|
||||
/// Every reference of `text` as a browser reads it, written apart from the core's reader:
|
||||
/// each `href="…"` and each `url(…)` (any case), quotes and CSS whitespace trimmed, tab and
|
||||
/// newline removed and `%XX` decoded as the URL parser does. Answers the fragment ids.
|
||||
fn browser_references(text: &str) -> Vec<String> {
|
||||
let normalise = |raw: &str| {
|
||||
let trimmed = raw.trim_matches(|c: char| c.is_ascii_whitespace() || c == '\'' || c == '"');
|
||||
let cleaned: String = trimmed
|
||||
.chars()
|
||||
.filter(|c| !matches!(c, '\t' | '\n' | '\r'))
|
||||
.collect();
|
||||
let mut bytes = Vec::new();
|
||||
let raw = cleaned.as_bytes();
|
||||
let mut i = 0;
|
||||
while i < raw.len() {
|
||||
let hex = raw
|
||||
.get(i + 1..i + 3)
|
||||
.and_then(|h| std::str::from_utf8(h).ok());
|
||||
match (raw[i], hex.and_then(|h| u8::from_str_radix(h, 16).ok())) {
|
||||
(b'%', Some(byte)) => {
|
||||
bytes.push(byte);
|
||||
i += 3;
|
||||
}
|
||||
(byte, _) => {
|
||||
bytes.push(byte);
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
String::from_utf8_lossy(&bytes).into_owned()
|
||||
};
|
||||
let mut out = Vec::new();
|
||||
for (index, _) in text.match_indices("href=\"") {
|
||||
let rest = &text[index + 6..];
|
||||
out.push(normalise(&rest[..rest.find('"').unwrap()]));
|
||||
}
|
||||
let lower = text.to_ascii_lowercase();
|
||||
for (index, _) in lower.match_indices("url(") {
|
||||
let rest = &text[index + 4..];
|
||||
out.push(normalise(&rest[..rest.find(')').unwrap_or(rest.len())]));
|
||||
}
|
||||
out.into_iter()
|
||||
.map(|reference| reference.strip_prefix('#').unwrap_or(&reference).to_owned())
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_reference_a_browser_reads_stays_in_its_view() {
|
||||
let preview = preview(&detail_drawing());
|
||||
for view in ["main", "detail"] {
|
||||
let text = canvas(&preview, view);
|
||||
let references = browser_references(&text);
|
||||
assert!(references.len() >= 2, "{view}");
|
||||
for reference in references {
|
||||
assert!(
|
||||
reference.starts_with(&format!("fv.{view}.")),
|
||||
"{view}: {reference}"
|
||||
);
|
||||
}
|
||||
}
|
||||
// The hostile spellings never reach a canvas: the drawing is refused, nothing composed.
|
||||
for value in ["url(#%66v.main.g)", "url(\'#\tg\')", "url(#%67)"] {
|
||||
let hostile =
|
||||
format!("{OPEN}<radialGradient id=\"g\"/><path fill=\"{value}\" d=\"M0 0\"/></svg>");
|
||||
let refused = canvas_outcome(&self::preview(&hostile), "detail");
|
||||
assert_eq!(refused["kind"], json!("svg_rejected"), "{value}");
|
||||
}
|
||||
}
|
||||
@@ -78,8 +78,10 @@ whole document. Since V1-2.2 (owner decision 2026-10-29) the core writes
|
||||
`fv.<view id>.` in front of every `id` of the drawing and of every local
|
||||
reference to it (`href`, `xlink:href`, `url(#…)`), so each view resolves its
|
||||
gradients, clip paths and `<use>` targets in its own drawing only, never in
|
||||
another view's or in the page; a drawing whose reference names an id it does
|
||||
not define is refused by the reader (`dangling_reference`). The annotation
|
||||
another view's or in the page, and the composer refuses a canvas that would
|
||||
keep a reference outside its scope; a drawing whose reference names an id it
|
||||
does not define, or spells a `url(` any other way than `url(#id)` with optional
|
||||
quotes and spaces, is refused by the reader. The annotation
|
||||
layer carries no `id`. The PDF view keeps the drawing's ids: it is rasterised
|
||||
as a document of its own. The R3 canvas goldens stay frozen; the tests apply
|
||||
this declared change to them (`withIdsScopedPerView`,
|
||||
|
||||
+30
-10
@@ -3865,7 +3865,8 @@ marking is written `inherited`): `general` is the document without `views`, `ann
|
||||
**Verdict codes,** first one recorded as the round's `failure_code`: `verification.integrity.document`, `.base`,
|
||||
`verification.validation.rules`, `.no_geometry`, `.caps`, `verification.integrity.drawing_missing`, `.size_mismatch`,
|
||||
`.object_conflict` (bytes not hashing to the row, which is the object key), `.svg_rejected`, `.svg_removal`,
|
||||
`.fingerprint`. Drawing results: `ok`, `missing`, `size_mismatch`, `hash_mismatch`, `svg_rejected`, `svg_removal`.
|
||||
`.svg_not_canonical` (§12.7), `.fingerprint`. Drawing results: `ok`, `missing`, `size_mismatch`, `hash_mismatch`,
|
||||
`svg_rejected`, `svg_removal`, `svg_not_canonical`.
|
||||
|
||||
### 12.2 Facade
|
||||
|
||||
@@ -3915,27 +3916,28 @@ trapping test stub (`apps/app/tests/helpers/core.ts`) lists the two new glue mem
|
||||
and local to their group, an omitted marking digesting as `inherited`, coverage, a derived version deleting a zone
|
||||
with its removal group and change list, removal digests bound to their key, an inherited element alone keeping its
|
||||
group uncoverable, added / changed / status-changed / removed-plus-added, a reorder changing the digest only.
|
||||
- `sheet_verdict` (14): a clean sheet and the equine draft pass (fingerprint `12d78872…`, 30 groups, 184 105 bytes); the
|
||||
- `sheet_verdict` (15, the stored form included, §12.7): a clean sheet and the equine draft pass (fingerprint `12d78872…`, 30 groups, 184 105 bytes); the
|
||||
shape the SQL reads; each rule and drawing fault alone; caps at cap − 1 / cap / cap + 1 (annotations, labels in
|
||||
astral characters, depth, nodes, document bytes; views, drawings, drawing bytes and total bytes through
|
||||
`caps_report`); code order; determinism; base and removal groups; a
|
||||
document at every cap (64 views, 1 024 annotations, 8 192 nodes, depth 8) verified.
|
||||
- `sheet_preview` (9): the equine draft previews with the bundle's index tables and canvases and its fingerprint; hash
|
||||
- `sheet_preview` (11, the stored form included): the equine draft previews with the bundle's index tables and canvases and its fingerprint; hash
|
||||
mismatch refused in every mode; fingerprint, missing drawing and caps refused for published and deprecated, reported
|
||||
for drafts; an invalid draft draws with its issues; five replacements, one drawing read; read-only published; no
|
||||
report operation on a preview; at most 16 drawings of at most 2 MiB.
|
||||
- `sheet_edit` (11): each marking rule of §6.6, the refusals, `dependents`, the facade, and 400 random commands on the
|
||||
- `sheet_edit` (12, removals refused while named, §12.7): each marking rule of §6.6, the refusals, `dependents`, the facade, and 400 random commands on the
|
||||
small sheet and on the equine draft, view crops and drawings, references, zones included (strict re-read;
|
||||
on the marked elements, annotations, categories and nodes: every key kept by every command but `remove`, which
|
||||
takes only its key and descendants, the rule of insert, update, move, set_status and `mark_reviewed`; nothing
|
||||
turned `inherited`). The keys of views, references, regions and annotation categories and the redraw rule are held
|
||||
by the case tests, not by the property test.
|
||||
- `svg_clean` (10): the 42 hostile files, each on the §9.2 line it belongs to; the security audit's 13 probes
|
||||
- `svg_clean` (14 since §12.7): the 42 hostile files, each on the §9.2 line it belongs to; the security audit's 13 probes
|
||||
(stylesheet PIs, active content under a long title, HTML fetchers, XHTML elements) refused; a stored PI refused by the
|
||||
verdict; active names; a plain `<style>` cleaned and
|
||||
named, four hostile ones refused; the product drawing clean with its sha256; the four committed exports; the owner's
|
||||
folder (empty so far); the fixpoint on the corpus and on 3 000 generated drawings (123 clean, 2 697 cleanable, 180
|
||||
reference cycles refused).
|
||||
named, four hostile ones refused; the product drawing clean with its sha256; the committed exports (four, three
|
||||
Inkscape ones since §12.7); the owner's folder (empty so far); the fixpoint on the corpus and on 3 000 generated
|
||||
drawings (138 clean, 2 434 cleanable, 428 refused: 256 dangling references, 172 reference cycles; before §12.7:
|
||||
123 / 2 697 / 180 cycles).
|
||||
- Mutation run (10 mutants, each against its suite; `.claude/audits/2026-10-29-v1-2-2-mutations.py`): caps off by one, digest without its key, no active class, hash
|
||||
unchecked, an update keeping `reviewed`, fingerprint unchecked, `inherited` counted as read, redrawn views ignored,
|
||||
numeric scale ignored, removal groups never made: 10 killed (the `inherited` one survived the first run; the test
|
||||
@@ -3948,7 +3950,7 @@ trapping test stub (`apps/app/tests/helpers/core.ts`) lists the two new glue mem
|
||||
|
||||
| Measure | Value |
|
||||
|---|---|
|
||||
| shipped module | 1 785 447 B raw, 587 470 B gzip -9 (script), 596 671 B by Node's gzip in `size.test.ts` (final, ca31b78); budget 600 000 (D-R13); 531 715 B before V1-2.2 (RUST.md §11.22) |
|
||||
| shipped module | 1 511 410 B raw, 558 651 B gzip -9 (script), 568 416 B by Node's gzip in `size.test.ts` (final, after §12.7: the debug `name` section dropped); budget 600 000 (D-R13); 596 671 B at ca31b78, 531 715 B before V1-2.2 (RUST.md §11.22) |
|
||||
| verdict at every cap, native | 107 ms release, 493 ms debug (document 1 165 850 bytes) |
|
||||
| `clean_svg`, shipped module | 45 hostile inputs and floods, slowest 0.4 ms |
|
||||
|
||||
@@ -3967,7 +3969,7 @@ with a PI shown `rejected` by the preview as the verdict refuses it.
|
||||
|
||||
### 12.6 Residual risks and points for V1-2.3
|
||||
|
||||
- The module's margin under its budget is about 3.3 KB by the test's measure: the V1-2.5 and V1-2.6 pages must not grow the
|
||||
- The module's margin under its budget is about 31.6 KB by the test's measure since §12.7 (3.3 KB before): the V1-2.5 and V1-2.6 pages must not grow the
|
||||
core's browser surface without measuring.
|
||||
- cairo colours: closed at the checkpoint (§12.7), strict numeric `rgb()` / `rgba()` kept.
|
||||
- Editor exports: Inkscape 1.4.3 covered at the checkpoint (§12.7); Illustrator, Figma and Affinity pending from the
|
||||
@@ -4017,6 +4019,24 @@ Inkscape: not installed and inkscape.org unreachable that day (504, then a timeo
|
||||
`apt-get download`, unpacked with `dpkg-deb -x` into the session scratch folder and run from there (no install, no sudo).
|
||||
`crates/core/tests/fixtures/svg/exports/generate-inkscape.sh` writes the three exports from `inkscape-source.svg`.
|
||||
|
||||
Security review of this round (fresh, 2026-10-29, BLOCK(1) HIGH, fixed in the same step): the sanitiser kept `url(#`
|
||||
followed by any character, while the dangling check and the scoping read an id only from an id character, so
|
||||
`url(#%61)` (and, in Chromium, `url('#<TAB>a')`) passed both and resolved in browsers, which percent-decode the fragment;
|
||||
the expansion budget was walked around the same way (pre-existing since R3). Now `sanitize::local_url_target` is the one
|
||||
reading of a `url(`: CSS whitespace, an optional quote, `#`, an id in the reference grammar, the same quote, CSS
|
||||
whitespace, `)`; any other spelling is active content and refuses the file. A `url(` or `rgb(` glued to a longer name
|
||||
(`xurl(`, `érgb(`, a non-ASCII letter included) is another function; a colour must end its value or list item. The
|
||||
composer checks, fail-closed, that every reference of a canvas carries its view's scope (`unscoped_reference`). Tests
|
||||
written apart from the reader: 14 refused spellings, 5 removed glued names, a 25 000-reference flood in `%61`, and a
|
||||
browser model (percent-decoding, tab and newline stripping) over composed canvases (`svg_scope`). The R3 sanitiser
|
||||
oracles needed no new declared change.
|
||||
|
||||
Residual (MEDIUM, security review): the scope is the view id, unique in one document only. A page that inlines canvases
|
||||
of two documents at once (two versions side by side, two sheets) would share `fv.main.` and resolve in the first one in
|
||||
tree order; such a page (V1-2.7 or later; the side-by-side diff is level 2, contract §8.3) must add a per-document
|
||||
prefix before it ships. The detail modal of the report editor draws another view of the same document, so its scope
|
||||
differs.
|
||||
|
||||
Size (V1-2.2 final, by Node's gzip in `size.test.ts`): see §12.5. Contributors measured on a build keeping the name
|
||||
section: code 1 283 513 B in 1 808 functions (gzip ≈ 462 KB) and data 219 920 B (gzip ≈ 90 KB); by crate, raw code:
|
||||
`faunosteo_core` 46 % (`domain::sheet` 204 KB, of which `schema` 68 KB and `edit` 42 KB; `pdf::write` 91 KB;
|
||||
|
||||
@@ -1220,6 +1220,9 @@ supplied; they are not invented.
|
||||
deletion is offered in level 1. An `insert` or `update` that names an
|
||||
element absent from the document stays allowed (left to the validation
|
||||
panel), as does a document saved with gaps: the verdict refuses them.
|
||||
Structural rules that name nothing (`view.unreachable` after the last link
|
||||
to a view goes, `view.main.count` after the main view goes) are left to
|
||||
the validation panel too.
|
||||
- Ids are generated by the page (`<prefix>-<10 lowercase base32
|
||||
characters>`, alphabet `a-z2-7`, inside the stable-id rule), passed to the
|
||||
core, never derived from labels, never editable, never reused.
|
||||
@@ -1363,7 +1366,12 @@ The page reads the file with the core SVG reader before anything is stored.
|
||||
so a new form is a new sha256, a new row and a new object.
|
||||
- Local references (owner decision 2026-10-29): every `href="#id"`,
|
||||
`xlink:href="#id"` and `url(#id)` must name an id the drawing itself
|
||||
defines; a reference to an absent id is a hard rejection
|
||||
defines, and a `url(` is a local reference only in its strict spelling
|
||||
(CSS whitespace, an optional quote, `#`, an id in the reference grammar,
|
||||
the same quote, CSS whitespace, `)`): `url(#%61)`, a tab, a space or an
|
||||
unbalanced quote inside, an empty or non-ASCII id are active content and
|
||||
refuse the file, since a browser normalises them (security review of the
|
||||
checkpoint); a reference to an absent id is a hard rejection
|
||||
(`dangling_reference`) for the reader of stored drawings, the cleaning
|
||||
(after active content is classified, so a hostile file is still named as
|
||||
such), the verdict and the preview. Valid internal references keep working.
|
||||
@@ -1371,7 +1379,8 @@ The page reads the file with the core SVG reader before anything is stored.
|
||||
keep the strict colour functions cairo writes, lowercase `rgb(` with three
|
||||
and `rgba(` with four components, all bare numbers up to 255 or all
|
||||
percentages up to 100, an alpha up to 1 or 100 %, commas, CSS whitespace,
|
||||
nothing glued before the name. Every other function (`url(` outside the
|
||||
nothing glued before the name (a non-ASCII letter included) and nothing
|
||||
after the `)` but the end, a space, `;`, `,` or `!`. Every other function (`url(` outside the
|
||||
document, `expression(`, `var(`, `hsl(`, an escaped name, an uppercase
|
||||
name…) is removed or refused as before; scripts and active CSS stay
|
||||
refused.
|
||||
@@ -1477,7 +1486,11 @@ A drawing never blocks authoring: only the round waits for its verdict.
|
||||
transformation runs at composition only: stored bytes, their sha256, the
|
||||
published versions, the archive snapshot and the PDF views (each rasterised
|
||||
as a document of its own) keep the drawing's ids. Composition is
|
||||
deterministic and applied once per call. A drawing outside the stored form
|
||||
deterministic and applied once per call; the composer refuses a canvas
|
||||
that would keep a reference outside its scope (`unscoped_reference`).
|
||||
The scope is unique within one document only: a page that inlines
|
||||
canvases of two documents at once (two versions or two sheets side by
|
||||
side) adds a per-document prefix first. A drawing outside the stored form
|
||||
(§9.2) shows `rejected` with `not_canonical` and draws nothing, as the
|
||||
verdict refuses it.
|
||||
- `LoadedSheet` (the report editor's sheet) keeps its mandatory migration map;
|
||||
|
||||
Reference in new issue
Block a user