Skip to content

Commit 108b3e0

Browse files
committed
fix(yaml): scale the scalar-byte budget for machine-written reports
from_report_str scaled node and event limits with input length but left max_total_scalar_bytes at serde-saphyr's 64 MiB default, so a report with more than 64 MiB of string content (reachable via the a2ml bundle loader, which reads whole files) would still be rejected. Scale it the same way; alias limits stay at their defaults. Addresses CodeRabbit review on #234. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PFaqv6iBXrt3W5Akd1Fq5k
1 parent afc1be0 commit 108b3e0

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎src/yaml.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//! `serde-saphyr` enforces resource budgets while parsing. Its defaults
77
//! suit hand-written configs (attack profiles, timelines, mutation specs),
88
//! but its 250k-node cap rejects YAML reports from large scans (roughly
9-
//! 15k files). Machine-written reports therefore get a node and event
10-
//! budget proportional to the input length instead: an alias-free document
9+
//! 15k files). Machine-written reports therefore get node, event and
10+
//! scalar-byte budgets proportional to the input length instead: an alias-free document
1111
//! cannot have more nodes than bytes, so the cap still bounds alias
1212
//! expansion while accepting any report the caller's read limit allows.
1313
@@ -27,6 +27,7 @@ pub fn from_report_str<T: DeserializeOwned>(input: &str) -> Result<T, serde_saph
2727
let mut budget = Budget::default();
2828
budget.max_nodes = defaults.max_nodes.max(input.len());
2929
budget.max_events = defaults.max_events.max(input.len());
30+
budget.max_total_scalar_bytes = defaults.max_total_scalar_bytes.max(input.len());
3031
let mut options = Options::default();
3132
options.budget = Some(budget);
3233
serde_saphyr::from_str_with_options(input, options)

0 commit comments

Comments
 (0)