[PR #7592] A capping limit and a block_rot integrity are bounded at decode #7698

Open
opened 2026-11-03 07:22:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7592
Author: @MSedgeMC
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: fix/processor-decode-bounds


📝 Commits (2)

  • f17bec8 fix: a capping limit and a block_rot integrity are bounded at decode
  • 0186dde test: the processor fields vanilla refuses out of range

📊 Changes

2 files changed (+156 additions, -5 deletions)

View changed files

📝 crates/horizon-world/src/worldgen/structure/processor.rs (+22 -5)
➕ crates/horizon-world/tests/processor_bounds.rs (+134 -0)

📄 Description

Processor::decode (crates/horizon-world/src/worldgen/structure/processor.rs) read two processor fields with no bound. Vanilla bounds both in the processor's own type codec, at decode: a data pack it refuses loaded here.

Vanilla

CappedProcessor.lambda$static$0, the limit field:

19: getstatic  #155  // Field net/minecraft/util/valueproviders/IntProviders.POSITIVE_CODEC
22: ldc        #160  // String limit
24: invokeinterface #139, 2  // Codec.fieldOf

IntProviders static init:

62: iconst_1
63: ldc        #168  // int 2147483647
65: invokestatic #169 // Method codec:(II)Lcom/mojang/serialization/Codec;
68: putstatic    #176 // Field POSITIVE_CODEC

and IntProviders.validate(min, max, provider) errors when provider.minInclusive() < min (1) or provider.maxInclusive() > max. So a limit of 0, of -1, of a uniform from 0, or of any provider whose range reaches below 1 is an error, not a capping processor that never keeps a block.

BlockRotProcessor.lambda$static$0, the integrity field:

22: fconst_0
23: fconst_1
24: invokestatic #102 // InterfaceMethod com/mojang/serialization/Codec.floatRange:(FF)Lcom/mojang/serialization/Codec;
27: ldc          #106 // String integrity
29: invokeinterface #107, 2 // Codec.fieldOf

Codec.floatRange is a fieldOf plus a -1/1 comparison: a value outside 0..=1 (or a NaN) fails the pack. The field is already required here, so only the range was missing.

What Horizon got wrong

"minecraft:block_rot" => Self::BlockRot {
    ...
    integrity: float(value, "integrity")?,          // any float
},
"minecraft:capped" => Self::Capped {
    ...
    limit: IntProvider::from_json(&value["limit"].to_string())?,   // any provider
},

float only checks that the field is a number and IntProvider::from_json only decodes the provider, so a list with "integrity": -1 rotted every block of the template, one with "integrity": 2 kept all of them, and one with "limit": 0 ran a capping processor that kept nothing — where vanilla refuses to load the pack and the structure keeps the list it had.

Now integrity is read through a float_range helper (vanilla's Codec.floatRange) and limit is checked against bounds()[0] >= 1 (vanilla's POSITIVE_CODEC), both the way DiskFeature's radius and half height already gate theirs.

Proven

cargo test -p horizon-world --test processor_bounds:

  • a_capping_limit_must_be_positive: without the bound, "limit": 0 decodes — the test panics on 0 at the first refusing case. With the fix it is a decode error, and so are -1, uniform 0..=3, biased_to_bottom -2..=2 and a weighted_list whose only entry is constant 0; 1, 7 and uniform 1..=3 still decode, and their bounds()[0] stays at or above 1.
  • block_rot_integrity_is_a_fraction: without the range, "integrity": -1 decodes — the test panics on -1. With the fix it is a decode error, and so are -0.01, 1.01, 2 and "half"; 0, 0.5 and 1 still decode inside the fraction.

The list each test decodes is a real ProcessorList::decode over a four-state registry, not the two helpers.

cargo test -q -p horizon-world --lib passes (318 passed, 2 ignored); cargo clippy -q -p horizon-world --lib prints nothing; rustfmt --edition 2024 --check is clean.

Not proven

  • No data pack in this repository ships a processor list with an out-of-range limit or integrity, so the reproduction is the two tests rather than a generated world. What the leniency cost is visible all the same: where vanilla's resource reload reports the list as invalid (the pack does not load, so the structure referencing it does not generate), Horizon quietly built a capping processor that keeps nothing or a block_rot that keeps every block.
  • StructureProcessorList's own codec (processors as a required field) is still lenient here: ProcessorList::decode also accepts a lone processor object, which Lithostitched's list holders use, so requiring the field would refuse that form. Left as it is.
  • No port_map row changed: the processors' processBlock/test rows already read port, and the codec methods are not in the verdict map (codecs are java plumbing there).

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/7592 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/processor-decode-bounds` --- ### 📝 Commits (2) - [`f17bec8`](https://github.com/horizon-rust/horizon/commit/f17bec84991a903cded0b6641d7a9e2d57fc53f5) fix: a capping limit and a block_rot integrity are bounded at decode - [`0186dde`](https://github.com/horizon-rust/horizon/commit/0186ddecf0065ab4ae99ffe0466b4fbbde82b29d) test: the processor fields vanilla refuses out of range ### 📊 Changes **2 files changed** (+156 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-world/src/worldgen/structure/processor.rs` (+22 -5) ➕ `crates/horizon-world/tests/processor_bounds.rs` (+134 -0) </details> ### 📄 Description `Processor::decode` (`crates/horizon-world/src/worldgen/structure/processor.rs`) read two processor fields with no bound. Vanilla bounds both in the processor's own type codec, at decode: a data pack it refuses loaded here. ## Vanilla `CappedProcessor.lambda$static$0`, the `limit` field: ``` 19: getstatic #155 // Field net/minecraft/util/valueproviders/IntProviders.POSITIVE_CODEC 22: ldc #160 // String limit 24: invokeinterface #139, 2 // Codec.fieldOf ``` `IntProviders` static init: ``` 62: iconst_1 63: ldc #168 // int 2147483647 65: invokestatic #169 // Method codec:(II)Lcom/mojang/serialization/Codec; 68: putstatic #176 // Field POSITIVE_CODEC ``` and `IntProviders.validate(min, max, provider)` errors when `provider.minInclusive() < min` (1) or `provider.maxInclusive() > max`. So a `limit` of `0`, of `-1`, of a `uniform` from `0`, or of any provider whose range reaches below 1 is an error, not a capping processor that never keeps a block. `BlockRotProcessor.lambda$static$0`, the `integrity` field: ``` 22: fconst_0 23: fconst_1 24: invokestatic #102 // InterfaceMethod com/mojang/serialization/Codec.floatRange:(FF)Lcom/mojang/serialization/Codec; 27: ldc #106 // String integrity 29: invokeinterface #107, 2 // Codec.fieldOf ``` `Codec.floatRange` is a `fieldOf` plus a `-1`/`1` comparison: a value outside `0..=1` (or a NaN) fails the pack. The field is already required here, so only the range was missing. ## What Horizon got wrong ```rust "minecraft:block_rot" => Self::BlockRot { ... integrity: float(value, "integrity")?, // any float }, "minecraft:capped" => Self::Capped { ... limit: IntProvider::from_json(&value["limit"].to_string())?, // any provider }, ``` `float` only checks that the field is a number and `IntProvider::from_json` only decodes the provider, so a list with `"integrity": -1` rotted every block of the template, one with `"integrity": 2` kept all of them, and one with `"limit": 0` ran a capping processor that kept nothing — where vanilla refuses to load the pack and the structure keeps the list it had. Now `integrity` is read through a `float_range` helper (vanilla's `Codec.floatRange`) and `limit` is checked against `bounds()[0] >= 1` (vanilla's `POSITIVE_CODEC`), both the way `DiskFeature`'s radius and half height already gate theirs. ## Proven `cargo test -p horizon-world --test processor_bounds`: - `a_capping_limit_must_be_positive`: without the bound, `"limit": 0` decodes — the test panics on `0` at the first refusing case. With the fix it is a decode error, and so are `-1`, `uniform 0..=3`, `biased_to_bottom -2..=2` and a `weighted_list` whose only entry is `constant 0`; `1`, `7` and `uniform 1..=3` still decode, and their `bounds()[0]` stays at or above 1. - `block_rot_integrity_is_a_fraction`: without the range, `"integrity": -1` decodes — the test panics on `-1`. With the fix it is a decode error, and so are `-0.01`, `1.01`, `2` and `"half"`; `0`, `0.5` and `1` still decode inside the fraction. The list each test decodes is a real `ProcessorList::decode` over a four-state registry, not the two helpers. `cargo test -q -p horizon-world --lib` passes (318 passed, 2 ignored); `cargo clippy -q -p horizon-world --lib` prints nothing; `rustfmt --edition 2024 --check` is clean. ## Not proven - No data pack in this repository ships a processor list with an out-of-range `limit` or `integrity`, so the reproduction is the two tests rather than a generated world. What the leniency cost is visible all the same: where vanilla's resource reload reports the list as invalid (the pack does not load, so the structure referencing it does not generate), Horizon quietly built a capping processor that keeps nothing or a block_rot that keeps every block. - `StructureProcessorList`'s own codec (`processors` as a required field) is still lenient here: `ProcessorList::decode` also accepts a lone processor object, which Lithostitched's list holders use, so requiring the field would refuse that form. Left as it is. - No `port_map` row changed: the processors' `processBlock`/`test` rows already read `port`, and the codec methods are not in the verdict map (codecs are java plumbing there). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#7698
No description provided.