gitlab-glaz 1.1.0-aarch64-linux-gnu → 1.2.0-aarch64-linux-gnu

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: a34e47f4e6d8bc276183c499c4b0122948b035c057df7817cc7ea748168b5e57
4
- data.tar.gz: 6fd028ef41f5598da88bd7828caf054c5c00688e4a5745e9cc87779ddd974868
3
+ metadata.gz: 18b1b82dc6360aba27c4c1c9a5efde8c037f3a2f0e633f03a2a0eb7852ecd058
4
+ data.tar.gz: 4411a15f95cf16401a473ab34301c2e0bc3813bda01e9ffc4487f3b5247d1fcc
5
5
  SHA512:
6
- metadata.gz: 7437a84501da6bd77a6a3a7e6ef7014545ae457100e875dbb0c300324de8e05c6050885460e59f5bd62e766f93729380a3863b0bff1e8383e842d8d28cae86fd
7
- data.tar.gz: 3714eec5f299d900f2df381fba2fe5ec3617bdaa0078c3982a53827bd4ce8550b0f9d1a9ee56044a14603c3e007577406a7ab7ec947d1872927f24c8495d8ef3
6
+ metadata.gz: b0446f66f110d319461ba3f55f0ddf2bee06679edf959794c9c6e7f2a7ec4ae62017876c051422c54ced685dd841b6c8ceff775291b30c4b2118d23253d10cbb
7
+ data.tar.gz: 8eb363311d4e9b93968020d9ce29716fc1cdd0a61f19a35e81641fd5cde7181b63101a6271236b22a174720dcba9d8ad16d1f6dfe861c001af4ada01f25b1de0
data/Cargo.lock CHANGED
@@ -646,7 +646,7 @@ dependencies = [
646
646
 
647
647
  [[package]]
648
648
  name = "glaz"
649
- version = "1.1.0"
649
+ version = "1.2.0"
650
650
  dependencies = [
651
651
  "glaz-module",
652
652
  "glaz-proto",
@@ -1716,18 +1716,18 @@ checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"
1716
1716
 
1717
1717
  [[package]]
1718
1718
  name = "rb-sys"
1719
- version = "0.9.128"
1719
+ version = "0.9.130"
1720
1720
  source = "registry+https://github.com/rust-lang/crates.io-index"
1721
- checksum = "45ca28513560e56cfb79a62b1fce363c73af170a182024ce880c77ee9429920a"
1721
+ checksum = "02faf625bb10ba893e3ae620f19c9fb1b5f8fcae0fe4eb86bb3f2230fad75edb"
1722
1722
  dependencies = [
1723
1723
  "rb-sys-build",
1724
1724
  ]
1725
1725
 
1726
1726
  [[package]]
1727
1727
  name = "rb-sys-build"
1728
- version = "0.9.128"
1728
+ version = "0.9.130"
1729
1729
  source = "registry+https://github.com/rust-lang/crates.io-index"
1730
- checksum = "ce04b2c55eff3a21aaa623fcc655d94373238e72cac6b3e1a3641ff31649f99a"
1730
+ checksum = "05be6f9c86fe5482808162826f6c047d093b3670582296c770de1d94f8066694"
1731
1731
  dependencies = [
1732
1732
  "bindgen",
1733
1733
  "lazy_static",
data/Cargo.toml CHANGED
@@ -4,7 +4,7 @@ members = ["ext/*"]
4
4
  resolver = "2"
5
5
 
6
6
  [workspace.package]
7
- version = "1.1.0"
7
+ version = "1.2.0"
8
8
  edition = "2024"
9
9
 
10
10
  # Shared dependencies for all crates
data/ext/glaz/src/lib.rs CHANGED
@@ -53,13 +53,18 @@ impl PermissionCheckEngine {
53
53
  }
54
54
 
55
55
  /// Thin 1:1 wrapper around `glaz_module::GovernPolicyCheckEngine`, the Rego
56
- /// governance evaluator. Stateless between calls; both methods take an
57
- /// encoded `glaz.govern.v1.EvaluateGovernPolicyRequest`. `evaluate` raises
58
- /// on failure (matching `PermissionCheckEngine`'s convention) and returns
59
- /// the encoded `EvaluateGovernPolicyResponse` on success `ArgumentError`
60
- /// for bad policy/input, `RuntimeError` for an engine-side fault, see
56
+ /// governance evaluator. Stateless between calls; `evaluate` raises on
57
+ /// failure (matching `PermissionCheckEngine`'s convention) and returns the
58
+ /// encoded `EvaluateGovernPolicyResponse` on success `ArgumentError` for
59
+ /// bad policy/input, `RuntimeError` for an engine-side fault, see
61
60
  /// `map_error`; `debug_evaluate` is infallible and carries failures in-band
62
- /// in its JSON response instead, since it's a raw debugging escape hatch.
61
+ /// in its JSON response instead, since it's a raw debugging escape hatch;
62
+ /// `validate` is also infallible — policy errors are returned as
63
+ /// `Ok(valid: false, errors: [...])` so the Policy Store can surface
64
+ /// actionable feedback without treating a user mistake as an exceptional
65
+ /// condition; a malformed protobuf payload raises `ArgumentError`, while
66
+ /// internal engine failures (`NotInitialized`, `Runtime`) raise
67
+ /// `RuntimeError` via `map_error`.
63
68
  ///
64
69
  /// Registered as `Glaz::Native::GovernPolicyEngine` (not
65
70
  /// `Glaz::GovernPolicyEngine`) specifically to avoid colliding, in name,
@@ -113,6 +118,25 @@ impl GovernPolicyEngine {
113
118
  .map_err(|e| map_error(ruby, e))?;
114
119
  Ok(ruby.str_from_slice(&response.encode_to_vec()))
115
120
  }
121
+
122
+ /// Parse and compile a Rego policy without evaluating it against input.
123
+ ///
124
+ /// Infallible for policy errors: parse failures and oversized input are
125
+ /// returned in-band as `{ valid: false, errors: [...] }` rather than
126
+ /// raised. Only a malformed protobuf payload raises `ArgumentError`; an
127
+ /// internal engine fault raises `RuntimeError` via `map_error`.
128
+ fn validate(
129
+ ruby: &Ruby,
130
+ rb_self: &Self,
131
+ proto_bytes: magnus::RString,
132
+ ) -> Result<magnus::RString, Error> {
133
+ let bytes = unsafe { proto_bytes.as_slice() };
134
+ let response = rb_self
135
+ .engine
136
+ .validate(bytes)
137
+ .map_err(|e| map_error(ruby, e))?;
138
+ Ok(ruby.str_from_slice(&response.encode_to_vec()))
139
+ }
116
140
  }
117
141
 
118
142
  /// Return the default roles embedded in the extension at build time (parsed
@@ -172,5 +196,6 @@ fn init(ruby: &Ruby) -> Result<(), Error> {
172
196
  magnus::method!(GovernPolicyEngine::debug_evaluate, 1),
173
197
  )?;
174
198
  govern.define_method("evaluate", magnus::method!(GovernPolicyEngine::evaluate, 1))?;
199
+ govern.define_method("validate", magnus::method!(GovernPolicyEngine::validate, 1))?;
175
200
  Ok(())
176
201
  }
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -83,6 +83,39 @@ module Gitlab
83
83
  }
84
84
  end
85
85
 
86
+ # Validate a Rego policy at save time without evaluating it against input.
87
+ #
88
+ # Parses and compiles the policy source. A policy that fails to parse is
89
+ # not an error - it is returned as `{ valid: false, errors: [...] }` so
90
+ # the Policy Store can surface actionable feedback without treating a user
91
+ # mistake as an exceptional condition.
92
+ #
93
+ # @param policy_rego [String] Rego policy source text (UTF-8, max 64 KiB).
94
+ # Must be a valid UTF-8 string; raises `Encoding::InvalidByteSequenceError`
95
+ # if the string contains invalid byte sequences.
96
+ # @return [Hash] `{ valid: Boolean, errors: Array<Hash> }`.
97
+ # `valid` is `true` when the policy parsed and compiled successfully.
98
+ # `errors` is empty when valid; each entry is
99
+ # `{ message: String, location: String }` where `location` is a
100
+ # source-location hint in `"LINE:COL"` format (e.g. `"2:1"`) when the
101
+ # engine surfaces one, or `""` when no separate location is available.
102
+ def validate(policy_rego:)
103
+ encoded = ::Glaz::Govern::V1::ValidateGovernPolicyRequest.encode(
104
+ ::Glaz::Govern::V1::ValidateGovernPolicyRequest.new(
105
+ policy_rego: policy_rego
106
+ )
107
+ )
108
+
109
+ response = ::Glaz::Govern::V1::ValidateGovernPolicyResponse.decode(
110
+ @native.validate(encoded)
111
+ )
112
+
113
+ {
114
+ valid: response.valid,
115
+ errors: response.errors.map { |e| { message: e.message, location: e.location } }
116
+ }
117
+ end
118
+
86
119
  # Evaluate a Rego query directly, with no `violation`/`deny`/`allow`
87
120
  # interpretation. A debugging/testing escape hatch for exercising a
88
121
  # policy's Rego directly; prefer #evaluate for the primary path.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gitlab
4
4
  module Glaz
5
- VERSION = "1.1.0"
5
+ VERSION = "1.2.0"
6
6
  end
7
7
  end
@@ -5,7 +5,7 @@
5
5
  require 'google/protobuf'
6
6
 
7
7
 
8
- descriptor_data = "\n\x12proto/govern.proto\x12\x0eglaz.govern.v1\"Y\n\x1b\x45valuateGovernPolicyRequest\x12\x13\n\x0bpolicy_rego\x18\x01 \x01(\t\x12\x12\n\ninput_json\x18\x02 \x01(\t\x12\x11\n\tdata_json\x18\x03 \x01(\t\"m\n EvaluateGovernPolicyDebugRequest\x12\x13\n\x0bpolicy_rego\x18\x01 \x01(\t\x12\r\n\x05query\x18\x02 \x01(\t\x12\x12\n\ninput_json\x18\x03 \x01(\t\x12\x11\n\tdata_json\x18\x04 \x01(\t\"I\n\x0cGovernAction\x12\x13\n\x0b\x61\x63tion_type\x18\x01 \x01(\t\x12\x0f\n\x07message\x18\x02 \x01(\t\x12\x13\n\x0bparams_json\x18\x03 \x01(\t\"5\n\x0cGovernReason\x12\x0f\n\x07message\x18\x01 \x01(\t\x12\x14\n\x0c\x64\x65tails_json\x18\x02 \x01(\t\"\x8d\x01\n\x1c\x45valuateGovernPolicyResponse\x12-\n\x07\x61\x63tions\x18\x01 \x03(\x0b\x32\x1c.glaz.govern.v1.GovernAction\x12-\n\x07reasons\x18\x02 \x03(\x0b\x32\x1c.glaz.govern.v1.GovernReason\x12\x0f\n\x07matched\x18\x03 \x01(\x08\x62\x06proto3"
8
+ descriptor_data = "\n\x12proto/govern.proto\x12\x0eglaz.govern.v1\"z\n\x1bEvaluateGovernPolicyRequest\x12\x1f\n\x0bpolicy_rego\x18\x01 \x01(\tR\npolicyRego\x12\x1d\n\ninput_json\x18\x02 \x01(\tR\tinputJson\x12\x1b\n\tdata_json\x18\x03 \x01(\tR\x08dataJson\"\x95\x01\n EvaluateGovernPolicyDebugRequest\x12\x1f\n\x0bpolicy_rego\x18\x01 \x01(\tR\npolicyRego\x12\x14\n\x05query\x18\x02 \x01(\tR\x05query\x12\x1d\n\ninput_json\x18\x03 \x01(\tR\tinputJson\x12\x1b\n\tdata_json\x18\x04 \x01(\tR\x08dataJson\"j\n\x0cGovernAction\x12\x1f\n\x0baction_type\x18\x01 \x01(\tR\nactionType\x12\x18\n\x07message\x18\x02 \x01(\tR\x07message\x12\x1f\n\x0bparams_json\x18\x03 \x01(\tR\nparamsJson\"K\n\x0cGovernReason\x12\x18\n\x07message\x18\x01 \x01(\tR\x07message\x12!\n\x0cdetails_json\x18\x02 \x01(\tR\x0bdetailsJson\"\xa8\x01\n\x1cEvaluateGovernPolicyResponse\x126\n\x07actions\x18\x01 \x03(\x0b2\x1c.glaz.govern.v1.GovernActionR\x07actions\x126\n\x07reasons\x18\x02 \x03(\x0b2\x1c.glaz.govern.v1.GovernReasonR\x07reasons\x12\x18\n\x07matched\x18\x03 \x01(\x08R\x07matched\">\n\x1bValidateGovernPolicyRequest\x12\x1f\n\x0bpolicy_rego\x18\x01 \x01(\tR\npolicyRego\"M\n\x15GovernValidationError\x12\x18\n\x07message\x18\x01 \x01(\tR\x07message\x12\x1a\n\x08location\x18\x02 \x01(\tR\x08location\"s\n\x1cValidateGovernPolicyResponse\x12\x14\n\x05valid\x18\x01 \x01(\x08R\x05valid\x12=\n\x06errors\x18\x02 \x03(\x0b2%.glaz.govern.v1.GovernValidationErrorR\x06errorsb\x06proto3"
9
9
 
10
10
  pool = ::Google::Protobuf::DescriptorPool.generated_pool
11
11
  pool.add_serialized_file(descriptor_data)
@@ -18,6 +18,9 @@ module Glaz
18
18
  GovernAction = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("glaz.govern.v1.GovernAction").msgclass
19
19
  GovernReason = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("glaz.govern.v1.GovernReason").msgclass
20
20
  EvaluateGovernPolicyResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("glaz.govern.v1.EvaluateGovernPolicyResponse").msgclass
21
+ ValidateGovernPolicyRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("glaz.govern.v1.ValidateGovernPolicyRequest").msgclass
22
+ GovernValidationError = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("glaz.govern.v1.GovernValidationError").msgclass
23
+ ValidateGovernPolicyResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("glaz.govern.v1.ValidateGovernPolicyResponse").msgclass
21
24
  end
22
25
  end
23
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-glaz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: aarch64-linux-gnu
6
6
  authors:
7
7
  - group::authorization
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-08-24 00:00:00.000000000 Z
11
+ date: 2026-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf