oso-oso 0.14.0 → 0.14.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/ext/oso-oso/lib/libpolar.dylib +0 -0
- data/ext/oso-oso/lib/libpolar.so +0 -0
- data/ext/oso-oso/lib/polar.dll +0 -0
- data/lib/oso/polar/host.rb +27 -11
- data/lib/oso/polar/query.rb +4 -6
- data/lib/oso/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e611289b05e0398183cb6e7f29929b2854b1aaad
|
4
|
+
data.tar.gz: bd8af76c1433c16193b4cf2587cc5ca9f953c5b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6778dedbfe11bb27219ed96712e3e93e79d3187455aad86040764e25b34079a4645ec16de0afed876faa88b290e58fad7e22ccd2ee6aaa61529bd1f9b6231a28
|
7
|
+
data.tar.gz: d21fda13edd7176ecc3dad96258f57f19f51b3114ee02c1fb844277befd0abf9a8cfb035df0593a49977a884aa2bc3fbfd6734cc547be0ef5093d149f866c8d7
|
data/Gemfile.lock
CHANGED
Binary file
|
data/ext/oso-oso/lib/libpolar.so
CHANGED
Binary file
|
data/ext/oso-oso/lib/polar.dll
CHANGED
Binary file
|
data/lib/oso/polar/host.rb
CHANGED
@@ -149,6 +149,33 @@ module Oso
|
|
149
149
|
raise PolarRuntimeError, "Error constructing instance of #{cls_name}: #{e}"
|
150
150
|
end
|
151
151
|
|
152
|
+
OPS = {
|
153
|
+
'Lt' => :<,
|
154
|
+
'Gt' => :>,
|
155
|
+
'Eq' => :==,
|
156
|
+
'Geq' => :>=,
|
157
|
+
'Leq' => :<=,
|
158
|
+
'Neq' => :!=
|
159
|
+
}.freeze
|
160
|
+
|
161
|
+
# Compare two values
|
162
|
+
#
|
163
|
+
# @param op [String] operation to perform.
|
164
|
+
# @param args [Array<Object>] left and right args to operation.
|
165
|
+
# @raise [PolarRuntimeError] if operation fails or is unsupported.
|
166
|
+
# @return [Boolean]
|
167
|
+
def operator(operation, args)
|
168
|
+
left, right = args
|
169
|
+
op = OPS[operation]
|
170
|
+
raise PolarRuntimeError, "Unsupported external operation '#{left.class} #{operation} #{right.class}'" if op.nil?
|
171
|
+
|
172
|
+
begin
|
173
|
+
left.__send__ op, right
|
174
|
+
rescue StandardError
|
175
|
+
raise PolarRuntimeError, "External operation '#{left.class} #{operation} #{right.class}' failed."
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
152
179
|
# Check if the left class is more specific than the right class
|
153
180
|
# with respect to the given instance.
|
154
181
|
#
|
@@ -174,17 +201,6 @@ module Oso
|
|
174
201
|
instance.is_a? cls
|
175
202
|
end
|
176
203
|
|
177
|
-
# Check if two instances unify
|
178
|
-
#
|
179
|
-
# @param left_instance_id [Integer]
|
180
|
-
# @param right_instance_id [Integer]
|
181
|
-
# @return [Boolean]
|
182
|
-
def unify?(left_instance_id, right_instance_id)
|
183
|
-
left_instance = get_instance(left_instance_id)
|
184
|
-
right_instance = get_instance(right_instance_id)
|
185
|
-
left_instance == right_instance
|
186
|
-
end
|
187
|
-
|
188
204
|
# Turn a Ruby value into a Polar term that's ready to be sent across the
|
189
205
|
# FFI boundary.
|
190
206
|
#
|
data/lib/oso/polar/query.rb
CHANGED
@@ -146,11 +146,6 @@ module Oso
|
|
146
146
|
class_tag = event.data['class_tag']
|
147
147
|
answer = host.isa?(instance, class_tag: class_tag)
|
148
148
|
question_result(answer, call_id: event.data['call_id'])
|
149
|
-
when 'ExternalUnify'
|
150
|
-
left_instance_id = event.data['left_instance_id']
|
151
|
-
right_instance_id = event.data['right_instance_id']
|
152
|
-
answer = host.unify?(left_instance_id, right_instance_id)
|
153
|
-
question_result(answer, call_id: event.data['call_id'])
|
154
149
|
when 'Debug'
|
155
150
|
puts event.data['message'] if event.data['message']
|
156
151
|
print 'debug> '
|
@@ -162,7 +157,10 @@ module Oso
|
|
162
157
|
command = JSON.dump(host.to_polar(input))
|
163
158
|
ffi_query.debug_command(command)
|
164
159
|
when 'ExternalOp'
|
165
|
-
|
160
|
+
op = event.data['operator']
|
161
|
+
args = event.data['args'].map(&host.method(:to_ruby))
|
162
|
+
answer = host.operator(op, args)
|
163
|
+
question_result(answer, call_id: event.data['call_id'])
|
166
164
|
when 'NextExternal'
|
167
165
|
call_id = event.data['call_id']
|
168
166
|
iterable = event.data['iterable']
|
data/lib/oso/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oso-oso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.14.
|
4
|
+
version: 0.14.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oso Security, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|