oso-cloud 1.3.0.dev.4 → 1.3.0.dev.6
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/Gemfile.lock +9 -2
- data/lib/oso/api.rb +7 -8
- data/lib/oso/oso.rb +28 -12
- data/lib/oso/version.rb +1 -1
- data/oso-cloud.gemspec +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14b5b319f475adefc2e05c6bf2e9cf6f22b20164d38fb9c1cb59b1b7c6c291ee
|
4
|
+
data.tar.gz: d9d50d1adcc35c04309b65cde6d2d802eec75ccdd62d6b2d5e05907e7bb9806f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8f770aaefda73dba90e6410be04dec0dc5ec1089535d7977f1aa5bd1d6310023954c6e2aae3e1d6c9e458ef2ceb5df58cf7dd16bc3c3183036da4965fcdaf02
|
7
|
+
data.tar.gz: 669d14ebf88e20a6f2a1bebdc609a7bda2e3eb6c20fc3d5eb7f4efa2b686ea611bc5a7ad28dcd4cd450a36226f1df5594daa09927a755d91ab97abe819363181
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
oso-cloud (1.3.0.dev.
|
4
|
+
oso-cloud (1.3.0.dev.5)
|
5
5
|
faraday (~> 2.5.2)
|
6
|
+
faraday-net_http_persistent (~> 2.0)
|
6
7
|
faraday-retry (~> 2.0.0)
|
7
8
|
faraday-typhoeus (~> 1.0.0)
|
8
9
|
|
@@ -12,6 +13,7 @@ GEM
|
|
12
13
|
binding_of_caller (1.0.0)
|
13
14
|
debug_inspector (>= 0.0.1)
|
14
15
|
coderay (1.1.3)
|
16
|
+
connection_pool (2.4.1)
|
15
17
|
debug_inspector (1.1.0)
|
16
18
|
ethon (0.16.0)
|
17
19
|
ffi (>= 1.15.0)
|
@@ -19,15 +21,20 @@ GEM
|
|
19
21
|
faraday-net_http (>= 2.0, < 3.1)
|
20
22
|
ruby2_keywords (>= 0.0.4)
|
21
23
|
faraday-net_http (3.0.2)
|
24
|
+
faraday-net_http_persistent (2.1.0)
|
25
|
+
faraday (~> 2.5)
|
26
|
+
net-http-persistent (~> 4.0)
|
22
27
|
faraday-retry (2.0.0)
|
23
28
|
faraday (~> 2.0)
|
24
29
|
faraday-typhoeus (1.0.0)
|
25
30
|
faraday (~> 2.0)
|
26
31
|
typhoeus (~> 1.4)
|
27
|
-
ffi (1.
|
32
|
+
ffi (1.16.2)
|
28
33
|
interception (0.5)
|
29
34
|
method_source (1.0.0)
|
30
35
|
minitest (5.18.0)
|
36
|
+
net-http-persistent (4.0.2)
|
37
|
+
connection_pool (~> 2.2)
|
31
38
|
pry (0.14.2)
|
32
39
|
coderay (~> 1.1)
|
33
40
|
method_source (~> 1.0)
|
data/lib/oso/api.rb
CHANGED
@@ -3,6 +3,7 @@ require 'uri'
|
|
3
3
|
require 'faraday'
|
4
4
|
require 'faraday/retry'
|
5
5
|
require 'faraday/typhoeus'
|
6
|
+
require 'faraday/net_http_persistent'
|
6
7
|
|
7
8
|
require 'oso/helpers'
|
8
9
|
require 'oso/version'
|
@@ -230,7 +231,7 @@ module OsoCloud
|
|
230
231
|
/api/actions
|
231
232
|
/api/query
|
232
233
|
].include? env.url.path
|
233
|
-
}
|
234
|
+
},
|
234
235
|
}
|
235
236
|
|
236
237
|
if options && options[:test_adapter]
|
@@ -245,13 +246,10 @@ module OsoCloud
|
|
245
246
|
options[:test_adapter][:func].call
|
246
247
|
end
|
247
248
|
end
|
249
|
+
elsif options && options[:parallel_adapter]
|
250
|
+
faraday.adapter :typhoeus, forbid_reuse: false, maxredirs: 1, connecttimeout: 30
|
248
251
|
else
|
249
|
-
|
250
|
-
# faraday.adapter :net_http_persistent, pool_size: 5 do |http|
|
251
|
-
# # yields Net::HTTP::Persistent
|
252
|
-
# http.idle_timeout = 1000
|
253
|
-
# end
|
254
|
-
faraday.adapter :typhoeus, forbid_reuse: true, maxredirs: 1
|
252
|
+
faraday.adapter :net_http_persistent, pool_size: 10, idle_timeout: 30
|
255
253
|
end
|
256
254
|
end
|
257
255
|
end
|
@@ -259,6 +257,7 @@ module OsoCloud
|
|
259
257
|
def initialize(url: 'https://api.osohq.com', api_key: nil, options: nil)
|
260
258
|
@url = url
|
261
259
|
@connection = get_connection(options: options)
|
260
|
+
@parallel_connection = get_connection(options: { parallel_adapter: true })
|
262
261
|
@api_key = api_key
|
263
262
|
@user_agent = "Oso Cloud (ruby #{RUBY_VERSION}p#{RUBY_PATCHLEVEL}; rv:#{VERSION})"
|
264
263
|
@last_offset = nil
|
@@ -396,7 +395,7 @@ module OsoCloud
|
|
396
395
|
end
|
397
396
|
|
398
397
|
def POST_BATCH(path, params, body_array, isMutation)
|
399
|
-
connection =
|
398
|
+
connection = @parallel_connection
|
400
399
|
responses = []
|
401
400
|
connection.in_parallel do
|
402
401
|
responses = body_array.map do |body|
|
data/lib/oso/oso.rb
CHANGED
@@ -270,21 +270,37 @@ module OsoCloud
|
|
270
270
|
OsoCloud::Helpers.facts_to_params(result.results)
|
271
271
|
end
|
272
272
|
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
273
|
+
##
|
274
|
+
# List authorized actions for a batch of queries
|
275
|
+
#
|
276
|
+
# Fetches a list of actions which an actor can perform on a particular resource.
|
277
|
+
#
|
278
|
+
# @param actor [OsoCloud::Value]
|
279
|
+
# @param queries [Array<OsoCloud::Value>] | Array<[OsoCloud::Value, Array<fact>]>
|
280
|
+
# @return [Array<Array<String>>]
|
281
|
+
# @see Oso for more information about facts
|
282
|
+
def actions_batch(actor, queries:)
|
283
|
+
actor_typed_id = actor.to_api_value
|
284
|
+
data = queries.map do |q|
|
285
|
+
context_facts = []
|
286
|
+
resource = nil
|
287
|
+
if (q.is_a?(Array))
|
288
|
+
resource = q[0]
|
289
|
+
context_facts = q[1]
|
290
|
+
else
|
291
|
+
resource = q
|
292
|
+
end
|
293
|
+
resource_typed_id = resource.to_api_value
|
294
|
+
OsoCloud::Core::ActionsQuery.new(
|
295
|
+
actor_type: actor_typed_id.type,
|
296
|
+
actor_id: actor_typed_id.id,
|
297
|
+
resource_type: resource_typed_id.type,
|
298
|
+
resource_id: resource_typed_id.id,
|
299
|
+
context_facts: OsoCloud::Helpers.params_to_facts(context_facts)
|
300
|
+
)
|
284
301
|
end
|
285
302
|
@api.post_actions_batch(data).map { |result| result.results}
|
286
303
|
end
|
287
304
|
end
|
288
305
|
|
289
306
|
end
|
290
|
-
|
data/lib/oso/version.rb
CHANGED
data/oso-cloud.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.add_dependency 'faraday', '~> 2.5.2'
|
24
24
|
spec.add_dependency 'faraday-retry', '~> 2.0.0'
|
25
|
-
|
25
|
+
spec.add_dependency 'faraday-net_http_persistent', '~> 2.0'
|
26
26
|
spec.add_dependency 'faraday-typhoeus', '~> 1.0.0'
|
27
27
|
#
|
28
28
|
spec.add_development_dependency 'minitest', '~> 5.15'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oso-cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.0.dev.
|
4
|
+
version: 1.3.0.dev.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oso Security, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: faraday-net_http_persistent
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: faraday-typhoeus
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|