gitlab-glaz 1.1.0-x86_64-linux-gnu → 1.2.0-x86_64-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 +4 -4
- data/Cargo.lock +5 -5
- data/Cargo.toml +1 -1
- data/ext/glaz/src/lib.rs +31 -6
- data/lib/gitlab/glaz/3.1/glaz.so +0 -0
- data/lib/gitlab/glaz/3.2/glaz.so +0 -0
- data/lib/gitlab/glaz/3.3/glaz.so +0 -0
- data/lib/gitlab/glaz/3.4/glaz.so +0 -0
- data/lib/gitlab/glaz/4.0/glaz.so +0 -0
- data/lib/gitlab/glaz/govern_policy_engine.rb +33 -0
- data/lib/gitlab/glaz/version.rb +1 -1
- data/lib/proto/govern_pb.rb +4 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 24a3708d49ed5271fea42025fc4d8086db8b5679b0bcd3e4dc6f15610d2a8603
|
|
4
|
+
data.tar.gz: ac11da8b7ed2a3ff5ccadfd93132ebc2d520617deb578b625125851d5548218f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a347f4a6fa0a8ee1c97ee1bbb4848cd6bf7e752415b5c95c456373db0d06d346298e3573b02103833d85f79e94d1da01ca0736e6da75173c7349958658d0bff7
|
|
7
|
+
data.tar.gz: 5094c7e30096ad612e07fcbae2ffc05337664931f98316136fbb6bcbdc268567018c59c13906a4f0ff0b5eceb9a72079756a7d569ca3a997c99b1f801c17da3f
|
data/Cargo.lock
CHANGED
|
@@ -646,7 +646,7 @@ dependencies = [
|
|
|
646
646
|
|
|
647
647
|
[[package]]
|
|
648
648
|
name = "glaz"
|
|
649
|
-
version = "1.
|
|
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.
|
|
1719
|
+
version = "0.9.130"
|
|
1720
1720
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1721
|
-
checksum = "
|
|
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.
|
|
1728
|
+
version = "0.9.130"
|
|
1729
1729
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1730
|
-
checksum = "
|
|
1730
|
+
checksum = "05be6f9c86fe5482808162826f6c047d093b3670582296c770de1d94f8066694"
|
|
1731
1731
|
dependencies = [
|
|
1732
1732
|
"bindgen",
|
|
1733
1733
|
"lazy_static",
|
data/Cargo.toml
CHANGED
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;
|
|
57
|
-
///
|
|
58
|
-
/// on
|
|
59
|
-
///
|
|
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
|
}
|
data/lib/gitlab/glaz/3.1/glaz.so
CHANGED
|
Binary file
|
data/lib/gitlab/glaz/3.2/glaz.so
CHANGED
|
Binary file
|
data/lib/gitlab/glaz/3.3/glaz.so
CHANGED
|
Binary file
|
data/lib/gitlab/glaz/3.4/glaz.so
CHANGED
|
Binary file
|
data/lib/gitlab/glaz/4.0/glaz.so
CHANGED
|
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.
|
data/lib/gitlab/glaz/version.rb
CHANGED
data/lib/proto/govern_pb.rb
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
require 'google/protobuf'
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
descriptor_data = "\n\x12proto/govern.proto\x12\x0eglaz.govern.v1\"
|
|
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.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: x86_64-linux-gnu
|
|
6
6
|
authors:
|
|
7
7
|
- group::authorization
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-09-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: google-protobuf
|