fix(domain): R4.5 gate hardenings: self-check without the import size cap, Ref(0) safe, pdf-write implies pdf-read; §10.7 records the gate
This commit is contained in:
1 parent
d2376a4574
commit
b44dd80af2
4 files changed
+26
-9
No files matched your search
@@ -18,7 +18,7 @@ ts = ["dep:ts-rs"]
|
||||
# facade enables it; the worker never does.
|
||||
pdf-read = ["dep:miniz_oxide"]
|
||||
# The PDF writer (R4, plan §B.1.3): layout to a draw log (R4.4), the serialiser (R4.5).
|
||||
pdf-write = []
|
||||
pdf-write = ["pdf-read"]
|
||||
|
||||
[dependencies]
|
||||
serde.workspace = true
|
||||
|
||||
@@ -12,7 +12,7 @@ use super::serialize::{Document, Metadata, export_date, serialize};
|
||||
use crate::domain::archive::{EnvelopeFormat, EnvelopeVersion1, Locale, ReportArchiveEnvelope};
|
||||
use crate::json::to_js_pretty;
|
||||
use crate::pdf::read::MAX_ATTACHMENT_BYTES;
|
||||
use crate::pdf::read::probe::{ProbeLimits, read_attached_document};
|
||||
use crate::pdf::read::probe::{ProbeLimits, locate_attachment};
|
||||
|
||||
/// What an export gives back: the file, the envelope text it carries and the warnings.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
@@ -49,13 +49,14 @@ fn envelope_text(input: &CheckedInput) -> Result<String, ExportError> {
|
||||
}
|
||||
|
||||
/// `finish()` re-reads its own output: one scan and one inflation, the attachment's text
|
||||
/// against the envelope written.
|
||||
/// against the envelope written. The scan runs without the reader's 50 MiB file cap: a
|
||||
/// larger export (a report near the caps with real rasters) is a valid file that the import
|
||||
/// refuses by size, as the TypeScript's did (plan §B.1.2); the export is not where to refuse it.
|
||||
fn self_check(pdf: &[u8], envelope: &str) -> Result<(), ExportError> {
|
||||
let located =
|
||||
read_attached_document(pdf, ProbeLimits::PRODUCTION).map_err(|kind| ExportError {
|
||||
kind: ExportErrorKind::SelfCheckFailed,
|
||||
detail: kind.as_str().to_owned(),
|
||||
})?;
|
||||
let located = locate_attachment(pdf, ProbeLimits::PRODUCTION).map_err(|kind| ExportError {
|
||||
kind: ExportErrorKind::SelfCheckFailed,
|
||||
detail: kind.as_str().to_owned(),
|
||||
})?;
|
||||
if located.text != envelope {
|
||||
return Err(ExportError {
|
||||
kind: ExportErrorKind::SelfCheckFailed,
|
||||
|
||||
@@ -34,7 +34,7 @@ impl Objects {
|
||||
}
|
||||
|
||||
pub fn set(&mut self, at: Ref, body: Vec<u8>) {
|
||||
if let Some(slot) = self.bodies.get_mut(at.0 - 1) {
|
||||
if let Some(slot) = at.0.checked_sub(1).and_then(|i| self.bodies.get_mut(i)) {
|
||||
*slot = body;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1581,6 +1581,22 @@ shipped module, inside the plan's estimate (+100 to 150 KB) and under 600 KB;
|
||||
above 550 KB it is to be reported, so R4.6 measures the shipped module again
|
||||
once the session links the writer.
|
||||
|
||||
Independent security gate (R4.5): PASS, 4 LOW, no blocker. Its probe ran
|
||||
131,648 mutated or synthetic PNGs through the gate and the decoder (0 panic,
|
||||
0 overflow, slowest 198 ms), 6.7 million rounds over the base64, date and
|
||||
number helpers, and hostile exports: report names holding PDF syntax reach
|
||||
the file as hex only (0 raw occurrence, `qpdf --check` clean, every `/Length`
|
||||
and xref offset exact), hostile URLs and `exportedAt` refused. Applied: the
|
||||
self-check scans without the reader's 50 MiB file cap (an export above it is
|
||||
a valid file the import refuses by size, as before); `Ref(0)` cannot
|
||||
underflow; `pdf-write` implies `pdf-read`. Reported: the self-check proves
|
||||
the attachment and the reader's read only (poppler covers the rendering of
|
||||
the corpus); the external-tools test skips on a host without qpdf and
|
||||
poppler (it ran here); the one-shot path holds each PNG twice and the file
|
||||
twice at the end (R4.6 input, OD-2); a view raster whose header reads but
|
||||
whose body fails to decode fails the export as `self_check_failed` where R4.6
|
||||
makes it a per-key `view_raster_failed` warning.
|
||||
|
||||
Residual risks and open points (R4.5):
|
||||
|
||||
- The one-shot export of L with real rasters is slow (5 s native, dominated
|
||||
|
||||
Reference in new issue
Block a user