fix(anatomy): R5.4 field segments and code spans on the generator alphabet, wiki and liquid brackets refused in list items, linear guard
This commit is contained in:
1 parent
1b12d90325
commit
aeb5050502
10 files changed
+325
-48
No files matched your search
@@ -0,0 +1,192 @@
|
|||||||
|
SECURITY — VERDICT: PASS
|
||||||
|
TOOL: semgrep 1.168.0 — p/security-audit, p/secrets, p/owasp-top-ten
|
||||||
|
SCOPE: 37 files
|
||||||
|
BLOCKING:
|
||||||
|
(none)
|
||||||
|
REPORTED (non-blocking):
|
||||||
|
- [MEDIUM] report-guard/wiki-link-across-code-spans (silent family F2) — crates/core/src/curation/report_guard.rs:55-59 (rule applied per plain part from :177-183); crates/core/src/curation/draft/review_report.rs:90-100
|
||||||
|
- [MEDIUM] report-guard/opener-closed-inside-code-span (silent family F1) — crates/core/src/curation/report_guard.rs:178-179; crates/core/src/curation/draft/fields.rs:104-112,123-125; crates/core/src/curation/draft/review_report.rs:91-98
|
||||||
|
- [LOW] declaration/code-spans-called-generator-only — docs/development/RUST.md:3166-3173,3176-3178,3221-3230; crates/core/src/curation/report_guard.rs:14-17
|
||||||
|
- [LOW] report-guard/quadratic-cost-per-line — crates/core/src/curation/report_guard.rs:116-122,126-141,55-59
|
||||||
|
- [LOW] anti-gaming/test-only-clippy-allow (context, not a security suppression) — crates/core/tests/curation_review.rs:6; crates/core/tests/curation_markdown.rs:6
|
||||||
|
PROOF: semgrep 162 rules on 37 files → 0 findings; checklist 9 checks → 1 finding (LOW); guard differential (Rust format_report vs Prettier 3.8.3 with the repository options) 147,789 report documents, then the Rust pipeline vs the TypeScript pipeline end to end on 13 changesets → 2 silent families reproduced end to end (MEDIUM), 2 LOW
|
||||||
|
|
||||||
|
# Security gate 5, R5.4 review files (2026-10-23)
|
||||||
|
|
||||||
|
Scope: `git diff c6e0d85..1b12d90` (HEAD of `feature/rust-r5-pipeline-core`), 37 files, read from a
|
||||||
|
pristine `git archive` copy of 1b12d90 in the session scratchpad. Product files read whole:
|
||||||
|
`curation/report_guard.rs`, `curation/markdown.rs`, `curation/mod.rs`, `draft/changelog.rs`,
|
||||||
|
`draft/review_report.rs`, `draft/svg_compare.rs`, `draft/drawing.rs`, `draft/overlay.rs`,
|
||||||
|
`draft/app_review.rs`, `draft/fields.rs`, `bin/import_equine.rs`, the diffs of `pipeline.rs`, `ops.rs`,
|
||||||
|
`mod.rs` and `Cargo.toml`, RUST.md §11.14 and §11.15, and the TypeScript sweep generator.
|
||||||
|
|
||||||
|
## Grading
|
||||||
|
|
||||||
|
No HIGH or CRITICAL: the inputs are the owner's own `changes.json` and `references.json`, the tool is
|
||||||
|
never deployed and exposes nothing, and no finding crosses a security boundary (no write outside the
|
||||||
|
claimed folder, no seed modification, no code execution). The two MEDIUMs breach the owner's
|
||||||
|
stated contract for this tool ("a report never differs silently from what the TypeScript+Prettier
|
||||||
|
pipeline wrote: byte-identical or loudly refused"). The gate does not block on them, but by that
|
||||||
|
contract they are defects to fix before R5.4 closes. Both were reproduced end to end: the raw
|
||||||
|
texts of the two pipelines are identical, the Rust `CHANGELOG.md` is identical, and the Rust
|
||||||
|
`REVIEW-REPORT.md` differs from the TypeScript one with no refusal.
|
||||||
|
|
||||||
|
Both new families have one root cause. The guard decides inline constructs per stretch of text
|
||||||
|
between two backticks. Prettier's parser builds wiki links, link references and liquid tags across
|
||||||
|
the generator's code spans, and its bracket counting does not see code spans at all.
|
||||||
|
|
||||||
|
## MEDIUM 1: wiki link split across two authored fields (F2)
|
||||||
|
|
||||||
|
`rewritten_construct` (report_guard.rs:53-80) runs on each plain part separately (`guard_text`,
|
||||||
|
:177-183). Its padded wiki rule (:55-59) needs the `[[` and the `]]` in the same plain part. In
|
||||||
|
the review report, `change_line` (review_report.rs:90-100) writes the title and the rationale
|
||||||
|
before the generated `Objets : \`…\`` and `Références : …` code spans and the question after them,
|
||||||
|
all on one line. A `[[` in the title or rationale and a `]]` in the question form one wiki link
|
||||||
|
that spans the code spans. Prettier's wiki-link plugin trims its content, so a space next to either
|
||||||
|
bracket is dropped. The guard never sees the pair.
|
||||||
|
|
||||||
|
Reproduced end to end on the sweep's mini sheet (Rust `apply_changeset`, `render_review_report`,
|
||||||
|
`format_report` against the TypeScript `applyChangeset`, `renderReviewReport`, `formatMarkdown`).
|
||||||
|
Changeset: one level C change, op `set finding:hip/hip-dysfunctions/mobility name.en = "Mobility"`,
|
||||||
|
title `Mobilité`, rationale `Libellé repris de [[`, question `Faut-il garder ]] ?`:
|
||||||
|
|
||||||
|
```
|
||||||
|
rust: … Libellé repris de [[ Objets : `finding:…name.en`, … Question : Faut-il garder ]] ?
|
||||||
|
ts : … Libellé repris de [[Objets : `finding:…name.en`, … Question : Faut-il garder]] ?
|
||||||
|
```
|
||||||
|
|
||||||
|
The same happens with title `Renommer [[mobilité` and question `Garder le nom ]] ?`, with rationale
|
||||||
|
`Voir [[ la fiche` and question `Confirmer]] ?`, and with title `Mobilité [[` (the generator's
|
||||||
|
following space pads it). Three random seeds of a mixed sweep without any field trick (48,000
|
||||||
|
documents, 26,244 admitted) gave 55 silent differences, all from this family.
|
||||||
|
|
||||||
|
How contrived: the changeset is fully valid and the document is untouched. It only needs wiki-link
|
||||||
|
brackets split between the title or rationale and the question of one change, with a space next to
|
||||||
|
one bracket. Wiki-link syntax is rare in French clinical prose, so accidental occurrence is
|
||||||
|
unlikely, but no malformed data is involved.
|
||||||
|
|
||||||
|
Fix direction: evaluate the construct rules on the whole line, code spans included, the way the
|
||||||
|
parser does (at least: a `[[` with a later `]]` anywhere on the line, a space next to either);
|
||||||
|
or refuse `[[` and `]]` in the list-item fields unless they form a closed, unpadded pair inside the
|
||||||
|
same field. Add cross-field probes to the sweep. Today it puts the same probe in every field, so
|
||||||
|
an opener in one field and its closer in another lies outside it by construction.
|
||||||
|
|
||||||
|
## MEDIUM 2: an authored opener closed inside a generated code span (F1)
|
||||||
|
|
||||||
|
Inside a code part, the guard admits anything but a carriage return or a tab (:178-179). The module
|
||||||
|
doc and RUST.md call code spans "the generator's alone (ids, targets, field names)", but field
|
||||||
|
names are authored. `is_settable` checks only the first segment of a `set` field
|
||||||
|
(fields.rs:123-125), and `split_field` refuses only empty segments, control characters, backticks,
|
||||||
|
NUL starts and `__proto__` (:91-121). Any other sub-segment reaches the review report's `Objets`
|
||||||
|
code spans through `record_subject`. If the title or the rationale holds an unclosed `[`, `[[` or
|
||||||
|
`{%`, the parser closes it at a `]`, `]]` or `%}` inside that code span, re-pairs every backtick
|
||||||
|
after it, and re-prints the rest of the span as Markdown.
|
||||||
|
|
||||||
|
Reproduced end to end. Change title `Mobilité [voir note`. Ops:
|
||||||
|
`set finding:hip/hip-dysfunctions/mobility name.<130 × "p">.a]_ = "x"`, then
|
||||||
|
`set … name = {"fr":"Mobilité","en":"Mobility"}`. The second op makes the final document valid
|
||||||
|
again, and the padding pushes the stray key past the CHANGELOG's 120-unit value cut, where the guard
|
||||||
|
would otherwise refuse it:
|
||||||
|
|
||||||
|
```
|
||||||
|
rust: … Objets : `finding:…name.ppp….a]_`, `finding:…name`, …
|
||||||
|
ts : … Objets : `finding:…name.ppp….a]\_`, `finding:…name`, …
|
||||||
|
```
|
||||||
|
|
||||||
|
Other reproduced variants: title `Titre [[x` with segment `a]] *b*` (TS prints `_b_`), `Titre [x`
|
||||||
|
with `a][b` (TS prints `a]b`), `Titre {%x` with `a%} *b*`, and the opener in the rationale. The
|
||||||
|
same breakage also turns the tail of a code span into live Markdown. With segment
|
||||||
|
`a] [lien](https://example.org) <b>gras</b> x` and title `voir [x`, the parsed report holds a link
|
||||||
|
and two inline HTML nodes, and `, ` becomes a code span. Both pipelines print that identically, so
|
||||||
|
it is no silent difference, but it gets past the guard's "no link, no HTML tag" rule. The author
|
||||||
|
already controls the file, so nothing is gained in privilege.
|
||||||
|
|
||||||
|
How contrived: very. It needs a field path with a stray sub-segment (a typo-class authoring error)
|
||||||
|
that a later op overwrites or removes, because every sheet object is strict and the final document
|
||||||
|
would be refused otherwise. The stray key must also stay out of the first 120 UTF-16 units of every
|
||||||
|
CHANGELOG value, or the guard refuses it there and the whole run stops. And the change's title or
|
||||||
|
rationale needs an unclosed opener.
|
||||||
|
|
||||||
|
Fix direction: refuse at `split_field` any segment outside the id alphabet (`[A-Za-z0-9_-]`, which
|
||||||
|
every settable path uses: `name.fr`, `view_box.min_x`, `count_range.min`). That is a declared
|
||||||
|
refusal where the TypeScript accepted. Then make the code-span rule an allowlist of what the
|
||||||
|
generator really writes (ids, `CHG-ddd`, `kind:id/…`, dotted field names).
|
||||||
|
|
||||||
|
## LOW: the residual-risk declaration is accurate in kind, wrong in two specifics
|
||||||
|
|
||||||
|
§11.14 and §11.15 correctly call the guarantee empirical and say an unprobed combination could
|
||||||
|
still differ. Two statements are false as written, though. "Code spans are the generator's alone
|
||||||
|
(ids, targets, field names); inside them, anything but a carriage return or a tab" (RUST.md
|
||||||
|
:3170-3173, report_guard.rs:14-17) hides that field sub-segments are authored, and that this channel
|
||||||
|
has the weakest rule of the guard. "Nested padded wiki links" and the other constructs are listed
|
||||||
|
as ruled (:3166-3168), but they are ruled only within one stretch between backticks. The sweep's
|
||||||
|
blind spot also deserves a line: one probe copied into every field never puts an opener and its
|
||||||
|
closer in two different fields. Fix: correct the module doc and §11.14 and §11.15 when F1 and F2 are
|
||||||
|
fixed.
|
||||||
|
|
||||||
|
## LOW: quadratic guard cost per line
|
||||||
|
|
||||||
|
`in_url_token` (:116-122) scans back to the token start for every `&` that is followed by a
|
||||||
|
lowercase letter (:129). The padded-wiki rule (:55-59) runs `contains` over the rest of the part
|
||||||
|
for every `[[` or `]]`. Measured on the release build: a 160 kB token
|
||||||
|
`https://x.org/?a=1&b=1&b=1…` takes 4.1 s and a 640 kB one 28.4 s. 640 kB of ` ]]` takes 5.6 s. Memory
|
||||||
|
stays flat (8 MB). Authored texts have no length cap below the 16 MiB file bound
|
||||||
|
(`MAX_FILE_BYTES`), and each text is guarded in two or three lines, so a multi-megabyte rationale
|
||||||
|
stalls the run for minutes to hours. It is owner-authored and can be interrupted. Fix: one forward
|
||||||
|
pass (track the current token's start and whether it holds a URL literal; precompute the first `[[`
|
||||||
|
and the last `]]` of the line), or a length cap on authored texts.
|
||||||
|
|
||||||
|
## LOW: new lint allows (anti-gaming, context)
|
||||||
|
|
||||||
|
`#![allow(clippy::disallowed_methods, clippy::unwrap_used, clippy::expect_used)]` heads the two new
|
||||||
|
integration test files (curation_review.rs:6, curation_markdown.rs:6), the same as the
|
||||||
|
pre-existing curation_draft.rs:7. These are test-only lint allows (oracle file reads, unwraps) in
|
||||||
|
separate test crates. They do not weaken the library's no-I/O rule and do not silence a security
|
||||||
|
scanner. The diff adds no `nosemgrep`, `nosec`, `eslint-disable`, `ts-ignore` or `noqa`. Not
|
||||||
|
blocking.
|
||||||
|
|
||||||
|
## Checked and clean
|
||||||
|
|
||||||
|
- semgrep, pinned packs, `--metrics=off` (EIO_BACKEND=posix), 37 files (rs, ts, md, json, toml):
|
||||||
|
0 results, 0 errors.
|
||||||
|
- Checklist: no secret, token, key or credential URL in the added lines (pattern grep plus
|
||||||
|
p/secrets). No SQL built in the diff (the seed SQL renderer is unchanged R5.3 code). No
|
||||||
|
innerHTML, `eval` or HTML sink. No endpoint, so no authz surface. No secret in a log. No tracked
|
||||||
|
`.env` or credential file (the tracked `.env.example` is the placeholder convention, outside the
|
||||||
|
scope; reading it was refused by a permission deny rule, so it was not opened).
|
||||||
|
- Guardrails scanner (`--domain api,supabase`, on the pristine copy): 0 FAIL, 1 WARN, 1 MANUAL. The
|
||||||
|
WARN (`SB-POLICY-NOT-OWNER`, `supabase/migrations/20261008110000_anatomical_sheets.sql:1177`) is in
|
||||||
|
a file outside the diff and is excluded.
|
||||||
|
- No authored text reaches a report outside the guard: both reports go through `format_report`
|
||||||
|
(pipeline.rs). Every authored field the reports print passes `assert_authored` (changelog.rs:70-71,
|
||||||
|
91-92; review_report.rs:361-389). Cell pipes are escaped and an authored `\|` is refused. Line
|
||||||
|
breaks become spaces in cells and are refused in list items. A row with another cell count is
|
||||||
|
refused. No authored text ever starts a line, so no heading, section, list or table can be forged.
|
||||||
|
Code spans are the exception, see F1.
|
||||||
|
- Drawings: every label, id, path and number goes through the core serializer's escaping, and
|
||||||
|
`first_unwritable` refuses XML-invalid text and CR. View ids used in file names are stable ids,
|
||||||
|
and `write_exclusive` accepts only plain components.
|
||||||
|
- Strict SVG comparison (`svg_compare.rs`): the committed file must rebuild byte for byte from its
|
||||||
|
tree, the rule must change that tree, and the rebuilt text after the rule must equal the produced
|
||||||
|
file byte for byte. The rule touches only `data-anno-name-en` and `FR / FR` titles of elements
|
||||||
|
that open a view, so it cannot hide another difference.
|
||||||
|
- `import-equine --check`, built in the scratch copy (read-only): `legacy-import: 6 files, 0
|
||||||
|
differences`, `draft: declared: review/app-main.svg …`, `draft: 12 files, 0 differences`, exit 0.
|
||||||
|
Its `--out` path checks (no `..`, parent canonicalized, seed refused by path and by inode,
|
||||||
|
symbolic link refused, non-empty refused, `create_dir` and `create_new` only) were read, not run.
|
||||||
|
- Panics: none found by reading the guard's slicing. A fuzz of 20,000 random multi-line documents
|
||||||
|
(tabs, CR, combining marks, U+2028, emoji, ZWJ, backticks, brackets) produced no panic.
|
||||||
|
|
||||||
|
## Method
|
||||||
|
|
||||||
|
Throwaway probes in the scratchpad only: `examples/guard_probe.rs` (calls `format_report`) and
|
||||||
|
`examples/pipeline_probe.rs` (the sweep's pipeline on a changes file), linked against the pristine
|
||||||
|
copy with `--features curation`; Node scripts running the repository's Prettier 3.8.3 with the
|
||||||
|
options of `packages/anatomy/src/format.ts`, and the TypeScript pipeline of `packages/anatomy/src`
|
||||||
|
through the tsx loader. Differential harness: raw report lines built like the reports (list items,
|
||||||
|
ordered items, table rows with `cell()` escaping), admitted by Rust then compared with Prettier.
|
||||||
|
Code-span channel: 1,476 documents, 0 silent without an opener. Random authored text: 66,000
|
||||||
|
documents, 48,737 admitted, 0 silent. Openers against code-span contents: 8,312 documents (F1).
|
||||||
|
Mixed fields: 72,000 documents (F1 and F2 only, every silent case classified). Fuzz: 20,000.
|
||||||
|
End to end: 13 changesets. No `--out` was run, nothing was deleted, and no file of the repository
|
||||||
|
was modified except this report.
|
||||||
@@ -42,3 +42,13 @@ Fresh verifier and security on the fixed commit: below.
|
|||||||
## Round 5
|
## Round 5
|
||||||
|
|
||||||
Fresh verifier and security on the fixed commit: below.
|
Fresh verifier and security on the fixed commit: below.
|
||||||
|
|
||||||
|
## Round 5 on 1b12d90: verifier ECARTS(2), security PASS (2 MEDIUM, 3 LOW)
|
||||||
|
|
||||||
|
- Verifier: C1, C3 to C8 MET. C2: 59 silent of 306,192 probes, all one class: a wiki link opened in one list-item field and closed in another of the same line (code spans between). C9: draft line count (4,376, gain 1,468), report_guard.rs line count, wiki rule wording.
|
||||||
|
- Security (`.claude/audits/2026-10-23-rust-r5-review-security-5.md`): MEDIUM F2 the same wiki link across fields; MEDIUM F1 an authored field segment (`name.x]`) inside a generated code span closing an author's `[`; LOW docs "code spans are the generator's alone" wrong (segments are authored); LOW quadratic `in_url_token` and padded-wiki scans; LOW test allows (context).
|
||||||
|
- Fixed: field segments limited to `[A-Za-z0-9_-]` at the op (declared refusal; TypeScript accepted any); code spans admit only the generator alphabet `[A-Za-z0-9_:/. -]`; list-item fields refuse `[[`, `]]`, `{%`, `%}` whole; plain parts refuse `{%`/`%}`; URL-token membership in one pass, padded wiki through one find/rfind; sweep 798 probes (eight cross-field construct pairs): 268 identical, 530 refused, 0 silent; segment refusal test with its reason; docs counts (draft 4,385, gain 1,477, report_guard.rs 258) and rules restated.
|
||||||
|
|
||||||
|
## Round 6
|
||||||
|
|
||||||
|
Fresh verifier and security on the fixed commit: below.
|
||||||
@@ -101,13 +101,16 @@ pub fn split_field(field: &str) -> Result<Vec<&str>, PipelineError> {
|
|||||||
if let Some(key) = path.iter().find(|key| key.starts_with('\0')) {
|
if let Some(key) = path.iter().find(|key| key.starts_with('\0')) {
|
||||||
return Err(fail(format!("reserved key {key:?} in field \"{field}\"")));
|
return Err(fail(format!("reserved key {key:?} in field \"{field}\"")));
|
||||||
}
|
}
|
||||||
// A control character or a backtick would reach the reports' code spans through the record.
|
// A segment reaches the reports' code spans through the record: the alphabet of every
|
||||||
if path
|
// settable path (`name.fr`, `view_box.min_x`, `count_range.min`), nothing a Markdown parser
|
||||||
.iter()
|
// could pair with the text around the span (a `]` closed an author's `[` there).
|
||||||
.any(|key| key.chars().any(|c| c.is_control()) || key.contains('`'))
|
let id_alphabet = |key: &str| {
|
||||||
{
|
key.chars()
|
||||||
|
.all(|c| c.is_ascii_alphanumeric() || "_-".contains(c))
|
||||||
|
};
|
||||||
|
if !path.iter().all(|key| id_alphabet(key)) {
|
||||||
return Err(fail(format!(
|
return Err(fail(format!(
|
||||||
"field {field:?} holds a control character or a backtick"
|
"field {field:?} holds a segment outside [A-Za-z0-9_-]"
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
// A JavaScript assignment through `__proto__` never wrote a key: it set a prototype,
|
// A JavaScript assignment through `__proto__` never wrote a key: it set a prototype,
|
||||||
|
|||||||
@@ -357,9 +357,15 @@ fn intro() -> String {
|
|||||||
|
|
||||||
/// A control character (a line break, a tab, a carriage return…) in an authored text the
|
/// A control character (a line break, a tab, a carriage return…) in an authored text the
|
||||||
/// report writes in a list item would break the item, and Prettier re-indents what follows:
|
/// report writes in a list item would break the item, and Prettier re-indents what follows:
|
||||||
/// refused (the TypeScript wrote it raw).
|
/// refused (the TypeScript wrote it raw). A list-item field shares its line with the other fields of the change and the generated
|
||||||
|
/// code spans: no control character, and no wiki-link or liquid bracket (`[[`, `]]`, `{%`, `%}`),
|
||||||
|
/// which Prettier pairs across the whole line (a `[[` in a rationale closed by the question's
|
||||||
|
/// `]]`, the code spans between them notwithstanding).
|
||||||
fn assert_single_line(text: &str) -> Result<(), PipelineError> {
|
fn assert_single_line(text: &str) -> Result<(), PipelineError> {
|
||||||
if text.chars().any(char::is_control) {
|
let across = ["[[", "]]", "{%", "%}"]
|
||||||
|
.iter()
|
||||||
|
.any(|bracket| text.contains(bracket));
|
||||||
|
if across || text.chars().any(char::is_control) {
|
||||||
return Err(PipelineError::UnsupportedMarkdown(text.to_owned()));
|
return Err(PipelineError::UnsupportedMarkdown(text.to_owned()));
|
||||||
}
|
}
|
||||||
assert_authored(text)
|
assert_authored(text)
|
||||||
|
|||||||
@@ -51,12 +51,16 @@ const LEGACY_ENTITIES: [&str; 106] = [
|
|||||||
/// HTML tag or an autolink (`<` before a letter, `/`, `!` or `?`), a character reference
|
/// HTML tag or an autolink (`<` before a letter, `/`, `!` or `?`), a character reference
|
||||||
/// (`&name;`, `&#n;`); a bare `&` is ruled in `admitted_char`.
|
/// (`&name;`, `&#n;`); a bare `&` is ruled in `admitted_char`.
|
||||||
fn rewritten_construct(plain: &str) -> bool {
|
fn rewritten_construct(plain: &str) -> bool {
|
||||||
// A `[[` padded inside with a `]]` after it, or a `]]` padded inside with a `[[` before it.
|
// A `[[` padded inside with a `]]` after it, or a `]]` padded inside with a `[[` before it
|
||||||
|
// (the last `]]` and the first `[[` found once: linear).
|
||||||
|
let last_close = plain.rfind("]]");
|
||||||
|
let first_open = plain.find("[[");
|
||||||
let padded_wiki = plain.match_indices("[[").any(|(at, _)| {
|
let padded_wiki = plain.match_indices("[[").any(|(at, _)| {
|
||||||
plain[at + 2..].starts_with(char::is_whitespace) && plain[at + 2..].contains("]]")
|
plain[at + 2..].starts_with(char::is_whitespace) && last_close.is_some_and(|c| c > at + 1)
|
||||||
}) || plain
|
}) || plain.match_indices("]]").any(|(at, _)| {
|
||||||
.match_indices("]]")
|
plain[..at].ends_with(char::is_whitespace) && first_open.is_some_and(|o| o + 1 < at)
|
||||||
.any(|(at, _)| plain[..at].ends_with(char::is_whitespace) && plain[..at].contains("[["));
|
});
|
||||||
|
let liquid = plain.contains("{%") || plain.contains("%}");
|
||||||
let tag = plain
|
let tag = plain
|
||||||
.split('<')
|
.split('<')
|
||||||
.skip(1)
|
.skip(1)
|
||||||
@@ -75,6 +79,7 @@ fn rewritten_construct(plain: &str) -> bool {
|
|||||||
|| plain.contains("][")
|
|| plain.contains("][")
|
||||||
|| plain.contains("![")
|
|| plain.contains("![")
|
||||||
|| padded_wiki
|
|| padded_wiki
|
||||||
|
|| liquid
|
||||||
|| tag
|
|| tag
|
||||||
|| reference
|
|| reference
|
||||||
}
|
}
|
||||||
@@ -111,22 +116,29 @@ fn starts_with(chars: &[char], from: usize, text: &str) -> bool {
|
|||||||
.all(|(index, c)| chars.get(index) == Some(&c))
|
.all(|(index, c)| chars.get(index) == Some(&c))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether position `i` lies in a bare URL token: the run of non-space characters around it
|
/// For each position, whether it lies in a bare URL token (a run of non-space characters
|
||||||
/// starts with a URL literal.
|
/// holding a URL literal before it), computed in one pass.
|
||||||
fn in_url_token(chars: &[char], i: usize) -> bool {
|
fn url_tokens(chars: &[char]) -> Vec<bool> {
|
||||||
let start = chars[..i]
|
let mut inside = Vec::with_capacity(chars.len());
|
||||||
.iter()
|
let mut seen = false;
|
||||||
.rposition(|c| c.is_whitespace())
|
for (k, c) in chars.iter().enumerate() {
|
||||||
.map_or(0, |p| p + 1);
|
if c.is_whitespace() {
|
||||||
(start..i).any(|k| URL_STARTS.iter().any(|url| starts_with(chars, k, url)))
|
seen = false;
|
||||||
|
}
|
||||||
|
inside.push(seen);
|
||||||
|
if URL_STARTS.iter().any(|url| starts_with(chars, k, url)) {
|
||||||
|
seen = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inside
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An `&` Prettier writes as is: before a space, or a URL's query separator (`&name=`, the name
|
/// An `&` Prettier writes as is: before a space, or a URL's query separator (`&name=`, the name
|
||||||
/// not starting with a legacy reference). Anything else may start a character reference.
|
/// not starting with a legacy reference). Anything else may start a character reference.
|
||||||
fn admitted_ampersand(chars: &[char], i: usize) -> bool {
|
fn admitted_ampersand(chars: &[char], urls: &[bool], i: usize) -> bool {
|
||||||
match chars.get(i + 1) {
|
match chars.get(i + 1) {
|
||||||
Some(' ') => true,
|
Some(' ') => true,
|
||||||
Some(c) if c.is_ascii_lowercase() && in_url_token(chars, i) => {
|
Some(c) if c.is_ascii_lowercase() && urls[i] => {
|
||||||
let name: String = chars[i + 1..]
|
let name: String = chars[i + 1..]
|
||||||
.iter()
|
.iter()
|
||||||
.take_while(|c| c.is_ascii_alphanumeric())
|
.take_while(|c| c.is_ascii_alphanumeric())
|
||||||
@@ -140,13 +152,13 @@ fn admitted_ampersand(chars: &[char], i: usize) -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn admitted_char(chars: &[char], i: usize) -> bool {
|
fn admitted_char(chars: &[char], urls: &[bool], i: usize) -> bool {
|
||||||
let at = |k: usize| chars.get(k).copied();
|
let at = |k: usize| chars.get(k).copied();
|
||||||
let previous = i.checked_sub(1).and_then(at);
|
let previous = i.checked_sub(1).and_then(at);
|
||||||
match chars[i] {
|
match chars[i] {
|
||||||
c if c.is_alphanumeric() => true,
|
c if c.is_alphanumeric() => true,
|
||||||
' ' => at(i + 1) != Some(' '),
|
' ' => at(i + 1) != Some(' '),
|
||||||
'&' => admitted_ampersand(chars, i),
|
'&' => admitted_ampersand(chars, urls, i),
|
||||||
'_' => {
|
'_' => {
|
||||||
previous.is_some_and(|c| c.is_ascii_alphanumeric())
|
previous.is_some_and(|c| c.is_ascii_alphanumeric())
|
||||||
&& at(i + 1).is_some_and(|c| c.is_ascii_alphanumeric())
|
&& at(i + 1).is_some_and(|c| c.is_ascii_alphanumeric())
|
||||||
@@ -165,7 +177,19 @@ fn admitted_plain(plain: &str) -> bool {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
let chars: Vec<char> = plain.chars().collect();
|
let chars: Vec<char> = plain.chars().collect();
|
||||||
(0..chars.len()).all(|i| admitted_char(&chars, i))
|
let urls = url_tokens(&chars);
|
||||||
|
(0..chars.len()).all(|i| admitted_char(&chars, &urls, i))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A code span as the generator writes one: ids, targets, field names, file paths and the
|
||||||
|
/// template's `pnpm import:equine` (the alphabet `[A-Za-z0-9_:/. -]`), never empty, no outer space.
|
||||||
|
fn generated_code(code: &str) -> bool {
|
||||||
|
!code.is_empty()
|
||||||
|
&& !code.starts_with(' ')
|
||||||
|
&& !code.ends_with(' ')
|
||||||
|
&& code
|
||||||
|
.chars()
|
||||||
|
.all(|c| c.is_ascii_alphanumeric() || "_:/. -".contains(c))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A text outside table delimiters: its code spans and its plain parts.
|
/// A text outside table delimiters: its code spans and its plain parts.
|
||||||
@@ -176,7 +200,7 @@ fn guard_text(text: &str) -> bool {
|
|||||||
}
|
}
|
||||||
let admitted = parts.iter().enumerate().all(|(index, part)| {
|
let admitted = parts.iter().enumerate().all(|(index, part)| {
|
||||||
if index % 2 == 1 {
|
if index % 2 == 1 {
|
||||||
!part.is_empty() && !part.starts_with(' ') && !part.ends_with(' ')
|
generated_code(part)
|
||||||
} else {
|
} else {
|
||||||
admitted_plain(part)
|
admitted_plain(part)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,12 +72,13 @@ const EQUINE_SAFE: &str = "[]&#{}=<>\"':;()/%?-.,«»…≠°—+";
|
|||||||
|
|
||||||
fn equine_safe(probe: &str) -> bool {
|
fn equine_safe(probe: &str) -> bool {
|
||||||
// A leading or trailing space becomes two spaces once the probe sits in its sentence; the
|
// A leading or trailing space becomes two spaces once the probe sits in its sentence; the
|
||||||
// inline constructs (links, wiki links, autolinks, character references) are probed apart.
|
// inline constructs (links, wiki links, autolinks, character references) are probed apart;
|
||||||
|
// the list-item fields refuse the wiki and liquid brackets whole (none in the equine ones).
|
||||||
let tag = probe.match_indices('<').any(|(at, _)| {
|
let tag = probe.match_indices('<').any(|(at, _)| {
|
||||||
probe[at + 1..].starts_with(|c: char| c.is_ascii_alphabetic() || "/!?".contains(c))
|
probe[at + 1..].starts_with(|c: char| c.is_ascii_alphabetic() || "/!?".contains(c))
|
||||||
});
|
});
|
||||||
let construct = tag
|
let construct = tag
|
||||||
|| ["](", "][", "![", "[[ ", " ]]", "&", "`"]
|
|| ["](", "][", "![", "[[", "]]", "{%", "%}", "&", "`"]
|
||||||
.iter()
|
.iter()
|
||||||
.any(|m| probe.contains(m));
|
.any(|m| probe.contains(m));
|
||||||
!construct
|
!construct
|
||||||
@@ -145,6 +146,6 @@ fn every_probe_is_formatted_as_the_typescript_or_refused() {
|
|||||||
"silent differences for {} probes: {silent:?}",
|
"silent differences for {} probes: {silent:?}",
|
||||||
silent.len()
|
silent.len()
|
||||||
);
|
);
|
||||||
assert_eq!(same + refused, 790);
|
assert_eq!(same + refused, 798);
|
||||||
println!("{same} identical, {refused} refused");
|
println!("{same} identical, {refused} refused");
|
||||||
}
|
}
|
||||||
@@ -467,6 +467,23 @@ fn ids_and_field_segments_that_could_forge_report_structure_are_refused() {
|
|||||||
apply_changeset(&frozen["baseline"], &references, &changeset.changes).unwrap_err();
|
apply_changeset(&frozen["baseline"], &references, &changeset.changes).unwrap_err();
|
||||||
assert!(error.to_string().starts_with("CHG-001 op 0:"), "{error}");
|
assert!(error.to_string().starts_with("CHG-001 op 0:"), "{error}");
|
||||||
}
|
}
|
||||||
|
// A segment outside the paths' alphabet: a `]` in a code span closed an author's `[`
|
||||||
|
// (security gate R5.4 round 5).
|
||||||
|
for field in ["name.x]", "name.a b", "name.x*", "name.é"] {
|
||||||
|
let file = serde_json::json!({ "changes": [{
|
||||||
|
"id": "CHG-001", "level": "A", "kind": "technical",
|
||||||
|
"title": { "fr": "Essai [", "en": "Test" }, "rationale": "Essai", "reference_ids": [],
|
||||||
|
"ops": [{ "op": "set", "target": "finding:hip/hip-dysfunctions/mobility",
|
||||||
|
"field": field, "value": "a" }],
|
||||||
|
}]});
|
||||||
|
let changeset = parse_changeset(&to_js_compact(&file).unwrap()).unwrap();
|
||||||
|
let error =
|
||||||
|
apply_changeset(&frozen["baseline"], &references, &changeset.changes).unwrap_err();
|
||||||
|
assert!(
|
||||||
|
error.to_string().contains("segment outside [A-Za-z0-9_-]"),
|
||||||
|
"{field}: {error}"
|
||||||
|
);
|
||||||
|
}
|
||||||
let deep = format!(
|
let deep = format!(
|
||||||
"<svg xmlns=\"http://www.w3.org/2000/svg\">{}{}</svg>",
|
"<svg xmlns=\"http://www.w3.org/2000/svg\">{}{}</svg>",
|
||||||
"<g>".repeat(100_000),
|
"<g>".repeat(100_000),
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"baseline":{"schema_version":2,"species_id":"equine","name":{"fr":"Mini","en":"Mini"},"description":{},"scope_disclaimer":{},"attribution":{"authors":[],"license":null,"notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18}]},"references":[],"categories":[{"id":"joints","name":{"fr":"Articulations","en":"Joints"},"color":null},{"id":"bones","name":{"fr":"Os","en":"Bones"},"color":null}],"views":[{"id":"main","kind":"main","name":{"fr":"Vue","en":"View"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null},{"id":"head","kind":"detail","parent_view_id":"main","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":0,"min_y":0,"width":10,"height":10}}],"annotations":[{"id":"hip","kind":"point","view_id":"main","category_id":"joints","laterality":"bilateral","geometry":{"type":"circle","cx":1,"cy":2,"r":3},"name":{"fr":"Hanche","en":"Hip"},"finding_zone_id":"hip","vertebral_region_code":null},{"id":"neck","kind":"zone","view_id":"main","category_id":"bones","laterality":"unpaired","geometry":null,"name":{"fr":"Cou","en":"Neck"},"finding_zone_id":"neck","vertebral_region_code":"C"},{"id":"head-trigger","kind":"detail_trigger","view_id":"main","category_id":"bones","laterality":"unpaired","geometry":null,"name":null,"opens_view_id":"head"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche","en":"Hip"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions","en":"Dysfunctions"},"children":[{"id":"mobility","name":{"fr":"mobility fr","en":"mobility en"},"children":[{"id":"flexion","name":{"fr":"flexion fr","en":"flexion en"}},{"id":"extension","name":{"fr":"extension fr","en":"extension en"}}]},{"id":"pain","name":{"fr":"pain fr","en":"pain en"}}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse","en":"Anamnesis"},"children":[{"id":"trauma","name":{"fr":"trauma fr","en":"trauma en"}}]}]},{"id":"neck","name":{"fr":"Cou","en":"Neck"},"categories":[{"id":"neck-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions","en":"Dysfunctions"},"children":[{"id":"stiffness","name":{"fr":"stiffness fr","en":"stiffness en"}},{"id":"vet","name":{"fr":"vet fr","en":"vet en"},"requires_vet_referral":true}]}]}]},"references":[{"id":"atlas","type":"book","citation":"Atlas of anatomy","url":null,"doi":null},{"id":"paper","type":"journal","citation":"A paper","url":null,"doi":"10.1/x"}],"legacy_id_map":{"views":{"head":"head"},"annotations":{"legacy-hip":"hip","legacy-neck":"neck"},"categories":{},"finding_nodes":{},"assets":{}},"cases":[{"probe":"*","reference_id":"probe_ref","changes_file":{"changes":[{"id":"CHG-001","level":"C","kind":"correction","title":{"fr":"Titre *","en":"Title"},"rationale":"Raison * fin.","reference_ids":[],"question":"Question * ?","ops":[{"op":"add","target":"document","field":"references","value":{"id":"probe_ref","type":"web","citation":"Citation *","url":null,"doi":null}},{"op":"cite","target":"finding:hip/hip-dysfunctions/mobility","reference_ids":["probe_ref"]},{"op":"set","target":"finding:hip/hip-dysfunctions/mobility","field":"name.en","value":"Label *"},{"op":"set","target":"finding:hip/hip-dysfunctions/mobility/flexion","field":"name.fr","value":"*"}]}]},"changelog_raw_sha256":"77926ee5c69c45be2f9576e04a7e3430b45c203bc667c5f1b51ac3a21e7ae4d9","changelog_sha256":"a84644e09477bf50e413ebe1e8240ccc04657488381b093755d349a35e494843","review_raw_sha256":"a3fc194f01e61c8ae010271894c962b40b8ef4b23987adb9d7712190839734df","review_sha256":"6b2208027f21d2b663a202a8d39accb640f9cae26bbceaa701b2754bdd6f8342"},{"probe":"*x","reference_id":"probe_ref","changes_file":{"changes":[{"id":"CHG-001","level":"C","kind":"correction","title":{"fr":"Titre *x","en":"Title"},"rationale":"Raison *x fin.","reference_ids":[],"question":"Question *x ?","ops":[{"op":"add","target":"document","field":"references","value":{"id":"probe_ref","type":"web","citation":"Citation *x","url":null,"doi":null}},{"op":"cite","target":"finding:hip/hip-dysfunctions/mobility","reference_ids":["probe_ref"]},{"op":"set","target":"finding:hip/hip-dysfunctions/mobility","field":"name.en","value":"Label *x"},{"op":"set","target":"finding:hip/hip-dysfunctions/mobility/flexion","field":"name.fr","value":"*x"}]}]},"changelog_raw_sha256":"a29af5d1b46d52b0de4a334e31e16aa4765c976865fee8ed0b2e00b7f60af4f4","changelog_sha256":"b150e9617d14894c9c33a2c95feab51b4b59245b74a78d48015569ffc300dec3","review_raw_sha256":"0e6605a31ba79a30d66e8ab8fe3858b4c305a816ea7b1e130201e8300611e218","review_sha256":"8693621d140233c9c7708c943621e61586289d0f8a72b93ca2e071eb58a5d45f"},{"probe":"x*","reference_id":"probe_ref","changes_file":{"changes":[{"id":"CHG-001","level":"C","kind":"correction","title":{"fr":"Titre x*","en":"Title"},"rationale":"Raison x* fin.","reference_ids":[],"question":"Question x* ?","ops":[{"op":"add","target":"document","field":"references","valueLine truncated
|
{"baseline":{"schema_version":2,"species_id":"equine","name":{"fr":"Mini","en":"Mini"},"description":{},"scope_disclaimer":{},"attribution":{"authors":[],"license":null,"notes":null},"vertebral_config":{"regions":[{"code":"C","name":{"fr":"Cervicales","en":"Cervical"},"count":7},{"code":"T","name":{"fr":"Thoraciques","en":"Thoracic"},"count":18}]},"references":[],"categories":[{"id":"joints","name":{"fr":"Articulations","en":"Joints"},"color":null},{"id":"bones","name":{"fr":"Os","en":"Bones"},"color":null}],"views":[{"id":"main","kind":"main","name":{"fr":"Vue","en":"View"},"svg_asset_id":"3f6c1b52-8a4e-4d17-9b0c-5e2a7d91c4f8","view_box":null},{"id":"head","kind":"detail","parent_view_id":"main","name":{"fr":"Tête","en":"Head"},"svg_asset_id":null,"view_box":{"min_x":0,"min_y":0,"width":10,"height":10}}],"annotations":[{"id":"hip","kind":"point","view_id":"main","category_id":"joints","laterality":"bilateral","geometry":{"type":"circle","cx":1,"cy":2,"r":3},"name":{"fr":"Hanche","en":"Hip"},"finding_zone_id":"hip","vertebral_region_code":null},{"id":"neck","kind":"zone","view_id":"main","category_id":"bones","laterality":"unpaired","geometry":null,"name":{"fr":"Cou","en":"Neck"},"finding_zone_id":"neck","vertebral_region_code":"C"},{"id":"head-trigger","kind":"detail_trigger","view_id":"main","category_id":"bones","laterality":"unpaired","geometry":null,"name":null,"opens_view_id":"head"}],"finding_zones":[{"id":"hip","name":{"fr":"Hanche","en":"Hip"},"categories":[{"id":"hip-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions","en":"Dysfunctions"},"children":[{"id":"mobility","name":{"fr":"mobility fr","en":"mobility en"},"children":[{"id":"flexion","name":{"fr":"flexion fr","en":"flexion en"}},{"id":"extension","name":{"fr":"extension fr","en":"extension en"}}]},{"id":"pain","name":{"fr":"pain fr","en":"pain en"}}]},{"id":"anamnesis","kind":"anamnesis","name":{"fr":"Anamnèse","en":"Anamnesis"},"children":[{"id":"trauma","name":{"fr":"trauma fr","en":"trauma en"}}]}]},{"id":"neck","name":{"fr":"Cou","en":"Neck"},"categories":[{"id":"neck-dysfunctions","kind":"dysfunction","name":{"fr":"Dysfonctions","en":"Dysfunctions"},"children":[{"id":"stiffness","name":{"fr":"stiffness fr","en":"stiffness en"}},{"id":"vet","name":{"fr":"vet fr","en":"vet en"},"requires_vet_referral":true}]}]}]},"references":[{"id":"atlas","type":"book","citation":"Atlas of anatomy","url":null,"doi":null},{"id":"paper","type":"journal","citation":"A paper","url":null,"doi":"10.1/x"}],"legacy_id_map":{"views":{"head":"head"},"annotations":{"legacy-hip":"hip","legacy-neck":"neck"},"categories":{},"finding_nodes":{},"assets":{}},"cases":[{"probe":"*","reference_id":"probe_ref","changes_file":{"changes":[{"id":"CHG-001","level":"C","kind":"correction","title":{"fr":"Titre *","en":"Title"},"rationale":"Raison * fin.","reference_ids":[],"question":"Question * ?","ops":[{"op":"add","target":"document","field":"references","value":{"id":"probe_ref","type":"web","citation":"Citation *","url":null,"doi":null}},{"op":"cite","target":"finding:hip/hip-dysfunctions/mobility","reference_ids":["probe_ref"]},{"op":"set","target":"finding:hip/hip-dysfunctions/mobility","field":"name.en","value":"Label *"},{"op":"set","target":"finding:hip/hip-dysfunctions/mobility/flexion","field":"name.fr","value":"*"}]}]},"changelog_raw_sha256":"77926ee5c69c45be2f9576e04a7e3430b45c203bc667c5f1b51ac3a21e7ae4d9","changelog_sha256":"a84644e09477bf50e413ebe1e8240ccc04657488381b093755d349a35e494843","review_raw_sha256":"a3fc194f01e61c8ae010271894c962b40b8ef4b23987adb9d7712190839734df","review_sha256":"6b2208027f21d2b663a202a8d39accb640f9cae26bbceaa701b2754bdd6f8342"},{"probe":"*x","reference_id":"probe_ref","changes_file":{"changes":[{"id":"CHG-001","level":"C","kind":"correction","title":{"fr":"Titre *x","en":"Title"},"rationale":"Raison *x fin.","reference_ids":[],"question":"Question *x ?","ops":[{"op":"add","target":"document","field":"references","value":{"id":"probe_ref","type":"web","citation":"Citation *x","url":null,"doi":null}},{"op":"cite","target":"finding:hip/hip-dysfunctions/mobility","reference_ids":["probe_ref"]},{"op":"set","target":"finding:hip/hip-dysfunctions/mobility","field":"name.en","value":"Label *x"},{"op":"set","target":"finding:hip/hip-dysfunctions/mobility/flexion","field":"name.fr","value":"*x"}]}]},"changelog_raw_sha256":"a29af5d1b46d52b0de4a334e31e16aa4765c976865fee8ed0b2e00b7f60af4f4","changelog_sha256":"b150e9617d14894c9c33a2c95feab51b4b59245b74a78d48015569ffc300dec3","review_raw_sha256":"0e6605a31ba79a30d66e8ab8fe3858b4c305a816ea7b1e130201e8300611e218","review_sha256":"8693621d140233c9c7708c943621e61586289d0f8a72b93ca2e071eb58a5d45f"},{"probe":"x*","reference_id":"probe_ref","changes_file":{"changes":[{"id":"CHG-001","level":"C","kind":"correction","title":{"fr":"Titre x*","en":"Title"},"rationale":"Raison x* fin.","reference_ids":[],"question":"Question x* ?","ops":[{"op":"add","target":"document","field":"references","valueLine truncated
|
||||||
+19
-11
@@ -3101,7 +3101,7 @@ Owner go « Validation R5.3 et autorisation conditionnelle R5.4 » (2026-10-23),
|
|||||||
fresh verification of the final R5.3 state: met on c6e0d85 (CONFORME 13/13, security PASS with
|
fresh verification of the final R5.3 state: met on c6e0d85 (CONFORME 13/13, security PASS with
|
||||||
LOWs only, §11.12). Contract `.claude/tasks/contracts/2026-10-23-rust-r5-review.md`.
|
LOWs only, §11.12). Contract `.claude/tasks/contracts/2026-10-23-rust-r5-review.md`.
|
||||||
|
|
||||||
`crates/core/src/curation/draft` gains 1,458 lines (4,366 in all), plus `curation/report_guard.rs` (140):
|
`crates/core/src/curation/draft` gains 1,477 lines (4,385 in all), plus `curation/report_guard.rs` (258):
|
||||||
|
|
||||||
| Module | Ports |
|
| Module | Ports |
|
||||||
|---|---|
|
|---|---|
|
||||||
@@ -3165,28 +3165,35 @@ backslash before `"` or `|` (a JSON quote, the cell escape), `**word**` with one
|
|||||||
between spaces or line edges (the import report's form), and no inline construct (an inline link,
|
between spaces or line edges (the import report's form), and no inline construct (an inline link,
|
||||||
image or reference `](`, `][`; an image reference `![`; a `[[` before a space with a `]]` after
|
image or reference `](`, `][`; an image reference `![`; a `[[` before a space with a `]]` after
|
||||||
it, or a `]]` after a space with a `[[` before it; `<` before a letter, `/`, `!` or `?`: an HTML
|
it, or a `]]` after a space with a `[[` before it; `<` before a letter, `/`, `!` or `?`: an HTML
|
||||||
tag or an autolink; a character reference `&name;`, `&#n;`); no plain underscore followed later on
|
tag or an autolink; a character reference `&name;`, `&#n;`; a liquid bracket `{%` or `%}`); no plain underscore followed later on
|
||||||
its line by one that can close an emphasis (inside a later code span, before anything but an ASCII
|
its line by one that can close an emphasis (inside a later code span, before anything but an ASCII
|
||||||
letter or digit: Prettier's parser paired `to_do … \`ref_\`` across the span); an authored text
|
letter or digit: Prettier's parser paired `to_do … \`ref_\`` across the span); an authored text
|
||||||
holds no backtick (titles, rationales, questions, citations, URLs, DOIs, values), so code spans are
|
holds no backtick (titles, rationales, questions, citations, URLs, DOIs, values), so code spans are
|
||||||
the generator's alone (ids, targets, field names); inside them, anything but a carriage return or
|
written by the generator from ids, targets, field names and file paths; a code span admits only
|
||||||
a tab, never empty, no outer space; a table row with
|
that alphabet, `[A-Za-z0-9_:/. -]`, never empty, no outer space (the template's
|
||||||
another cell count than its header and a control character in a list-item field (title,
|
`pnpm import:equine` holds the one inner space), and a field segment an op names is limited to
|
||||||
rationale, question, citation, URL, DOI, vet-flag value) are refused too. Everything else is
|
`[A-Za-z0-9_-]` (refused at the op otherwise: a `]` there closed an author's `[` across the span);
|
||||||
|
a table row with another cell count than its header is refused; a list-item field (title,
|
||||||
|
rationale, question, citation, URL, DOI, vet-flag value) shares its line with the change's other
|
||||||
|
fields and code spans, so it refuses a control character and any wiki-link or liquid bracket
|
||||||
|
(`[[`, `]]`, `{%`, `%}`) whole, wherever its partner sits on the line (a table cell is parsed on
|
||||||
|
its own and keeps the per-cell rule). Everything else is
|
||||||
refused with `UnsupportedMarkdown`: a character outside the set is refused by default; the forms
|
refused with `UnsupportedMarkdown`: a character outside the set is refused by default; the forms
|
||||||
built from admitted characters are ruled one by one, so a form no rule names and no probe covers
|
built from admitted characters are ruled one by one, so a form no rule names and no probe covers
|
||||||
could still pass.
|
could still pass.
|
||||||
|
|
||||||
The guarantee is empirical, not a proof of Prettier's behaviour: the TypeScript sweep
|
The guarantee is empirical, not a proof of Prettier's behaviour: the TypeScript sweep
|
||||||
(`oracles/r5/markdown-sweep.json`, generator `packages/anatomy/tests/r5.markdown-sweep-oracles.test.ts`,
|
(`oracles/r5/markdown-sweep.json`, generator `packages/anatomy/tests/r5.markdown-sweep-oracles.test.ts`,
|
||||||
digests of the raw and formatted reports) holds 790 probes: 48 characters in six positions,
|
digests of the raw and formatted reports) holds 798 probes: 48 characters in six positions,
|
||||||
whitespace patterns, Markdown constructs, the families each gate round found (strong pairs, URLs,
|
whitespace patterns, Markdown constructs, the families each gate round found (strong pairs, URLs,
|
||||||
non-terminated references, image references, nested padded wiki links, authored code spans and
|
non-terminated references, image references, nested padded wiki links, authored code spans and
|
||||||
underscores paired across them, with the cited reference named `probe_ref` and, for three probes,
|
underscores paired across them, with the cited reference named `probe_ref` and, for three probes,
|
||||||
`probe_ref_`), and 400 strings from a
|
`probe_ref_`; eight construct pairs opened in the title, the rationale and the other fields and
|
||||||
|
closed in the question: `[[`/`]]`, padded and unpadded, `{%`/`%}`, `[x`/`](y)`, `*`, `_`, `<b`/`>`),
|
||||||
|
and 400 strings from a
|
||||||
seeded generator over an alphabet that includes `&#`, `&`, `<`, `![`, `[[` and `]]`, each placed in a title, a rationale, a question, a citation, a label after a
|
seeded generator over an alphabet that includes `&#`, `&`, `<`, `![`, `[[` and `]]`, each placed in a title, a rationale, a question, a citation, a label after a
|
||||||
word and a label alone (a cell start). Result (test `every_probe_is_formatted_as_the_typescript_or_refused`):
|
word and a label alone (a cell start). Result (test `every_probe_is_formatted_as_the_typescript_or_refused`):
|
||||||
279 probes byte for byte with the TypeScript, 511 refused, 0 silent difference; a probe made only
|
268 probes byte for byte with the TypeScript, 530 refused, 0 silent difference; a probe made only
|
||||||
of what the equine reports use, outside the constructs, is never refused (a polygon's
|
of what the equine reports use, outside the constructs, is never refused (a polygon's
|
||||||
`[[10,10],…]`, the DOI's `<0697:toih>` and the URLs' inner underscores pass). The equine reports
|
`[[10,10],…]`, the DOI's `<0697:toih>` and the URLs' inner underscores pass). The equine reports
|
||||||
pass the guard unchanged.
|
pass the guard unchanged.
|
||||||
@@ -3195,7 +3202,7 @@ 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 (combining marks, pictographs, symbols) | 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 |
|
| 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 (combining marks, pictographs, symbols) | 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 |
|
| 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 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 holding a control character (NUL included) or a backtick | 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`) |
|
| 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 |
|
| 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 |
|
||||||
|
|
||||||
The drawing comparison hides nothing (security gate, MEDIUM): the rule fallback of `--check`
|
The drawing comparison hides nothing (security gate, MEDIUM): the rule fallback of `--check`
|
||||||
@@ -3225,7 +3232,8 @@ pipeline, visibly, until the allowlist is widened from new TypeScript probes or
|
|||||||
Markdown printer; the allowlist is proven by probes, not by a model of Prettier: each gate round
|
Markdown printer; the allowlist is proven by probes, not by a model of Prettier: each gate round
|
||||||
of R5.4 found a family the previous rules missed (Markdown syntax, constructs, strong pairs and
|
of R5.4 found a family the previous rules missed (Markdown syntax, constructs, strong pairs and
|
||||||
URLs, then non-terminated references, image references and nested padded wiki links, then
|
URLs, then non-terminated references, image references and nested padded wiki links, then
|
||||||
authored code spans and underscores paired across code spans), each now
|
authored code spans and underscores paired across code spans, then wiki links opened in one field
|
||||||
|
and closed in another and field segments closing an author's bracket from a code span), each now
|
||||||
ruled and frozen in the sweep, so a combination of admitted characters no probe covers could still
|
ruled and frozen in the sweep, so a combination of admitted characters no probe covers could still
|
||||||
differ; the comparison of the application's drawings accepts
|
differ; the comparison of the application's drawings accepts
|
||||||
exactly the trigger-name rule, byte for byte; the frozen
|
exactly the trigger-name rule, byte for byte; the frozen
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
* (a special character in six positions, whitespace patterns, Markdown constructs) is placed
|
* (a special character in six positions, whitespace patterns, Markdown constructs) is placed
|
||||||
* in a change title, rationale and question, a cited reference and a changed label, and the
|
* in a change title, rationale and question, a cited reference and a changed label, and the
|
||||||
* sha256 of the raw and formatted CHANGELOG and REVIEW-REPORT are frozen (400 of the probes
|
* sha256 of the raw and formatted CHANGELOG and REVIEW-REPORT are frozen (400 of the probes
|
||||||
* come from a seeded generator, so unknown classes surface on their own). `MAKE_R5_ORACLES=1` writes
|
* come from a seeded generator, so unknown classes surface on their own; eight pairs open a
|
||||||
|
* construct in one field and close it in the question). `MAKE_R5_ORACLES=1` writes
|
||||||
* crates/core/tests/oracles/r5/markdown-sweep.json.
|
* crates/core/tests/oracles/r5/markdown-sweep.json.
|
||||||
*/
|
*/
|
||||||
import { createHash } from 'node:crypto'
|
import { createHash } from 'node:crypto'
|
||||||
@@ -185,7 +186,19 @@ function probes(): string[] {
|
|||||||
return [...CHARACTERS.flatMap(positions), ...PATTERNS, ...randomProbes(400)]
|
return [...CHARACTERS.flatMap(positions), ...PATTERNS, ...randomProbes(400)]
|
||||||
}
|
}
|
||||||
|
|
||||||
function changesFile(probe: string, referenceId: string) {
|
/** Openers in the title, the rationale and every other field, closers in the question. */
|
||||||
|
const SPLIT = [
|
||||||
|
['[[', ']]'],
|
||||||
|
['[[ a', 'b ]]'],
|
||||||
|
['[[a', 'b]]'],
|
||||||
|
['{%', '%}'],
|
||||||
|
['[x', '](y)'],
|
||||||
|
['*a', 'b*'],
|
||||||
|
['_a', 'b_'],
|
||||||
|
['<b', '>'],
|
||||||
|
]
|
||||||
|
|
||||||
|
function changesFile(probe: string, referenceId: string, closer = probe) {
|
||||||
return {
|
return {
|
||||||
changes: [
|
changes: [
|
||||||
{
|
{
|
||||||
@@ -195,7 +208,7 @@ function changesFile(probe: string, referenceId: string) {
|
|||||||
title: { fr: `Titre ${probe}`, en: 'Title' },
|
title: { fr: `Titre ${probe}`, en: 'Title' },
|
||||||
rationale: `Raison ${probe} fin.`,
|
rationale: `Raison ${probe} fin.`,
|
||||||
reference_ids: [],
|
reference_ids: [],
|
||||||
question: `Question ${probe} ?`,
|
question: `Question ${closer} ?`,
|
||||||
ops: [
|
ops: [
|
||||||
{
|
{
|
||||||
op: 'add',
|
op: 'add',
|
||||||
@@ -232,8 +245,8 @@ function changesFile(probe: string, referenceId: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function run(probe: string, referenceId = 'probe_ref') {
|
async function run(probe: string, referenceId = 'probe_ref', closer = probe) {
|
||||||
const file = changesFile(probe, referenceId)
|
const file = changesFile(probe, referenceId, closer)
|
||||||
const changeset = ChangesetSchema.parse(file)
|
const changeset = ChangesetSchema.parse(file)
|
||||||
const baseline = miniSheet()
|
const baseline = miniSheet()
|
||||||
const result = applyChangeset(baseline, MINI_REFERENCES, changeset)
|
const result = applyChangeset(baseline, MINI_REFERENCES, changeset)
|
||||||
@@ -256,7 +269,7 @@ async function run(probe: string, referenceId = 'probe_ref') {
|
|||||||
legacyAnomalies: [],
|
legacyAnomalies: [],
|
||||||
})
|
})
|
||||||
return {
|
return {
|
||||||
probe,
|
probe: closer === probe ? probe : `${probe}|${closer}`,
|
||||||
reference_id: referenceId,
|
reference_id: referenceId,
|
||||||
changes_file: file,
|
changes_file: file,
|
||||||
changelog_raw_sha256: sha256(changelogRaw),
|
changelog_raw_sha256: sha256(changelogRaw),
|
||||||
@@ -273,6 +286,9 @@ describe('R5.4 Markdown sweep oracle', () => {
|
|||||||
// A cited id ending with `_` puts a closing underscore in a generated code span.
|
// A cited id ending with `_` puts a closing underscore in a generated code span.
|
||||||
for (const probe of ['to_do', 'a_b c', 'x'])
|
for (const probe of ['to_do', 'a_b c', 'x'])
|
||||||
rows.push(await run(probe, 'probe_ref_'))
|
rows.push(await run(probe, 'probe_ref_'))
|
||||||
|
// A construct opened in one field and closed in another of the same line.
|
||||||
|
for (const [opener, closer] of SPLIT)
|
||||||
|
rows.push(await run(opener, 'probe_ref', closer))
|
||||||
const oracle = {
|
const oracle = {
|
||||||
baseline: miniSheet(),
|
baseline: miniSheet(),
|
||||||
references: MINI_REFERENCES,
|
references: MINI_REFERENCES,
|
||||||
|
|||||||
Reference in new issue
Block a user