oso-cloud 1.2.0 → 1.3.0.dev.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 +27 -1
- data/lib/oso/api.rb +41 -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: ea1469d68034a213af21a5a0300d2b1b1c7df2d00a3a2518f0a5e48fc0b5756b
|
4
|
+
data.tar.gz: 9491bc2e2bc622296b16a473c0996fdb89a67eb2242f046637ccba173a9e9fb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4baf074d8e2a237287699be969ad02959f5ba1c626cc582c0542931c198cc3c7728b5aa2ec5fa1d323a1368a027d7734fea5c07490247df81f16153c4192cdc4
|
7
|
+
data.tar.gz: '083f190963c58855ac7c5514a07f4547edb2d4b01cb01ac1ef2e11594375401d1b5481a23811134ac484242b8a257a1897e57c36da59241da4a2e95e6fc4d694'
|
data/Gemfile.lock
CHANGED
@@ -1,22 +1,46 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
oso-cloud (1.
|
4
|
+
oso-cloud (1.3.0.dev.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,34 @@ module OsoCloud
|
|
379
391
|
handle_faraday_error e
|
380
392
|
end
|
381
393
|
|
394
|
+
def POST_BATCH(path, params, body_array, isMutation)
|
395
|
+
@connection.in_parallel do
|
396
|
+
@responses = body_array.map do |body|
|
397
|
+
@connection.post("api#{path}") do |req|
|
398
|
+
req.params = params unless params.nil?
|
399
|
+
req.body = OsoCloud::Helpers.to_hash(body) unless body.nil?
|
400
|
+
req.headers = headers
|
401
|
+
end
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
connection_failed = @responses.find { |r| r.env.custom_members[:typhoeus_connection_failed] }
|
406
|
+
if connection_failed
|
407
|
+
raise Faraday::ConnectionFailed, connection_failed.env.custom_members[:typhoeus_return_message]
|
408
|
+
end
|
409
|
+
|
410
|
+
timed_out = @responses.find { |r| r.env.custom_members[:typhoeus_timed_out] }
|
411
|
+
if timed_out
|
412
|
+
raise Faraday::TimeoutError, timed_out.env.custom_members[:typhoeus_return_message]
|
413
|
+
end
|
414
|
+
if isMutation
|
415
|
+
@last_offset = @responses[-1].headers[:OsoOffset]
|
416
|
+
end
|
417
|
+
@responses
|
418
|
+
rescue Faraday::Error => e
|
419
|
+
handle_faraday_error e
|
420
|
+
end
|
421
|
+
|
382
422
|
def POST(path, params, body, isMutation)
|
383
423
|
response = @connection.post("api#{path}") do |req|
|
384
424
|
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.1
|
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-26 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: []
|