fix(app): import worker hardenings from the security gate; restore_copy size cap in the core

Page messages validated by field (size and chunk length as safe byte counts, length within
the buffer); the task post wrapped so a refused clone leaves no orphan worker; a second
ready ignored; the 16 MiB copy cap enforced in facade::restore_copy as well as in the
worker (the uncommitted part of R4.3a). Gate verdict PASS, 7 LOW.
This commit is contained in:
bchanot committed 2026-10-18 19:07:06 +02:00
1 parent e0127b0726
commit 8ddf185aa6
4 files changed
+46 -13

No files matched your search

+7 -2
View File
@@ -85,8 +85,13 @@ pub fn import_pdf(sheet: &LoadedSheet, bytes: &[u8]) -> String {
pub fn restore_copy(sheet: &LoadedSheet, bytes: Vec<u8>) -> String {
use crate::domain::session::restore_draft;
use crate::ops::{over_value_budget, restore_failure};
let outcome = String::from_utf8(bytes)
.map_err(|_| Failure::new("invalid", "the copy is not valid UTF-8"))
let outcome = Ok(bytes)
.and_then(|bytes: Vec<u8>| {
if bytes.len() > crate::pdf::read::MAX_ATTACHMENT_BYTES {
return Err(Failure::new("invalid", "the copy is over the size cap"));
}
String::from_utf8(bytes).map_err(|_| Failure::new("invalid", "not valid UTF-8"))
})
.and_then(|text| {
let text = text.strip_prefix('\u{FEFF}').map_or(text.as_str(), |t| t);
if over_value_budget(text) {