corvus_json_schema 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31371364d14a0b654889fc47b325553d0c8c0851da6acdf8a32794704aca30d5
4
- data.tar.gz: a5769ffed7a3d92f28959821e68890acfcedb84afe072771416a2ca602b023aa
3
+ metadata.gz: c49a0e22cb2d5d434a1cc48ff218ee2d8a1c75e12721672f8555ec1d7829ea4e
4
+ data.tar.gz: da2296f3cf10c8b9cd4e55c5455c4e159ba447530eaafaeda3d1692893d2b71a
5
5
  SHA512:
6
- metadata.gz: 7410802842bb6dcbf949cf63cba86c429430e4aa8a8fe901fbe30a2ff9ff475278c64440e84296795f0f25528fc43780e0c1b46a6c46552ca930ae9a8085d1a5
7
- data.tar.gz: 5221fd2ea871f4ec29864c29e975ff623c75d85afe36a5a1a9fad86f39eb9d5a1cb886d3c261f00792eb515589c49f5ce5a246471ad5c2e0befc0dd5853fbc93
6
+ metadata.gz: 131e37b22d753a2c9bd803a333a014796fd9dd0cf66f91a87f83d442b9afb34d6d60960da00d62c213be2e502634e96dcb6222a6f07395b1b245c9a23456a63b
7
+ data.tar.gz: 77e5b94a420597102e3c70d138778f9ad0744efdda767d258d47a20131b8b06a9aa571c4c159b8136180693c3c70623aa352d6863b0274e68bff7f340d456916
data/Cargo.lock CHANGED
@@ -63,7 +63,7 @@ dependencies = [
63
63
 
64
64
  [[package]]
65
65
  name = "corvus-json-schema"
66
- version = "0.1.4"
66
+ version = "0.1.6"
67
67
  dependencies = [
68
68
  "regex",
69
69
  "regress",
@@ -72,7 +72,7 @@ dependencies = [
72
72
 
73
73
  [[package]]
74
74
  name = "corvus_json_schema"
75
- version = "0.1.1"
75
+ version = "0.1.3"
76
76
  dependencies = [
77
77
  "corvus-json-schema",
78
78
  "magnus",
data/README.md CHANGED
@@ -11,7 +11,7 @@ standalone evaluator.
11
11
  validated without creating Ruby objects for it.
12
12
  - **Precompiled**: native gems for Linux (x86_64 and aarch64, glibc and musl), macOS (x86_64 and arm64) and Windows
13
13
  (x64), for Ruby 3.3, 3.4 and 4.0. On other platforms the source gem builds the extension, which needs a Rust
14
- toolchain (1.85 or later) and libclang.
14
+ toolchain (1.89 or later) and libclang.
15
15
 
16
16
  ## Install
17
17
 
data/VERSIONHISTORY.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  The version history of the `corvus_json_schema` Ruby gem. It is versioned independently of the Corvus NuGet packages and of the [corvus-json-schema](../../src-rs/corvus-json-schema/VERSIONHISTORY.md) Rust crate it is built on.
4
4
 
5
+ ## V0.1.3
6
+
7
+ V0.1.3 fixes `gem install corvus_json_schema` on Alpine Linux and other musl systems, where RubyGems before 4.0 could install the glibc gem, which does not load there. There are no API changes, and the extension is the one in 0.1.2. Versions 0.1.0 to 0.1.2 are affected.
8
+
9
+ ### Bug fixes
10
+
11
+ - **`gem install` on a musl system with RubyGems before 4.0 (the RubyGems of Ruby 3.3 and 3.4).** The precompiled glibc gems had the platforms `x86_64-linux` and `aarch64-linux`. On a musl Ruby, those versions of RubyGems rank such a gem equal to the musl gem (`x86_64-linux-musl`) and install whichever comes last in their own ordering. Since 0.1.1 was published that has been the glibc gem, and `require "corvus_json_schema"` then failed with a `LoadError` naming `ld-linux-x86-64.so.2`. The glibc gems now have the platforms `x86_64-linux-gnu` and `aarch64-linux-gnu`, which RubyGems does not offer to a musl Ruby at all, so the musl gem is the one installed. Bundler was not affected, and neither was any glibc system, macOS or Windows.
12
+
13
+ The earlier versions stay as they are. On a musl system with RubyGems before 4.0, install 0.1.3 or later, or install an earlier version with Bundler.
14
+
15
+ ## V0.1.2
16
+
17
+ V0.1.2 fixes a crash of the Ruby process for a schema whose `not` leads back to the schema it is in, by taking version 0.1.6 of the corvus-json-schema crate. There are no API changes. Versions 0.1.0 and 0.1.1 are affected.
18
+
19
+ ### Bug fixes
20
+
21
+ - **A `not` that leads back to the schema it is in.** A schema can loop without consuming the instance. The gem abandons such an evaluation at `max_depth` (128 by default) and raises `CorvusJsonSchema::DepthError`. Evaluating `not` went around that guard. For a schema such as `{"not": {"$ref": "#"}}`, validating an instance that reached the `not` recursed in the native extension until the stack overflowed, which crashes the Ruby process. `valid?`, `valid_json?` and `evaluate` were all affected. A `not` is now under the guard, so they raise `CorvusJsonSchema::DepthError`. The fault is in the schema. No instance causes it for a schema without such a loop, so a program was exposed only if it compiled schemas it did not write. A schema that loops elsewhere under a `not` was not affected in this gem: it raised `CorvusJsonSchema::DepthError`, and still does.
22
+
5
23
  ## V0.1.1
6
24
 
7
25
  V0.1.1 fixes wrong validation results for one form of pattern, by taking version 0.1.4 of the corvus-json-schema crate. There are no API changes. Version 0.1.0 is affected.
@@ -1,8 +1,8 @@
1
1
  [package]
2
2
  name = "corvus_json_schema"
3
- version = "0.1.1"
3
+ version = "0.1.3"
4
4
  edition = "2024"
5
- rust-version = "1.85"
5
+ rust-version = "1.89"
6
6
  description = "The native extension of the corvus_json_schema gem: the corvus-json-schema crate, reading Ruby values in place."
7
7
  license = "Apache-2.0"
8
8
  publish = false
@@ -12,7 +12,7 @@ crate-type = ["cdylib"]
12
12
 
13
13
  [dependencies]
14
14
  # The crate, copied in by `rake vendor` (from src-rs/corvus-json-schema) so that the source gem builds on its own.
15
- corvus = { package = "corvus-json-schema", path = "vendor/corvus-json-schema", version = "0.1.4" }
15
+ corvus = { package = "corvus-json-schema", path = "vendor/corvus-json-schema", version = "0.1.6" }
16
16
  magnus = { version = "0.9.1", features = ["rb-sys"] }
17
17
  rb-sys = "0.9.130"
18
18
  serde_json = { version = "1.0.151", features = ["preserve_order", "float_roundtrip"] }
@@ -0,0 +1,4 @@
1
+ # Clippy suggests idioms by the minimum Rust version. The declared minimum (rust-version in Cargo.toml) was corrected
2
+ # from 1.85 to 1.89 with no change to the source, so the lints stay at the level the source was written to. Raise this
3
+ # when the source is next revised for the newer idioms.
4
+ msrv = "1.85"
@@ -1,8 +1,8 @@
1
1
  [package]
2
2
  name = "corvus-json-schema"
3
- version = "0.1.4"
3
+ version = "0.1.6"
4
4
  edition = "2024"
5
- rust-version = "1.85"
5
+ rust-version = "1.89"
6
6
  description = "A high-performance JSON Schema evaluator (draft 4 to 2020-12) with results collection and annotations, ported from the Corvus.Text.Json V5 runtime evaluator."
7
7
  license = "Apache-2.0"
8
8
  repository = "https://github.com/corvus-dotnet/Corvus.JsonSchema"
@@ -1268,7 +1268,8 @@ impl Evaluator<'_, '_> {
1268
1268
  }
1269
1269
  matched == 1
1270
1270
  }
1271
- Op::Not(c) => !self.run(*c, x),
1271
+ // Under the depth guard, like every other in-place applicator: a not can be part of a cycle too.
1272
+ Op::Not(c) => !self.run_in_place(*c, x),
1272
1273
  Op::DynamicRef(d) => {
1273
1274
  let target = self.p.fast_target[self.resolve_dynamic(d) as usize];
1274
1275
  self.run_in_place(target, x)
@@ -597,7 +597,9 @@ impl<'p, 'c> Evaluator<'p, 'c> {
597
597
  /// Evaluates the program's entry in fast mode.
598
598
  pub fn validate<'x, I: Instance<'x>>(&mut self, x: I) -> bool {
599
599
  let root = self.p.fast_target[self.p.root as usize];
600
- self.fast(root, x)
600
+ // An evaluation that recursed in place beyond the maximum depth is not valid, whatever it came to: the
601
+ // branch that was abandoned counts as false, which a not above it turns into true.
602
+ self.fast(root, x) && !self.depth_exceeded
601
603
  }
602
604
 
603
605
  /// Fail-fast evaluation of a node, through its plan when there are plans.
@@ -1413,16 +1415,28 @@ impl<'p, 'c> Evaluator<'p, 'c> {
1413
1415
  check!(self, M, ok, matched == 1, Message::Static(message), "oneOf");
1414
1416
  }
1415
1417
  if let Some(not) = n.not {
1416
- // Not elided, never contributes results or evaluated properties/items.
1417
- let inner = if M::COLLECT {
1418
+ // Not elided, never contributes results or evaluated properties/items. A not on an in-place cycle is
1419
+ // under the depth guard, like every other in-place applicator.
1420
+ let target = if M::COLLECT { not } else { self.p.fast_target[not as usize] };
1421
+ let guarded = self.node(target).in_place_cycle;
1422
+ if guarded {
1423
+ self.depth += 1;
1424
+ }
1425
+ let inner = if guarded && self.depth > self.p.max_depth {
1426
+ self.depth_exceeded = true;
1427
+ false
1428
+ } else if M::COLLECT {
1418
1429
  let pointer = &self.node(not).pointer;
1419
1430
  self.col().begin_child_context(Some("not"), Some(pointer), None);
1420
1431
  let inner = self.eval_node::<Collect, I>(not, x, None);
1421
1432
  self.col().pop_child_context();
1422
1433
  inner
1423
1434
  } else {
1424
- self.fast(self.p.fast_target[not as usize], x)
1435
+ self.fast(target, x)
1425
1436
  };
1437
+ if guarded {
1438
+ self.depth -= 1;
1439
+ }
1426
1440
  check!(self, M, ok, !inner, Message::Static(if inner { MATCHED_NOT } else { DID_NOT_MATCH_NOT }), "not");
1427
1441
  }
1428
1442
  if let Some(cond_node) = n.if_ {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CorvusJsonSchema
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: corvus_json_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - endjin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-08 00:00:00.000000000 Z
11
+ date: 2026-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb_sys
@@ -39,6 +39,7 @@ files:
39
39
  - README.md
40
40
  - VERSIONHISTORY.md
41
41
  - ext/corvus_json_schema/Cargo.toml
42
+ - ext/corvus_json_schema/clippy.toml
42
43
  - ext/corvus_json_schema/extconf.rb
43
44
  - ext/corvus_json_schema/rustfmt.toml
44
45
  - ext/corvus_json_schema/src/lib.rs