fix(anatomy): R5.4 drawings projection charges each drawing's fixed parts
This commit is contained in:
1 parent
411e1058c0
commit
c4e717da86
5 files changed
+193
-8
No files matched your search
@@ -0,0 +1,153 @@
|
||||
# Security gate R5.4 (round 11): review files in Rust
|
||||
|
||||
Mode: audit (delta). Repository `/home/bchanot/Documents/faunosteo`, branch
|
||||
`feature/rust-r5-pipeline-core`, HEAD `411e105`. Scope:
|
||||
`git diff c6e0d85..HEAD -- crates/core packages/anatomy/tests docs/development/RUST.md`
|
||||
(29 files, 21 commits). Blind run: no prior verdict or finding list consulted.
|
||||
|
||||
```
|
||||
SECURITY — VERDICT: PASS
|
||||
TOOL: semgrep 1.168.0 — p/security-audit, p/secrets, p/owasp-top-ten
|
||||
SCOPE: 29 files
|
||||
BLOCKING:
|
||||
(none)
|
||||
REPORTED (non-blocking):
|
||||
- [LOW] anti-gaming/new-lint-allow — crates/core/tests/curation_markdown.rs:6, crates/core/tests/curation_review.rs:6
|
||||
- [LOW] report-guard/bare-url-autolink — crates/core/src/curation/report_guard.rs:119
|
||||
PROOF: semgrep 128 rules on 29 files → 0 findings; checklist 14 checks → 2 findings
|
||||
```
|
||||
|
||||
## Semgrep
|
||||
|
||||
`semgrep scan --config p/security-audit --config p/secrets --config p/owasp-top-ten
|
||||
--metrics=off --quiet --json <29 files>`: 0 results, 0 errors, 29 targets scanned, 128 rules
|
||||
run (most of the 725 loaded rules do not apply to Rust). Ruleset content is fetched at run
|
||||
time, so the rule count can change on unchanged code.
|
||||
|
||||
## Checklist (14 checks)
|
||||
|
||||
| # | Check | Result |
|
||||
|---|---|---|
|
||||
| 1 | Hardcoded secret, token, key, auth-bearing URL (added lines and the two oracle JSON files) | 0 |
|
||||
| 2 | SQL built by concatenation | 0 (no SQL in the diff; `seed.rs` untouched) |
|
||||
| 3 | Unsanitized render, `eval`, process spawn | 0 |
|
||||
| 4 | Sensitive endpoint without authz | n/a (no endpoint, offline CLI and library) |
|
||||
| 5 | Stack trace or internal path to an end user | 0 (the CLI prints paths to the local operator only) |
|
||||
| 6 | Secret or PII in a log | 0 |
|
||||
| 7 | Tracked `.env` or credential file | 0 (only `.env.example`, outside the diff) |
|
||||
| 8 | Guardrails scanner (`--domain api,supabase`) | 0 FAIL, 1 WARN (`SB-POLICY-NOT-OWNER`, `supabase/migrations/20261008110000_anatomical_sheets.sql:1177`), outside the diff, filtered |
|
||||
| 9 | New suppressions (anti-gaming) | 2 new lint allows in test files: LOW, see L1 |
|
||||
| 10 | Markdown structure forging (sections, list items, code spans, links, HTML) | 0 forging path; one LOW note, see L2 |
|
||||
| 11 | Silent difference from Prettier 3.8.3 on admitted text (differential probe) | 0 |
|
||||
| 12 | Non-well-formed review SVG | 0 |
|
||||
| 13 | Resource bounds (records, tables, drawings, quadratic scans) | 0 new |
|
||||
| 14 | CLI file-system confinement (`--check`, `--out`) | 0 |
|
||||
|
||||
### 10. Report structure forging
|
||||
|
||||
Every authored channel that reaches CHANGELOG.md or REVIEW-REPORT.md was traced:
|
||||
|
||||
- Line breaks: list-item fields (title, rationale, question, citation, URL, DOI, vet-flag
|
||||
values) refuse any control character (`review_report.rs:364`). Table cells turn `\n` into a
|
||||
space (`markdown.rs:47`), and the guard refuses `\r` and `\t` (`report_guard.rs:198`).
|
||||
No authored text starts a line: every template line begins with generated text (`- `,
|
||||
`N. `, `| `). Line-start constructs (headings, setext underlines, link reference
|
||||
definitions, footnote definitions, blockquotes, tables) are therefore out of reach.
|
||||
- Code spans: authored texts refuse backticks (`assert_authored`). Ids are validated at the op
|
||||
(`ops.rs` `assert_stable_id` on add, nested children and rename). Change ids match
|
||||
`^CHG-\d{3,}$`. Change reference ids must be declared references (`assert_declared`), whose ids
|
||||
are stable ids. Field segments are limited to `[A-Za-z0-9_-]` (`fields.rs`) and ids are not
|
||||
settable. Targets resolve to existing items. The code-span alphabet check
|
||||
(`[A-Za-z0-9_:/. -]`) and the per-line backtick parity hold as a second layer.
|
||||
- Inline constructs: links, images, references, HTML tags, autolinks `<…>`, character
|
||||
references, liquid and padded wiki brackets are refused. Cross-field pairs were checked:
|
||||
`**` opened in the title and closed in the rationale is refused by `outside_strong`, and `](`
|
||||
across fields is refused by `rewritten_construct`.
|
||||
- Invisible or bidi characters (U+202E, U+200B, NBSP) are neither alphanumeric nor in
|
||||
`PUNCTUATION`: refused.
|
||||
|
||||
### 11. Differential probe against Prettier 3.8.3
|
||||
|
||||
Probe: `/tmp/claude-1000/-home-bchanot-Documents-faunosteo/9b0edf59-ccd2-4662-b90c-e473dd78028e/scratchpad/diff.mjs`
|
||||
and `.../diff2.mjs`. A Rust binary calls `report_guard::format_report`, and the repository's
|
||||
`prettier@3.8.3` runs on the same raw report with the `format.ts` options. Random authored
|
||||
texts (letters, accents, CJK, every admitted punctuation sign, `_`, `\`, `*`, `**word**`, URL
|
||||
starts, `&name=`, `&`, `&#`, brackets, list and heading markers) are placed in four
|
||||
templates: a list-item title and rationale, a table row (cell escape as `cell()` does), a
|
||||
bibliography citation and URL, and a trailing question. Eight seeds produced 146,000 cases.
|
||||
44,330 were admitted by the guard and 0 differed from Prettier byte for byte.
|
||||
|
||||
### 12. Review SVG well-formedness
|
||||
|
||||
Drawings are built as trees and printed by `anatomy::svg::serialize`. Attributes escape
|
||||
`& < > "` and `\t \n \r`, and text escapes `& < >`. `drawing::first_unwritable` refuses any
|
||||
code point outside the XML 1.0 `Char` production, and any carriage return, in every attribute
|
||||
and text node before writing. Element and attribute names are fixed. Colours come from the
|
||||
strict document (`#rrggbb`), and no `href`, `on*` or `style` value is author-controlled.
|
||||
|
||||
### 13. Resource bounds
|
||||
|
||||
- Records: `records::charge` runs before the change and op are cloned. It is called from every
|
||||
`record` site (set, subtree set, add, remove, move, cite, rename links and citations, B/C
|
||||
marking). Each record's weight includes the change texts, the op, and the before and after
|
||||
values.
|
||||
- Tables: the three CHANGELOG level tables are summed in `assert_table_bound` from the cell
|
||||
bytes before `table()` joins them. Bytes are never fewer than the display width: the first
|
||||
width-2 code point is U+1100, which takes 3 bytes. Every other table is checked in `align`
|
||||
before padding.
|
||||
- Review drawings: per-annotation projection. A probe binary
|
||||
(`.../scratchpad/probe/src/bin/drawings.rs`) compared projected and written bytes on hostile
|
||||
documents built from the equine draft: 40 points with 6,000-character `&` names (ratio
|
||||
0.405), `"<&` names (0.262), 6,000-byte `&"<` paths (0.170), unnamed triggers of a long view
|
||||
name (0.120), equine (0.406). The projection stays above what is written. The projection loop
|
||||
itself (views × annotations) took 1.2 s on a 7,000-view, 6,000-annotation document, which
|
||||
the bound then refuses.
|
||||
- Guard and aligner scans are linear per line. `underscore_pairs_later` only rescans after
|
||||
authored plain parts, and generated separators hold no `_`. The `&` and `<` splits are
|
||||
segment-local.
|
||||
- Already declared and not re-reported: the 65× parse of `changes.json`, the per-op bound walk
|
||||
(§11.13), and the linear trigger lookup in `--check`.
|
||||
|
||||
### 14. CLI confinement (`crates/core/src/bin/import_equine.rs`)
|
||||
|
||||
Every read is canonicalized and must lie inside the canonical seed folder. Reads accept only
|
||||
regular files and are capped at 16 MiB. Output file names come from stable view ids, and
|
||||
`write_exclusive` accepts only `Normal` components and `create_new`. Exercised in the
|
||||
scratchpad (fresh folders only, nothing in the repository):
|
||||
|
||||
- `--out` into an absent folder wrote 18 files. `diff -r` against the seed matched except
|
||||
`review/app-main.svg`, the declared R3 difference.
|
||||
- A second run into the same folder was refused: `not empty, nothing written`.
|
||||
- A symbolic link was refused with and without a trailing `/`.
|
||||
- A path holding `..` was refused, and so was an empty path.
|
||||
|
||||
`--check` against the repository reported `legacy-import: 6 files, 0 differences` and
|
||||
`draft: 12 files, 0 differences` (one `declared:` line), with `git status` clean afterwards.
|
||||
The `--out` refusal of a destination inside the seed was verified by reading the code and the
|
||||
unit test. It was not run against the real seed.
|
||||
|
||||
Tests run: `cargo test -p faunosteo-core --features curation --release` on `curation_review`
|
||||
(11), `curation_markdown` (2), `curation_draft` (18), `curation_format` (7) and the
|
||||
`import-equine` binary tests (3): all green.
|
||||
|
||||
## Reported findings (non-blocking)
|
||||
|
||||
### L1. [LOW] New lint allows in two new test files
|
||||
|
||||
`crates/core/tests/curation_markdown.rs:6` and `crates/core/tests/curation_review.rs:6`
|
||||
both add `#![allow(clippy::disallowed_methods, clippy::unwrap_used, clippy::expect_used)]`.
|
||||
The lint allowed here is the core's no-I/O and no-clock rule, which `clippy.toml` documents
|
||||
as allowed locally in tests. The same line heads the ten existing integration test files.
|
||||
It is a test-harness convention and does not suppress a security scanner (no `nosemgrep`,
|
||||
`nosec` or eslint-security in the diff), so it does not block. Context only.
|
||||
|
||||
### L2. [LOW] Bare URLs in any authored field render as autolinks
|
||||
|
||||
`report_guard.rs` admits bare URLs (`url_tokens`, line 119; the `&name=` query rule) in every
|
||||
authored text, not only in the reference `url` and `doi` fields. In a GFM viewer (Gitea), a
|
||||
URL typed in a title, rationale or question becomes a clickable link. This does not forge or
|
||||
disguise anything: the visible text is the target, and the output is the TypeScript's byte
|
||||
for byte. The link cannot swallow generated text either, because every authored field is
|
||||
followed by a space, ` |`, a line end, or a trailing `,` or `)` that GFM excludes. Owner
|
||||
choice: keep it, or confine URLs to the bibliography fields if links in rationales are
|
||||
unwanted.
|
||||
@@ -76,6 +76,12 @@ Fresh verifier and security on the fixed commit: below.
|
||||
- Security (`.claude/audits/2026-10-23-rust-r5-review-security-10.md`): HIGH the drawings bound counted the cleaned drawing only: an unnamed trigger copies the opened view's names four times (485 KB changeset → 131 MB `app-main.svg`; 1.2 MB → abort at 3 GB). LOW tables bound per table (three level tables ≈97 MB together); LOW stale `report_guard.rs` header; LOW add/move position anchor not charged; LOW test allows.
|
||||
- Fixed: drawings projected as an upper bound per annotation (`pipeline::review_drawings_bytes`: 1,024 + 24 × (JSON text + longest view name) per annotation of the view, overlay's two documents and the app drawing; equine 1,390,428), test `unnamed_triggers_repeating_a_long_view_name_are_refused_before_rendering`; CHANGELOG tables bound summed over the three level tables (`assert_table_bound` with a running total), number cells 25; position anchor charged (equine records 1,966,163); `report_guard.rs` header; RUST.md counts (draft 4,600 lines, tests 11/2/18/5/3/7), ASCII letter wording, rows rewritten.
|
||||
|
||||
## Round 11
|
||||
## Round 11 on 411e105: verifier C1 to C8 MET, C9 NOT-MET (2 gaps) + 10 FLOOR (audit prose), security PASS (2 LOW); `pnpm check:all` green 16:02:45
|
||||
|
||||
- Verifier: own differential 64,000 changesets TS + Prettier vs Rust, 0 silent, 0 raw mismatch; bounds far below their limits on equine and synthetic oracles; adversarial projections held except one. C9: (a) draft line count 4,600 → 4,601; (b) `review_drawings_bytes` 477 bytes under what is written for a change removing every annotation (fixed parts of each drawing, layer group, overlay group and legend, never charged). Obs: test comment cites §11.12 for the emoji refusal (§11.10/§11.14).
|
||||
- Security (`.claude/audits/2026-10-23-rust-r5-review-security-11.md`): PASS. 146,000 random cases vs Prettier, 44,330 admitted, 0 differ; drawings wrote 0.12 to 0.41 of the projection on hostile documents. LOW test allows (convention); LOW bare URLs autolinked in any authored field (visible text = target, TypeScript alike: owner choice).
|
||||
- Fixed: 4,096 bytes per drawing for its fixed parts (`pipeline::DRAWING_FIXED_BYTES`; equine projection 1,406,812 for 564,239 written), test `the_drawings_projection_bounds_what_is_written` (equine and no annotations); RUST.md counts (4,606 lines, review 12 tests); test comment sections.
|
||||
|
||||
## Round 12
|
||||
|
||||
Fresh verifier and security on the fixed commit: below.
|
||||
Reference in new issue
Block a user