fix(anatomy): R5.4 records bounded in total, CHANGELOG tables projected before they are joined
This commit is contained in:
1 parent
777c8000b8
commit
5880dfa959
9 files changed
+258
-6
No files matched your search
@@ -0,0 +1,88 @@
|
||||
# Security gate R5.4 (round 7): review files in Rust
|
||||
|
||||
Branch `feature/rust-r5-pipeline-core`, HEAD `777c800`. Scope: `git diff c6e0d85..HEAD -- crates/core packages/anatomy/tests docs/development/RUST.md` (26 files). Blind, complete scan. No prior verdict was read.
|
||||
|
||||
```
|
||||
SECURITY — VERDICT: BLOCK(2)
|
||||
TOOL: semgrep 1.168.0 — p/security-audit, p/secrets, p/owasp-top-ten
|
||||
SCOPE: 26 files
|
||||
BLOCKING:
|
||||
1. [HIGH] resource-bound/output-amplification — crates/core/src/curation/draft/changelog.rs:68 (record_row), :116-119 (table built whole); crates/core/src/curation/markdown.rs:52-63 (table), :139-159 (bound checked after the raw rows exist); crates/core/src/curation/draft/pipeline.rs:247-252; docs/development/RUST.md:3206 — the CHANGELOG raw table (rows × authored rationale/title) is fully built, joined and split before MAX_TABLE_COLUMNS_TOTAL is checked, so the declared case "80 KB rationale over 14,000 records" still exhausts memory: a 1.9 MB changes.json aborts at a 3 GB address-space cap; RUST.md's "refused before any row is built" is false — hint: bound before render_changelog builds a row (project rows × widest authored cell per level from the records, or cap the raw length while table() accumulates), and pin it with a pipeline-level test (build + render of the declared case under a memory ceiling), not format_markdown on a hand-built table
|
||||
2. [HIGH] resource-bound/record-amplification — crates/core/src/curation/draft/ops.rs:197 (rename), :384 (remove); crates/core/src/curation/draft/records.rs:18-28 (out of diff, same pipeline) — every rename/remove record deep-copies the whole item (before and after) and every record clones the ChangeSummary (title, rationale, question); MAX_DOCUMENT_VALUES (200,000) bounds the document after an op, never the sum of the records: an 810 KB changes.json (one 5,000-child add, 400 renames back and forth) reaches 4.3 GB RSS at build, linear at ~10.7 MB per rename; ~1,400 renames exceed the 15 GB dev machine; R5.4's CHANGELOG then serialises each whole item again (compact_value) — hint: bound the records (total values or bytes recorded, checked as each record is pushed, refused with Guard) or record ids/paths and share the ChangeSummary (index or Rc) instead of cloning
|
||||
REPORTED (non-blocking):
|
||||
- [LOW] new lint relaxation `#![allow(clippy::disallowed_methods, clippy::unwrap_used, clippy::expect_used)]` — crates/core/tests/curation_markdown.rs:6, crates/core/tests/curation_review.rs:6 (integration tests only, same line as every existing test file; not a security-rule suppression)
|
||||
- [LOW] pre-existing suppression `#![allow(clippy::disallowed_methods)]` — crates/core/src/bin/import_equine.rs:17 (the tool's declared I/O file, context)
|
||||
- [LOW] error echo size — crates/core/src/curation/report_guard.rs:29-31 (UnsupportedMarkdown carries the whole refused line, multi-MB on stderr; authored content, no secret)
|
||||
- [LOW] subfolder race — crates/core/src/bin/import_equine.rs:353-389 (write_exclusive re-checks the claimed root only, not the subfolders this run created; same-user swap, declared out of model in RUST.md §11.13; unchanged by this diff)
|
||||
PROOF: semgrep 128 rules on 26 files → 0 findings; checklist 12 checks → 6 findings (2 HIGH, 4 LOW)
|
||||
```
|
||||
|
||||
## Checklist detail
|
||||
|
||||
| Check | Result |
|
||||
|---|---|
|
||||
| Hardcoded secret, token, key, credentialed URL | none in the added lines |
|
||||
| SQL by concatenation | none (no SQL in the diff) |
|
||||
| Unsanitized render (innerHTML, eval, raw) | none |
|
||||
| Sensitive endpoint without authz | not applicable (offline CLI and pure core) |
|
||||
| Stack trace or internal path to a user | none (CLI messages to the operator) |
|
||||
| Secret or PII in a log | none; `println!` lines print file names and counts |
|
||||
| Tracked `.env` or credential file | only `.env.example` tracked |
|
||||
| guardrails `scan.py --domain api,supabase` | 0 FAIL, 1 WARN (`SB-POLICY-NOT-OWNER`, `supabase/migrations/20261008110000_anatomical_sheets.sql:1177`, outside the diff: dropped) |
|
||||
| Anti-gaming (new suppressions) | two test-file lint allows, convention of all test files, LOW |
|
||||
| Report structure forgery (sections, list items, code spans, links, HTML) | held, see below |
|
||||
| SVG well-formedness and injection | held: serializer escapes `& < > "` and CR/TAB/LF in attributes, `first_unwritable` refuses non-XML-1.0 code points and CR, element and attribute names are fixed, no href or event attribute written |
|
||||
| Resource bounds and file safety | 2 HIGH (above); quadratic scans and `--out`/`--check` held, see below |
|
||||
|
||||
## Finding 1: CHANGELOG raw table amplified before its bound
|
||||
|
||||
`render_changelog` builds one row per record, each carrying the change's title and rationale (`changelog.rs:89`, `:94`). `table()` joins every row, wraps it, and joins again. `format_report` then guards each line, and `align` splits every row into owned strings. Only after all of that does it compare `row_width × rows` with `MAX_TABLE_COLUMNS_TOTAL`. So the bound caps the padded copy only. The raw table, which already holds N × R bytes, gets built four to five times first.
|
||||
|
||||
Measured with the full pipeline (`build_equine_draft` + `render_draft_artifacts` on the real legacy sources and the committed changeset, plus one appended change of `set` ops):
|
||||
|
||||
| changes.json | rationale × set ops | Result |
|
||||
|---|---|---|
|
||||
| 545 KB | 20 KB × 3,000 | Guard refusal, peak 373 MB |
|
||||
| 506 KB | 100 KB × 2,000 | Guard refusal, peak 1.19 GB |
|
||||
| 1.04 MB | 400 KB × 4,000 | `memory allocation failed`, signal 6, at the 6 GB cap |
|
||||
| 1.92 MB | 80 KB × 14,000 (the case RUST.md declares held) | `memory allocation failed`, signal 6, at the 3 GB cap |
|
||||
|
||||
The 16 MiB read cap allows inputs of hundreds of GB of raw table. Without a ulimit the process grows until the OOM killer acts. The failure is fail-closed: `folders()` finishes before `claim_destination`, so nothing gets written. The impact is availability of the developer machine, and that includes `--check`. The test `an_aligned_table_past_the_bound_is_refused_before_it_is_built` calls `format_markdown` on a table it built by hand, so it cannot see the pipeline's allocation.
|
||||
|
||||
## Finding 2: records deep-copy whole items
|
||||
|
||||
`ChangeRecord` keeps a `ChangeSummary` clone plus deep copies of `before` and `after`, and for a rename or remove those copies are the whole item (`records.rs:18`). An `add` of a 5,000-child category followed by N renames that swap its id back and forth gives:
|
||||
|
||||
| renames | build-only RSS |
|
||||
|---|---|
|
||||
| 0 | 56 MB |
|
||||
| 100 | 1.13 GB |
|
||||
| 200 | 2.20 GB |
|
||||
| 400 | 4.34 GB (810 KB changes.json) |
|
||||
|
||||
`MAX_DOCUMENT_VALUES` is checked on the document after each op, not on what the records accumulate. The cloning lines are R5.3 code, but they sit in a file of this diff (`ops.rs`, whose `apply_rename` the diff modifies), and the R5.4 renderers consume every record. The TypeScript had the same amplification but V8's heap limit stopped it with a clean error. The Rust process has no such ceiling.
|
||||
|
||||
## What held
|
||||
|
||||
Markdown guard. I ran a differential of `report_guard::format_report` (Rust) against Prettier 3.8.3 `format(…, parser: 'markdown')` with the repository options, on raw reports shaped like the generator's output: list items with title, rationale and question, CHANGELOG rows with `cell()` applied, bibliography and decision lines. Authored texts followed the same preconditions as the code (no backtick; no control character or wiki/liquid bracket in list items). Results:
|
||||
- 201,000 random probes over the admitted alphabet plus adversarial tokens (`&`, `&#`, URL starts, `**`, `_`, `\`, brackets, wide and zero-width characters). 20,969 were admitted and 0 diverged.
|
||||
- 960 targeted probes: reference-style links with a space, `[a]: b` mid-line, `1.`, `#`, `+`, `>` at a cell start, bare URLs with `_`, `)`, `&`, `x@y`, `**é**`, `a\|b` outside tables, `<3`, `<-`. 689 were admitted and 0 diverged.
|
||||
|
||||
None of these forged a section, list item, code span, link or HTML. A newline in a list-item field is refused, and table cells turn newlines into spaces. The guard's scans stayed linear: 18 lines of 4 MB with 20,000 code spans each ran in 1.19 s.
|
||||
|
||||
`--check` and `--out`:
|
||||
- `compare_file` falls back on trees only for `review/app-*` with the declared rule. `compare_drawing` returns an error with no rule, requires the committed file to rebuild byte for byte from its tree, and requires the rule to change it.
|
||||
- `inside_by_identity` now fails closed with an explicit error.
|
||||
- Reads stay canonical-inside-seed, regular-file-only and capped at 16 MiB.
|
||||
- Written names are `Component::Normal` only, and view ids are stable ids.
|
||||
- Writes use `create_new`, and the existing destination is identity-checked against the seed.
|
||||
|
||||
SVG: `drawing_text` refuses unwritable text, and the overlay and the app layer only emit fixed element and attribute names. Depth is bounded by the core reader's prescan before `first_difference` or `TriggerNames::apply` recurse.
|
||||
|
||||
## Probes (scratchpad only, no tracked change, nothing deleted)
|
||||
|
||||
- `/tmp/claude-1000/-home-bchanot-Documents-faunosteo/9b0edf59-ccd2-4662-b90c-e473dd78028e/scratchpad/probe/src/main.rs` (guard probe), `/tmp/claude-1000/-home-bchanot-Documents-faunosteo/9b0edf59-ccd2-4662-b90c-e473dd78028e/scratchpad/probe/src/bin/amp.rs` (pipeline memory probe; `BUILD_ONLY=1` stops after the build)
|
||||
- `/tmp/claude-1000/-home-bchanot-Documents-faunosteo/9b0edf59-ccd2-4662-b90c-e473dd78028e/scratchpad/scripts/fuzz.py`, `/tmp/claude-1000/-home-bchanot-Documents-faunosteo/9b0edf59-ccd2-4662-b90c-e473dd78028e/scratchpad/scripts/targeted.py`, `/tmp/claude-1000/-home-bchanot-Documents-faunosteo/9b0edf59-ccd2-4662-b90c-e473dd78028e/scratchpad/scripts/prettier.mjs`
|
||||
- `/tmp/claude-1000/-home-bchanot-Documents-faunosteo/9b0edf59-ccd2-4662-b90c-e473dd78028e/scratchpad/scripts/mkchg.py` (finding 1 inputs), `/tmp/claude-1000/-home-bchanot-Documents-faunosteo/9b0edf59-ccd2-4662-b90c-e473dd78028e/scratchpad/scripts/mkren.py` (finding 2 inputs)
|
||||
|
||||
Memory probes ran under `ulimit -v` (3 to 6 GB). Cargo built into a scratchpad `CARGO_TARGET_DIR`. `git status` stayed clean at `777c800`.
|
||||
@@ -55,6 +55,11 @@ Fresh verifier and security on the fixed commit: below.
|
||||
- Security (`.claude/audits/2026-10-23-rust-r5-review-security-6.md`): MEDIUM CHANGELOG table amplification (rows × widest cell: +155 KB changeset → 1.09 GB, 2.2 GB RSS; TypeScript alike); LOW per-view drawings bounded only by the value bound (≈2 GB estimate); LOW `underscore_pairs_later` O(parts × length) in isolation, unreachable (≤2 authored parts per line); LOW invisible Hangul fillers admitted (Prettier keeps them); LOW unpadded `[[x]]` in a cell by design; LOW test allows (convention).
|
||||
- Fixed: aligned table bounded at 32 Mi display columns before any row is built (`Guard`, test `an_aligned_table_past_the_bound_is_refused_before_it_is_built`; equine widest ≈0.5 MB), declared in §11.14; residual risks (drawings bound, Hangul fillers) in §11.15; `draft/mod.rs` header; RUST.md wording (format_markdown shared refusals, alphabetic marks); declared emoji case now holds its review report (same text or declared refusal) and drawings; TODO R5.4a.
|
||||
|
||||
## Round 7
|
||||
## Round 7 on 777c800: security BLOCK(2) (verifier pending at fix time); `pnpm check:all` green 14:43:14
|
||||
|
||||
- Security (`.claude/audits/2026-10-23-rust-r5-review-security-7.md`): HIGH output amplification: the CHANGELOG raw table (rows × authored rationale) built whole before the round-6 bound (1.9 MB changes.json aborts at 3 GB), RUST.md "refused before any row is built" false; HIGH record amplification: rename/remove records deep-copy the whole item and clone the change texts, no total bound (400 renames of a 5,000-child item → 4.3 GB). LOW test allows, bin allow (context), error echo size, subfolder race (declared out of model).
|
||||
- Fixed: records bounded in total (`apply::MAX_RECORDED_WEIGHT` 16 Mi units, `records::record_weight`, checked after every op; equine 1,084,422), test `the_records_cannot_outgrow_their_bound`; CHANGELOG tables projected from their cells before the raw table is joined (`markdown::assert_table_bound`), pipeline-level test `a_changelog_whose_alignment_would_explode_is_refused_before_it_is_built`; RUST.md rows rewritten exactly, residual risk (one op's copies before the check).
|
||||
|
||||
## Round 8
|
||||
|
||||
Fresh verifier and security on the fixed commit: below.
|
||||
@@ -14,7 +14,9 @@
|
||||
use serde_json::Value;
|
||||
|
||||
use super::ops::{apply_op, assert_declared};
|
||||
use super::records::{ChangeRecord, CurationResult, Recorder, strip_marks, touch_order};
|
||||
use super::records::{
|
||||
ChangeRecord, CurationResult, Recorder, record_weight, strip_marks, touch_order,
|
||||
};
|
||||
use super::schema::{Change, ChangeSummary, Op, SetOp};
|
||||
use super::shape::assert_same_shape;
|
||||
use super::targets::{
|
||||
@@ -95,10 +97,37 @@ fn mark_to_confirm(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The total weight of the records (`records::record_weight`): about 16 MiB of text, or a
|
||||
/// quarter of a million JSON values, far past the equine changeset (test
|
||||
/// `the_records_cannot_outgrow_their_bound`) and small enough that the reports built from them
|
||||
/// stay bounded too. Checked after every op, before the next one records anything.
|
||||
pub const MAX_RECORDED_WEIGHT: usize = 16 * 1024 * 1024;
|
||||
|
||||
/// The records counted so far and their weight.
|
||||
#[derive(Default)]
|
||||
struct Tally {
|
||||
counted: usize,
|
||||
weight: usize,
|
||||
}
|
||||
|
||||
fn assert_recorded(records: &[ChangeRecord], tally: &mut Tally) -> Result<(), PipelineError> {
|
||||
for record in &records[tally.counted..] {
|
||||
tally.weight = tally.weight.saturating_add(record_weight(record));
|
||||
}
|
||||
tally.counted = records.len();
|
||||
if tally.weight > MAX_RECORDED_WEIGHT {
|
||||
return Err(fail(format!(
|
||||
"the records weigh more than {MAX_RECORDED_WEIGHT} units"
|
||||
)));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn apply_change(
|
||||
doc: &mut Value,
|
||||
change: &Change,
|
||||
records: &mut Vec<ChangeRecord>,
|
||||
tally: &mut Tally,
|
||||
) -> Result<(), PipelineError> {
|
||||
let summary = change.summary();
|
||||
assert_declared(doc, &change.reference_ids)
|
||||
@@ -108,10 +137,12 @@ fn apply_change(
|
||||
let mut recorder = Recorder::new(&summary, op, records, &mut next_touch);
|
||||
apply_op(doc, &mut recorder)
|
||||
.and_then(|()| assert_depth(doc))
|
||||
.and_then(|()| assert_recorded(records, tally))
|
||||
.map_err(|error| fail(format!("{} op {index}: {error}", change.id)))?;
|
||||
}
|
||||
if change.level.needs_confirmation() {
|
||||
mark_to_confirm(doc, &summary, records)?;
|
||||
assert_recorded(records, tally).map_err(|error| fail(format!("{}: {error}", change.id)))?;
|
||||
}
|
||||
strip_marks(doc);
|
||||
Ok(())
|
||||
@@ -204,8 +235,9 @@ pub fn apply_changeset(
|
||||
.ok_or_else(|| fail("the baseline is not an object"))?
|
||||
.insert("references".to_owned(), registry);
|
||||
let mut records = Vec::new();
|
||||
let mut tally = Tally::default();
|
||||
for change in changes {
|
||||
apply_change(&mut doc, change, &mut records)?;
|
||||
apply_change(&mut doc, change, &mut records, &mut tally)?;
|
||||
}
|
||||
curated_issues(&doc)?;
|
||||
Ok(CurationResult {
|
||||
|
||||
@@ -12,7 +12,7 @@ use super::schema::ChangeLevel;
|
||||
use super::stats::{DocumentStats, stat_rows};
|
||||
use super::targets::fail;
|
||||
use crate::curation::PipelineError;
|
||||
use crate::curation::markdown::{Cell, code, table};
|
||||
use crate::curation::markdown::{Cell, assert_table_bound, code, table};
|
||||
use crate::curation::report_guard::assert_authored;
|
||||
use crate::json::to_js_compact;
|
||||
|
||||
@@ -113,6 +113,9 @@ fn level_section(level: ChangeLevel, records: &[ChangeRecord]) -> Result<String,
|
||||
"Références",
|
||||
"Confirmation requise",
|
||||
];
|
||||
// The rows are bounded through the records' weight; their alignment is checked here,
|
||||
// before the raw table is joined.
|
||||
assert_table_bound(&head, &rows)?;
|
||||
let body = if rows.is_empty() {
|
||||
"Aucun changement de ce niveau.".to_owned()
|
||||
} else {
|
||||
|
||||
@@ -105,6 +105,50 @@ impl<'a> Recorder<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// What the records hold, in weight units: 64 per JSON value (a `Value` node costs tens of
|
||||
/// bytes) plus one per byte of every string (the values' and the change's texts, which each
|
||||
/// record clones). A rename or a remove records the whole item, so the records can grow far
|
||||
/// past the document; `apply` bounds their total (`MAX_RECORDED_WEIGHT`).
|
||||
pub fn record_weight(record: &ChangeRecord) -> usize {
|
||||
let change = &record.change;
|
||||
let texts = [
|
||||
change.id.as_str(),
|
||||
&change.title.fr,
|
||||
&change.title.en,
|
||||
&change.rationale,
|
||||
change.question.as_deref().unwrap_or_default(),
|
||||
&record.target,
|
||||
record.field.as_deref().unwrap_or_default(),
|
||||
];
|
||||
let text: usize = texts.iter().map(|text| text.len()).sum::<usize>()
|
||||
+ change.reference_ids.iter().map(String::len).sum::<usize>();
|
||||
let op_value = match &record.op {
|
||||
Op::Set(op) => value_weight(&op.value),
|
||||
Op::Add(op) => value_weight(&op.value),
|
||||
_ => 0,
|
||||
};
|
||||
text + op_value + value_weight(&record.before) + value_weight(&record.after)
|
||||
}
|
||||
|
||||
/// The weight of a value, walked with an explicit stack (no recursion).
|
||||
fn value_weight(value: &Value) -> usize {
|
||||
let mut weight = 0;
|
||||
let mut pending = vec![value];
|
||||
while let Some(value) = pending.pop() {
|
||||
weight += 64;
|
||||
match value {
|
||||
Value::String(text) => weight += text.len(),
|
||||
Value::Object(map) => {
|
||||
weight += map.keys().map(String::len).sum::<usize>();
|
||||
pending.extend(map.values());
|
||||
}
|
||||
Value::Array(items) => pending.extend(items),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
weight
|
||||
}
|
||||
|
||||
/// The touch order of a marked item.
|
||||
pub fn touch_order(item: &Item) -> Option<u64> {
|
||||
item.get(TOUCH_MARK).and_then(Value::as_u64)
|
||||
|
||||
@@ -48,6 +48,31 @@ pub fn cell(value: &Cell) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
/// Refuses a table whose alignment would pass `MAX_TABLE_COLUMNS_TOTAL`, from its cells, before
|
||||
/// the raw table is joined: a cell's bytes bound its display width (an emoji, the one glyph
|
||||
/// wider than its bytes, is refused by the width table), so the projection never under-counts.
|
||||
pub fn assert_table_bound(head: &[&str], rows: &[Vec<Cell>]) -> Result<(), PipelineError> {
|
||||
let mut widths: Vec<usize> = head.iter().map(|text| text.len().max(3)).collect();
|
||||
for row in rows {
|
||||
for (width, value) in widths.iter_mut().zip(row) {
|
||||
let bytes = match value {
|
||||
Cell::Text(text) => text.len() + text.matches('|').count(),
|
||||
Cell::Number(_) => 24,
|
||||
Cell::Null => 1,
|
||||
};
|
||||
*width = (*width).max(bytes);
|
||||
}
|
||||
}
|
||||
let row_width = widths.iter().sum::<usize>() + 3 * widths.len() + 1;
|
||||
if row_width.saturating_mul(rows.len() + 2) > MAX_TABLE_COLUMNS_TOTAL {
|
||||
return Err(PipelineError::Guard(format!(
|
||||
"an aligned table of {} rows × {row_width} columns exceeds the {MAX_TABLE_COLUMNS_TOTAL} bound",
|
||||
rows.len() + 2
|
||||
)));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// `table()`: the raw table the TypeScript wrote before Prettier aligned it.
|
||||
pub fn table(head: &[&str], rows: &[Vec<Cell>]) -> String {
|
||||
let mut lines = vec![head.join(" | "), vec!["---"; head.len()].join(" | ")];
|
||||
|
||||
@@ -775,6 +775,33 @@ fn the_document_cannot_hold_more_values_than_the_bound() {
|
||||
assert!(error.contains("more than 200000 values"), "{error}");
|
||||
}
|
||||
|
||||
/// A rename or a remove records the whole item, before and after, with the change's texts:
|
||||
/// the records are bounded in total (security gate R5.4 round 7: 400 renames of a
|
||||
/// 5,000-child item asked for 4.3 GB). The equine changeset stays far below the bound.
|
||||
#[test]
|
||||
fn the_records_cannot_outgrow_their_bound() {
|
||||
use faunosteo_core::curation::draft::apply::MAX_RECORDED_WEIGHT;
|
||||
use faunosteo_core::curation::draft::records::record_weight;
|
||||
let equine: usize = equine_draft().records.iter().map(record_weight).sum();
|
||||
println!("equine records weigh {equine} units");
|
||||
assert!(equine * 8 < MAX_RECORDED_WEIGHT, "{equine}");
|
||||
let children: Vec<Value> = (0..5_000)
|
||||
.map(|i| json!({ "id": format!("n{i}"), "name": { "fr": "a", "en": "a" } }))
|
||||
.collect();
|
||||
let value = json!({ "id": "many", "name": { "fr": "a", "en": "a" }, "children": children });
|
||||
let mut ops = vec![json!({ "op": "add", "target": MOBILITY, "value": value })];
|
||||
for round in 0..200 {
|
||||
let (from, to) = if round % 2 == 0 {
|
||||
("many", "other")
|
||||
} else {
|
||||
("other", "many")
|
||||
};
|
||||
ops.push(json!({ "op": "rename", "target": format!("{MOBILITY}/{from}"), "id": to }));
|
||||
}
|
||||
let error = mini_apply(Value::from(ops)).unwrap_err();
|
||||
assert!(error.contains("the records weigh more than"), "{error}");
|
||||
}
|
||||
|
||||
/// A `__proto__` segment had no faithful reading in the TypeScript (a prototype set, a
|
||||
/// polluted `Object.prototype`, or nothing written): the port refuses it at the op.
|
||||
#[test]
|
||||
|
||||
@@ -149,3 +149,29 @@ fn every_probe_is_formatted_as_the_typescript_or_refused() {
|
||||
assert_eq!(same + refused, 798);
|
||||
println!("{same} identical, {refused} refused");
|
||||
}
|
||||
|
||||
/// One long authored cell pads every row of its level: the CHANGELOG is refused before its
|
||||
/// table is joined, through the pipeline (security gate R5.4 round 7), while the records stay
|
||||
/// within their own bound.
|
||||
#[test]
|
||||
fn a_changelog_whose_alignment_would_explode_is_refused_before_it_is_built() {
|
||||
let frozen = oracle();
|
||||
let mobility = "finding:hip/hip-dysfunctions/mobility";
|
||||
let sets: Vec<Value> = (0..20)
|
||||
.map(|i| json!({ "op": "set", "target": mobility, "field": "name.en", "value": format!("v{i}") }))
|
||||
.collect();
|
||||
let change = |id: &str, rationale: String, ops: Vec<Value>| {
|
||||
json!({ "id": id, "level": "A", "kind": "technical",
|
||||
"title": { "fr": "Essai", "en": "Test" }, "rationale": rationale,
|
||||
"reference_ids": [], "ops": ops })
|
||||
};
|
||||
let long = change("CHG-001", "a".repeat(2_000_000), vec![sets[0].clone()]);
|
||||
let rows = change("CHG-002", "Essai".to_owned(), sets);
|
||||
let case = json!({ "changes_file": { "changes": [long, rows] } });
|
||||
let (changelog, _) = raw_reports(&frozen, &case);
|
||||
let error = changelog.unwrap_err();
|
||||
assert!(
|
||||
matches!(&error, PipelineError::Guard(message) if message.contains("exceeds the")),
|
||||
"{error}"
|
||||
);
|
||||
}
|
||||
@@ -3203,7 +3203,8 @@ pass the guard unchanged.
|
||||
|---|---|---|
|
||||
| authored text outside the allowlist: Markdown Prettier rewrites (`*x*`, `_x`, `x_**a**`, `**a****b**`, `Voir_https://…`, `a b`, a non-ASCII space, a tab, a line break in a list item, `` `` ``, `a\|b`, `[a](<b>)`, `[[ a ]]`, `*`…), the constructs refused whole (links, HTML tags, autolinks, character references) and any character outside the admitted set (pictographs, symbols, combining marks without the Alphabetic property; an alphabetic mark such as U+0345 is a letter and Prettier aligns it alike) | written, then rewritten by Prettier (escapes, `_emphasis_`, collapsed spaces, indented continuation lines, normalised links; a row with an extra cell), or kept | refused (`UnsupportedMarkdown`), even where Prettier would have kept the text |
|
||||
| a pictograph in a table cell (an emoji, and ©, ®, ™, ✓, ★, ⚠ and the other characters `text::is_emoji_candidate` lists) | measured with Prettier's tables | refused (`UnsupportedWidth`, R5.2): the set is wider than the emoji, the refusal stays loud |
|
||||
| an aligned report table past 32 Mi display columns in all (rows × padded row width; the equine CHANGELOG's widest table is about 0.5 MB): one long authored cell pads every row of its level, so an 80 KB rationale over 14,000 records asked for 1 GB (security gate R5.4 round 6) | Prettier aligned it (the same amplification) | refused before any row is built (`Guard`, test `an_aligned_table_past_the_bound_is_refused_before_it_is_built`), import report included |
|
||||
| an aligned report table past 32 Mi display columns in all (rows × padded row width; the equine CHANGELOG's widest table is about 0.5 MB): one long authored cell pads every row of its level, so an 80 KB rationale over 14,000 records asked for 1 GB (security gate R5.4 round 6) | Prettier aligned it (the same amplification) | refused (`Guard`): the CHANGELOG's tables are projected from their cells (bytes bound the display width) before the raw table is joined (test `a_changelog_whose_alignment_would_explode_is_refused_before_it_is_built`, through the pipeline), every other table in the aligner before any padded row is built (test `an_aligned_table_past_the_bound_is_refused_before_it_is_built`), import report included |
|
||||
| records weighing more than 16 Mi units in all (`records::record_weight`: 64 per JSON value plus one per string byte of the values and of the change's texts, which each record clones; the equine records weigh 1,084,422): a rename or a remove records the whole item, so 400 renames of a 5,000-child item asked for 4.3 GB, and an 80 KB rationale repeated over 14,000 records for 1.1 GB of raw rows (security gate R5.4 round 7) | recorded (the same copies) | refused at the op that passes the bound, before the next op records anything (test `the_records_cannot_outgrow_their_bound`); the raw report rows, built from the records, are bounded with them |
|
||||
| an id an `add` writes (the item's, and those nested in its `children` or `categories`) or a `rename` id that is not a stable id (a region code for a region), or a field segment outside `[A-Za-z0-9_-]` (a control character, NUL included, a backtick, a `]`, a space, a non-ASCII letter) | accepted when a later op removed or renamed the item: the raw id stayed in the records and reached the reports' code spans (a line break there forged a section, security gate R5.4 round 2) | refused at the op, the check the final document applies anyway (test `ids_and_field_segments_that_could_forge_report_structure_are_refused`) |
|
||||
| a label, id or path holding a code point XML 1.0 refuses, or a carriage return, in a review drawing | written (a non-well-formed file; a raw CR read back as a line feed) | refused: the drawing is not written |
|
||||
|
||||
@@ -3240,7 +3241,8 @@ ruled and frozen in the sweep, so a combination of admitted characters no probe
|
||||
differ; the comparison of the application's drawings accepts
|
||||
exactly the trigger-name rule, byte for byte; the frozen
|
||||
`horse.svg` is read, never regenerated, so a future change of the drawing needs its own
|
||||
decision; the review drawings are bounded only through the document's 200,000 values (two drawings
|
||||
decision; one op still records up to about three copies of an item under the 200,000-value bound
|
||||
before the records bound is checked (tens of MB at most); the review drawings are bounded only through the document's 200,000 values (two drawings
|
||||
of about 137 KB per view, about 2 GB at the bound, an estimate of the security gate R5.4 round 6,
|
||||
not measured), and the allowlist admits the invisible Hangul fillers (U+3164, U+115F, U+1160,
|
||||
U+FFA0, letters Prettier keeps, no structure); the residual risks of §11.13 stand.
|
||||
|
||||
Reference in new issue
Block a user