oso-cloud 1.2.0 → 1.3.0.dev.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +26 -0
- data/lib/oso/api.rb +32 -1
- data/lib/oso/oso.rb +17 -1
- data/lib/oso/version.rb +1 -1
- data/oso-cloud.gemspec +5 -0
- metadata +50 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93c11d4552281f1cbf95ec309bbbcd5e8d1289a7f0ee2000724f8d6eb4386617
|
4
|
+
data.tar.gz: 62fd22884497116c5db29b06a012b2b06ad82de78b96ed4823b0dbd22862ef37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5139439b2e01ab083c0e73827ddb520a54dc0c2606d1ca20203bad6b56fc446f747a638cc603a83584da35ae65e500ecf4354fd53065c109fa044aef6ba2950f
|
7
|
+
data.tar.gz: eac48b47137286b49a1e27197cfb7867bbcd982b6fe6523f9e50ed9d8659934ceaea9b548f3d543510e9983872c9a9859400d417f149af8ef82f9319ea7b9f3e
|
data/Gemfile.lock
CHANGED
@@ -4,19 +4,43 @@ PATH
|
|
4
4
|
oso-cloud (1.2.0)
|
5
5
|
faraday (~> 2.5.2)
|
6
6
|
faraday-retry (~> 2.0.0)
|
7
|
+
faraday-typhoeus (~> 1.0.0)
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: https://rubygems.org/
|
10
11
|
specs:
|
12
|
+
binding_of_caller (1.0.0)
|
13
|
+
debug_inspector (>= 0.0.1)
|
14
|
+
coderay (1.1.3)
|
15
|
+
debug_inspector (1.1.0)
|
16
|
+
ethon (0.16.0)
|
17
|
+
ffi (>= 1.15.0)
|
11
18
|
faraday (2.5.2)
|
12
19
|
faraday-net_http (>= 2.0, < 3.1)
|
13
20
|
ruby2_keywords (>= 0.0.4)
|
14
21
|
faraday-net_http (3.0.2)
|
15
22
|
faraday-retry (2.0.0)
|
16
23
|
faraday (~> 2.0)
|
24
|
+
faraday-typhoeus (1.0.0)
|
25
|
+
faraday (~> 2.0)
|
26
|
+
typhoeus (~> 1.4)
|
27
|
+
ffi (1.15.5)
|
28
|
+
interception (0.5)
|
29
|
+
method_source (1.0.0)
|
17
30
|
minitest (5.18.0)
|
31
|
+
pry (0.14.2)
|
32
|
+
coderay (~> 1.1)
|
33
|
+
method_source (~> 1.0)
|
34
|
+
pry-rescue (1.5.2)
|
35
|
+
interception (>= 0.5)
|
36
|
+
pry (>= 0.12.0)
|
37
|
+
pry-stack_explorer (0.6.1)
|
38
|
+
binding_of_caller (~> 1.0)
|
39
|
+
pry (~> 0.13)
|
18
40
|
rake (12.3.3)
|
19
41
|
ruby2_keywords (0.0.5)
|
42
|
+
typhoeus (1.4.0)
|
43
|
+
ethon (>= 0.9.0)
|
20
44
|
|
21
45
|
PLATFORMS
|
22
46
|
ruby
|
@@ -24,6 +48,8 @@ PLATFORMS
|
|
24
48
|
DEPENDENCIES
|
25
49
|
minitest (~> 5.15)
|
26
50
|
oso-cloud!
|
51
|
+
pry-rescue
|
52
|
+
pry-stack_explorer
|
27
53
|
rake (~> 12.0)
|
28
54
|
|
29
55
|
BUNDLED WITH
|
data/lib/oso/api.rb
CHANGED
@@ -2,6 +2,7 @@ require 'json'
|
|
2
2
|
require 'uri'
|
3
3
|
require 'faraday'
|
4
4
|
require 'faraday/retry'
|
5
|
+
require 'faraday/typhoeus'
|
5
6
|
|
6
7
|
require 'oso/helpers'
|
7
8
|
require 'oso/version'
|
@@ -246,7 +247,12 @@ module OsoCloud
|
|
246
247
|
end
|
247
248
|
end
|
248
249
|
else
|
249
|
-
faraday.adapter :net_http
|
250
|
+
# faraday.adapter :net_http
|
251
|
+
# faraday.adapter :net_http_persistent, pool_size: 5 do |http|
|
252
|
+
# # yields Net::HTTP::Persistent
|
253
|
+
# http.idle_timeout = 1000
|
254
|
+
# end
|
255
|
+
faraday.adapter :typhoeus, forbid_reuse: true, maxredirs: 1
|
250
256
|
end
|
251
257
|
end
|
252
258
|
@api_key = api_key
|
@@ -320,6 +326,12 @@ module OsoCloud
|
|
320
326
|
ActionsResult.new(**result)
|
321
327
|
end
|
322
328
|
|
329
|
+
def post_actions_batch(batch_data)
|
330
|
+
url = '/actions'
|
331
|
+
results = POST_BATCH(url, nil, batch_data, false)
|
332
|
+
results.map { |result| ActionsResult.new(**result.body) }
|
333
|
+
end
|
334
|
+
|
323
335
|
def post_query(data)
|
324
336
|
url = '/query'
|
325
337
|
result = POST(url, nil, data, false)
|
@@ -379,6 +391,25 @@ module OsoCloud
|
|
379
391
|
handle_faraday_error e
|
380
392
|
end
|
381
393
|
|
394
|
+
def POST_BATCH(path, params, body_array, isMutation)
|
395
|
+
responses = []
|
396
|
+
@connection.in_parallel do
|
397
|
+
body_array.each do |body|
|
398
|
+
responses << @connection.post("api#{path}") do |req|
|
399
|
+
req.params = params unless params.nil?
|
400
|
+
req.body = OsoCloud::Helpers.to_hash(body) unless body.nil?
|
401
|
+
req.headers = headers
|
402
|
+
end
|
403
|
+
end
|
404
|
+
end
|
405
|
+
if isMutation
|
406
|
+
@last_offset = responses[-1].headers[:OsoOffset]
|
407
|
+
end
|
408
|
+
responses
|
409
|
+
rescue Faraday::Error => e
|
410
|
+
handle_faraday_error e
|
411
|
+
end
|
412
|
+
|
382
413
|
def POST(path, params, body, isMutation)
|
383
414
|
response = @connection.post("api#{path}") do |req|
|
384
415
|
req.params = params unless params.nil?
|
data/lib/oso/oso.rb
CHANGED
@@ -32,7 +32,6 @@ module OsoCloud
|
|
32
32
|
@api = OsoCloud::Core::Api.new(url: url, api_key: api_key)
|
33
33
|
end
|
34
34
|
|
35
|
-
##
|
36
35
|
# Update the active policy
|
37
36
|
#
|
38
37
|
# Updates the active policy in Oso Cloud, The string passed into
|
@@ -270,5 +269,22 @@ module OsoCloud
|
|
270
269
|
context_facts: OsoCloud::Helpers.params_to_facts(context_facts)))
|
271
270
|
OsoCloud::Helpers.facts_to_params(result.results)
|
272
271
|
end
|
272
|
+
|
273
|
+
def actions_batch(actor, resources, context_facts = [])
|
274
|
+
actor_typed_id = actor.to_api_value
|
275
|
+
data = resources.map do |r|
|
276
|
+
resource_typed_id = r.to_api_value
|
277
|
+
OsoCloud::Core::ActionsQuery.new(
|
278
|
+
actor_type: actor_typed_id.type,
|
279
|
+
actor_id: actor_typed_id.id,
|
280
|
+
resource_type: resource_typed_id.type,
|
281
|
+
resource_id: resource_typed_id.id,
|
282
|
+
context_facts: OsoCloud::Helpers.params_to_facts(context_facts)
|
283
|
+
)
|
284
|
+
end
|
285
|
+
@api.post_actions_batch(data).map { |result| result.results}
|
286
|
+
end
|
273
287
|
end
|
288
|
+
|
274
289
|
end
|
290
|
+
|
data/lib/oso/version.rb
CHANGED
data/oso-cloud.gemspec
CHANGED
@@ -22,5 +22,10 @@ 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
|
+
# spec.add_dependency 'faraday-net_http_persistent', '~> 2.0'
|
26
|
+
spec.add_dependency 'faraday-typhoeus', '~> 1.0.0'
|
27
|
+
#
|
25
28
|
spec.add_development_dependency 'minitest', '~> 5.15'
|
29
|
+
spec.add_development_dependency 'pry-rescue'
|
30
|
+
spec.add_development_dependency 'pry-stack_explorer'
|
26
31
|
end
|
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.
|
4
|
+
version: 1.3.0.dev.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oso Security, Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-22 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-typhoeus
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.0.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: minitest
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,7 +66,35 @@ dependencies:
|
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '5.15'
|
55
|
-
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry-rescue
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry-stack_explorer
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description:
|
56
98
|
email:
|
57
99
|
- support@osohq.com
|
58
100
|
executables: []
|
@@ -77,7 +119,7 @@ homepage: https://www.osohq.com/
|
|
77
119
|
licenses:
|
78
120
|
- Apache-2.0
|
79
121
|
metadata: {}
|
80
|
-
post_install_message:
|
122
|
+
post_install_message:
|
81
123
|
rdoc_options: []
|
82
124
|
require_paths:
|
83
125
|
- lib
|
@@ -88,12 +130,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
130
|
version: 3.0.0
|
89
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
132
|
requirements:
|
91
|
-
- - "
|
133
|
+
- - ">"
|
92
134
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
135
|
+
version: 1.3.1
|
94
136
|
requirements: []
|
95
137
|
rubygems_version: 3.2.33
|
96
|
-
signing_key:
|
138
|
+
signing_key:
|
97
139
|
specification_version: 4
|
98
140
|
summary: Oso Cloud Ruby client
|
99
141
|
test_files: []
|