hyper-operation 1.0.alpha1.2 → 1.0.alpha1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +49 -27
- data/hyper-operation.gemspec +2 -1
- data/lib/hyper-operation.rb +2 -0
- data/lib/hyper-operation/exception.rb +29 -3
- data/lib/hyper-operation/server_op.rb +25 -7
- data/lib/hyper-operation/transport/client_drivers.rb +4 -0
- data/lib/hyper-operation/transport/hyperstack_controller.rb +1 -1
- data/lib/hyper-operation/transport/policy.rb +7 -22
- data/lib/hyper-operation/transport/policy_diagnostics.rb +106 -0
- data/lib/hyper-operation/version.rb +1 -1
- metadata +30 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9684386e717f491348c6acab32279464d69eae7a30dad4177a86e5b05e34b47a
|
4
|
+
data.tar.gz: 8a7ffd0abd510e70a657ce14ee796265520646a8a709fd4e98b8589c568da42e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a52bbf0183579a349caaa55afc19179d851a900c335bda1a51a13fafc0a9535ec456dd4f2c864bb33766ca2329bf912bde9fba0b13c236a65a5d5bd9763843e1
|
7
|
+
data.tar.gz: 7a2127f42df5613b3a4f030afa05fc1b3c30e5d0d2afa7b6c32df05ccf33e43678584fa4e54e58562d65caad7936279baf0b700c4fd2c482cecec42ddc0eddf4
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../hyper-component
|
3
3
|
specs:
|
4
|
-
hyper-component (1.0.alpha1.
|
5
|
-
hyper-state (= 1.0.alpha1.
|
6
|
-
hyperstack-config (= 1.0.alpha1.
|
7
|
-
libv8 (~> 6.
|
8
|
-
mini_racer (~> 0.
|
4
|
+
hyper-component (1.0.alpha1.3)
|
5
|
+
hyper-state (= 1.0.alpha1.3)
|
6
|
+
hyperstack-config (= 1.0.alpha1.3)
|
7
|
+
libv8 (~> 6.7.0)
|
8
|
+
mini_racer (~> 0.2.4)
|
9
9
|
opal (>= 0.11.0, < 0.12.0)
|
10
10
|
opal-activesupport (~> 0.3.1)
|
11
11
|
react-rails (>= 2.4.0, < 2.5.0)
|
@@ -13,12 +13,12 @@ PATH
|
|
13
13
|
PATH
|
14
14
|
remote: ../hyper-spec
|
15
15
|
specs:
|
16
|
-
hyper-spec (1.0.alpha1.
|
16
|
+
hyper-spec (1.0.alpha1.3)
|
17
17
|
capybara
|
18
18
|
chromedriver-helper (= 1.2.0)
|
19
|
-
libv8
|
19
|
+
libv8
|
20
20
|
method_source
|
21
|
-
mini_racer (~> 0.
|
21
|
+
mini_racer (~> 0.2.4)
|
22
22
|
opal (>= 0.11.0, < 0.12.0)
|
23
23
|
parser (>= 2.3.3.1)
|
24
24
|
pry
|
@@ -26,23 +26,22 @@ PATH
|
|
26
26
|
selenium-webdriver
|
27
27
|
timecop (~> 0.8.1)
|
28
28
|
uglifier
|
29
|
-
unparser
|
29
|
+
unparser (>= 0.2, < 0.4)
|
30
30
|
webdrivers
|
31
31
|
|
32
32
|
PATH
|
33
33
|
remote: ../hyper-state
|
34
34
|
specs:
|
35
|
-
hyper-state (1.0.alpha1.
|
36
|
-
hyperstack-config (= 1.0.alpha1.
|
35
|
+
hyper-state (1.0.alpha1.3)
|
36
|
+
hyperstack-config (= 1.0.alpha1.3)
|
37
37
|
opal (>= 0.11.0, < 0.12.0)
|
38
38
|
|
39
39
|
PATH
|
40
40
|
remote: ../hyperstack-config
|
41
41
|
specs:
|
42
|
-
hyperstack-config (1.0.alpha1.
|
43
|
-
libv8 (~> 6.3.0)
|
42
|
+
hyperstack-config (1.0.alpha1.3)
|
44
43
|
listen (~> 3.0)
|
45
|
-
mini_racer (~> 0.
|
44
|
+
mini_racer (~> 0.2.4)
|
46
45
|
opal (>= 0.11.0, < 0.12.0)
|
47
46
|
opal-browser (~> 0.2.0)
|
48
47
|
uglifier
|
@@ -51,11 +50,12 @@ PATH
|
|
51
50
|
PATH
|
52
51
|
remote: .
|
53
52
|
specs:
|
54
|
-
hyper-operation (1.0.alpha1.
|
53
|
+
hyper-operation (1.0.alpha1.3)
|
55
54
|
activerecord (>= 4.0.0)
|
56
|
-
hyper-component (= 1.0.alpha1.
|
55
|
+
hyper-component (= 1.0.alpha1.3)
|
57
56
|
mutations
|
58
57
|
opal-activesupport (~> 0.3.1)
|
58
|
+
tty-table
|
59
59
|
|
60
60
|
GEM
|
61
61
|
remote: https://rubygems.org/
|
@@ -116,7 +116,7 @@ GEM
|
|
116
116
|
babel-source (>= 4.0, < 6)
|
117
117
|
execjs (~> 2.0)
|
118
118
|
builder (3.2.3)
|
119
|
-
capybara (3.
|
119
|
+
capybara (3.12.0)
|
120
120
|
addressable
|
121
121
|
mini_mime (>= 0.1.3)
|
122
122
|
nokogiri (~> 1.8)
|
@@ -152,10 +152,11 @@ GEM
|
|
152
152
|
eventmachine (>= 0.12.9)
|
153
153
|
http_parser.rb (~> 0.6.0)
|
154
154
|
equalizer (0.0.11)
|
155
|
+
equatable (0.5.0)
|
155
156
|
erubi (1.7.1)
|
156
157
|
eventmachine (1.2.7)
|
157
158
|
execjs (2.7.0)
|
158
|
-
ffi (1.
|
159
|
+
ffi (1.10.0)
|
159
160
|
globalid (0.4.1)
|
160
161
|
activesupport (>= 4.2.0)
|
161
162
|
hike (1.2.3)
|
@@ -170,7 +171,7 @@ GEM
|
|
170
171
|
rails-dom-testing (>= 1, < 3)
|
171
172
|
railties (>= 4.2.0)
|
172
173
|
thor (>= 0.14, < 2.0)
|
173
|
-
libv8 (6.
|
174
|
+
libv8 (6.7.288.46.1)
|
174
175
|
listen (3.1.5)
|
175
176
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
176
177
|
rb-inotify (~> 0.9, >= 0.9.7)
|
@@ -188,13 +189,15 @@ GEM
|
|
188
189
|
mimemagic (0.3.2)
|
189
190
|
mini_mime (1.0.1)
|
190
191
|
mini_portile2 (2.3.0)
|
191
|
-
mini_racer (0.
|
192
|
-
libv8 (
|
192
|
+
mini_racer (0.2.4)
|
193
|
+
libv8 (>= 6.3)
|
193
194
|
minitest (5.11.3)
|
194
195
|
multi_json (1.13.1)
|
195
196
|
mutations (0.8.3)
|
196
197
|
activesupport
|
197
198
|
mysql2 (0.5.2)
|
199
|
+
necromancer (0.4.0)
|
200
|
+
net_http_ssl_fix (0.0.10)
|
198
201
|
nio4r (2.3.1)
|
199
202
|
nokogiri (1.8.4)
|
200
203
|
mini_portile2 (~> 2.3.0)
|
@@ -225,6 +228,9 @@ GEM
|
|
225
228
|
paggio (0.2.6)
|
226
229
|
parser (2.3.3.1)
|
227
230
|
ast (~> 2.2)
|
231
|
+
pastel (0.7.2)
|
232
|
+
equatable (~> 0.5.0)
|
233
|
+
tty-color (~> 0.4.0)
|
228
234
|
procto (0.0.3)
|
229
235
|
pry (0.11.3)
|
230
236
|
coderay (~> 1.1.0)
|
@@ -273,8 +279,8 @@ GEM
|
|
273
279
|
thor (>= 0.19.0, < 2.0)
|
274
280
|
rake (12.3.1)
|
275
281
|
rb-fsevent (0.10.3)
|
276
|
-
rb-inotify (0.
|
277
|
-
ffi (
|
282
|
+
rb-inotify (0.10.0)
|
283
|
+
ffi (~> 1.0)
|
278
284
|
react-rails (2.4.7)
|
279
285
|
babel-transpiler (>= 0.7.0)
|
280
286
|
connection_pool
|
@@ -321,6 +327,11 @@ GEM
|
|
321
327
|
activesupport (>= 4.0)
|
322
328
|
sprockets (>= 3.0.0)
|
323
329
|
sqlite3 (1.3.13)
|
330
|
+
strings (0.1.4)
|
331
|
+
strings-ansi (~> 0.1.0)
|
332
|
+
unicode-display_width (~> 1.4.0)
|
333
|
+
unicode_utils (~> 1.4.0)
|
334
|
+
strings-ansi (0.1.0)
|
324
335
|
thin (1.7.2)
|
325
336
|
daemons (~> 1.0, >= 1.0.9)
|
326
337
|
eventmachine (~> 1.0, >= 1.0.4)
|
@@ -329,10 +340,20 @@ GEM
|
|
329
340
|
thread_safe (0.3.6)
|
330
341
|
tilt (2.0.8)
|
331
342
|
timecop (0.8.1)
|
343
|
+
tty-color (0.4.3)
|
344
|
+
tty-screen (0.6.5)
|
345
|
+
tty-table (0.10.0)
|
346
|
+
equatable (~> 0.5.0)
|
347
|
+
necromancer (~> 0.4.0)
|
348
|
+
pastel (~> 0.7.2)
|
349
|
+
strings (~> 0.1.0)
|
350
|
+
tty-screen (~> 0.6.4)
|
332
351
|
tzinfo (1.2.5)
|
333
352
|
thread_safe (~> 0.1)
|
334
|
-
uglifier (4.1.
|
353
|
+
uglifier (4.1.20)
|
335
354
|
execjs (>= 0.3.0, < 3)
|
355
|
+
unicode-display_width (1.4.1)
|
356
|
+
unicode_utils (1.4.0)
|
336
357
|
unparser (0.2.8)
|
337
358
|
abstract_type (~> 0.0.7)
|
338
359
|
adamantium (~> 0.2.0)
|
@@ -341,7 +362,8 @@ GEM
|
|
341
362
|
equalizer (~> 0.0.9)
|
342
363
|
parser (>= 2.3.1.2, < 2.6)
|
343
364
|
procto (~> 0.0.2)
|
344
|
-
webdrivers (3.
|
365
|
+
webdrivers (3.6.0)
|
366
|
+
net_http_ssl_fix
|
345
367
|
nokogiri (~> 1.6)
|
346
368
|
rubyzip (~> 1.0)
|
347
369
|
selenium-webdriver (~> 3.0)
|
@@ -356,7 +378,7 @@ PLATFORMS
|
|
356
378
|
ruby
|
357
379
|
|
358
380
|
DEPENDENCIES
|
359
|
-
bundler
|
381
|
+
bundler (>= 1.17.3, < 2.1)
|
360
382
|
chromedriver-helper
|
361
383
|
database_cleaner
|
362
384
|
hyper-component!
|
@@ -382,4 +404,4 @@ DEPENDENCIES
|
|
382
404
|
timecop (~> 0.8.1)
|
383
405
|
|
384
406
|
BUNDLED WITH
|
385
|
-
|
407
|
+
2.0.1
|
data/hyper-operation.gemspec
CHANGED
@@ -27,8 +27,9 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_dependency 'hyper-component', Hyperstack::Operation::VERSION
|
28
28
|
spec.add_dependency 'mutations'
|
29
29
|
spec.add_dependency 'opal-activesupport', '~> 0.3.1'
|
30
|
+
spec.add_dependency 'tty-table'
|
30
31
|
|
31
|
-
spec.add_development_dependency 'bundler'
|
32
|
+
spec.add_development_dependency 'bundler', ['>= 1.17.3', '< 2.1']
|
32
33
|
spec.add_development_dependency 'chromedriver-helper'
|
33
34
|
spec.add_development_dependency 'database_cleaner'
|
34
35
|
spec.add_development_dependency 'hyper-spec', Hyperstack::Operation::VERSION
|
data/lib/hyper-operation.rb
CHANGED
@@ -29,6 +29,7 @@ if RUBY_ENGINE == 'opal'
|
|
29
29
|
require 'hyper-operation/server_op'
|
30
30
|
require 'hyper-operation/boot'
|
31
31
|
else
|
32
|
+
require 'tty-table'
|
32
33
|
require 'hyperstack-config'
|
33
34
|
require 'mutations'
|
34
35
|
Mutations::HashFilter.register_additional_filter(Mutations::DuckFilter, :duck)
|
@@ -40,6 +41,7 @@ else
|
|
40
41
|
require 'hyper-operation/transport/connection'
|
41
42
|
require 'hyper-operation/transport/hyperstack'
|
42
43
|
require 'hyper-operation/transport/policy'
|
44
|
+
require 'hyper-operation/transport/policy_diagnostics'
|
43
45
|
require 'hyper-operation/transport/client_drivers'
|
44
46
|
require 'hyper-operation/transport/acting_user'
|
45
47
|
require 'opal-activesupport'
|
@@ -1,13 +1,39 @@
|
|
1
|
+
module Mutations
|
2
|
+
class ErrorArray
|
3
|
+
def self.new_from_error_hash(errors)
|
4
|
+
new(errors.collect do |key, values|
|
5
|
+
ErrorAtom.new(key, values[:symbol], values)
|
6
|
+
end)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
1
11
|
module Hyperstack
|
2
12
|
class AccessViolation < StandardError
|
3
|
-
|
4
|
-
|
13
|
+
attr_accessor :details
|
14
|
+
|
15
|
+
def initialize(message = nil, details = nil)
|
16
|
+
super("Hyperstack::AccessViolation#{':' + message.to_s if message}")
|
17
|
+
@details = details
|
18
|
+
end
|
19
|
+
|
20
|
+
def __hyperstack_on_error(operation, params, fmted_message)
|
21
|
+
Hyperstack.on_error(operation, self, params, fmted_message)
|
5
22
|
end
|
6
23
|
end
|
7
24
|
|
8
25
|
class Operation
|
9
26
|
class ValidationException < Mutations::ValidationException
|
27
|
+
def as_json(*)
|
28
|
+
errors.as_json
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize(errors)
|
32
|
+
unless errors.is_a? Mutations::ErrorHash
|
33
|
+
errors = Mutations::ErrorArray.new_from_error_hash(errors)
|
34
|
+
end
|
35
|
+
super(errors)
|
36
|
+
end
|
10
37
|
end
|
11
38
|
end
|
12
|
-
|
13
39
|
end
|
@@ -20,7 +20,11 @@ module Hyperstack
|
|
20
20
|
deserialize_response response.json[:response]
|
21
21
|
end
|
22
22
|
.fail do |response|
|
23
|
-
|
23
|
+
begin
|
24
|
+
const_get(response.json[:error_class]).new(response.json[:error])
|
25
|
+
rescue
|
26
|
+
Exception.new response.json[:error]
|
27
|
+
end
|
24
28
|
end
|
25
29
|
end
|
26
30
|
elsif on_opal_server?
|
@@ -74,7 +78,7 @@ module Hyperstack
|
|
74
78
|
if _Railway.params_wrapper.method_defined?(:controller)
|
75
79
|
params[:controller] = controller
|
76
80
|
elsif !_Railway.params_wrapper.method_defined?(security_param)
|
77
|
-
raise AccessViolation
|
81
|
+
raise AccessViolation.new(:remote_access_not_allowed)
|
78
82
|
end
|
79
83
|
run(deserialize_params(params))
|
80
84
|
.then { |r| return { json: { response: serialize_response(r) } } }
|
@@ -84,13 +88,27 @@ module Hyperstack
|
|
84
88
|
handle_exception(e, operation, params)
|
85
89
|
end
|
86
90
|
|
91
|
+
def status(e)
|
92
|
+
if e.is_a? AccessViolation
|
93
|
+
403
|
94
|
+
elsif e.is_a? Operation::ValidationException
|
95
|
+
400
|
96
|
+
else
|
97
|
+
500
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
87
101
|
def handle_exception(e, operation, params)
|
88
|
-
if
|
89
|
-
params.
|
90
|
-
|
91
|
-
|
102
|
+
if e.respond_to? :__hyperstack_on_error
|
103
|
+
params = params.to_h
|
104
|
+
message = []
|
105
|
+
message << Pastel.new.red("HYPERSTACK ERROR during #{operation} #{e.inspect}")
|
106
|
+
params.each { |param, value| message << " #{param} => #{value.inspect.truncate(120, separator: '...')}" }
|
107
|
+
message << "\n#{e.details}" if e.respond_to? :details
|
108
|
+
e.__hyperstack_on_error(operation, params, message.join("\n"))
|
92
109
|
end
|
93
|
-
|
110
|
+
|
111
|
+
{ json: { error_class: e.class.to_s, error: e}, status: status(e) }
|
94
112
|
end
|
95
113
|
|
96
114
|
|
@@ -6,6 +6,10 @@ module Hyperstack
|
|
6
6
|
# We use ERB to determine the configuration and implement the appropriate
|
7
7
|
# client interface to sync_change or sync_destroy
|
8
8
|
|
9
|
+
def self.anti_csrf_token
|
10
|
+
ClientDrivers.opts[:form_authenticity_token]
|
11
|
+
end
|
12
|
+
|
9
13
|
class Application
|
10
14
|
extend Component::IsomorphicHelpers::ClassMethods
|
11
15
|
|
@@ -153,7 +153,7 @@ module Hyperstack
|
|
153
153
|
def execute_remote_api
|
154
154
|
params.require(:params).permit!
|
155
155
|
parsed_params = params[:params].to_h.symbolize_keys
|
156
|
-
raise AccessViolation unless parsed_params[:authorization]
|
156
|
+
raise AccessViolation.new(:illegal_remote_api_call) unless parsed_params[:authorization]
|
157
157
|
render ServerOp.run_from_client(:authorization, self, params[:operation], parsed_params)
|
158
158
|
end
|
159
159
|
|
@@ -21,7 +21,7 @@ module Hyperstack
|
|
21
21
|
EXPOSED_METHODS = [
|
22
22
|
:regulate_class_connection, :always_allow_connection, :regulate_instance_connections,
|
23
23
|
:regulate_all_broadcasts, :regulate_broadcast,
|
24
|
-
:
|
24
|
+
:regulate_dispatches_from, :always_dispatch_from,
|
25
25
|
:allow_change, :allow_create, :allow_read, :allow_update, :allow_destroy
|
26
26
|
]
|
27
27
|
|
@@ -58,21 +58,6 @@ module Hyperstack
|
|
58
58
|
regulate_dispatches_from(*args) { true }
|
59
59
|
end
|
60
60
|
|
61
|
-
def dispatch_to(*args, ®ulation)
|
62
|
-
actual_klass = if regulated_klass.is_a?(Class)
|
63
|
-
regulated_klass
|
64
|
-
else
|
65
|
-
begin
|
66
|
-
regulated_klass.constantize
|
67
|
-
rescue NameError
|
68
|
-
nil
|
69
|
-
end
|
70
|
-
end
|
71
|
-
raise 'you can only dispatch_to Operation classes' unless actual_klass.respond_to? :dispatch_to
|
72
|
-
actual_klass.dispatch_to(actual_klass)
|
73
|
-
actual_klass.dispatch_to(*args, ®ulation)
|
74
|
-
end
|
75
|
-
|
76
61
|
CHANGE_POLICIES = [:create, :update, :destroy]
|
77
62
|
|
78
63
|
def self.allow_policy(policy, method)
|
@@ -379,8 +364,7 @@ module Hyperstack
|
|
379
364
|
end
|
380
365
|
|
381
366
|
def self.raise_operation_access_violation(message, details)
|
382
|
-
Hyperstack.
|
383
|
-
raise Hyperstack::AccessViolation
|
367
|
+
raise Hyperstack::AccessViolation.new(message, details)
|
384
368
|
end
|
385
369
|
|
386
370
|
def self.regulate_connection(acting_user, channel_string)
|
@@ -406,16 +390,17 @@ module Hyperstack
|
|
406
390
|
internal_policy.broadcast &block
|
407
391
|
end
|
408
392
|
|
409
|
-
def initialize(obj, attribute_names, available_channels)
|
393
|
+
def initialize(obj, attribute_names, available_channels = :all)
|
410
394
|
@obj = obj
|
411
|
-
attribute_names = attribute_names.map(&:to_sym).to_set
|
395
|
+
@attribute_names = attribute_names.map(&:to_sym).to_set
|
412
396
|
@unassigned_send_sets = []
|
413
|
-
@channel_sets = Hash.new { |hash, key| hash[key] = attribute_names }
|
397
|
+
@channel_sets = Hash.new { |hash, key| hash[key] = @attribute_names }
|
414
398
|
@available_channels = available_channels
|
415
399
|
end
|
416
400
|
|
417
401
|
def channel_available?(channel)
|
418
|
-
|
402
|
+
return false unless channel
|
403
|
+
@available_channels == :all || @available_channels.include?(channel_to_string(channel))
|
419
404
|
end
|
420
405
|
|
421
406
|
def id
|
@@ -0,0 +1,106 @@
|
|
1
|
+
module Hyperstack
|
2
|
+
class ClassConnectionRegulation
|
3
|
+
def self.connections(acting_user)
|
4
|
+
regulations.collect do |channel, regulation|
|
5
|
+
status = regulation.connectable?(acting_user) ? :allowed : :denied
|
6
|
+
{ type: :class, owner: channel, channel: InternalPolicy.channel_to_string(channel), auto_connect: !regulation.auto_connect_disabled?, status: status }
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class InstanceConnectionRegulation
|
12
|
+
def self.connections(acting_user)
|
13
|
+
regulations.collect do |channel, regulation|
|
14
|
+
regulation.connectable_to(acting_user, false).collect do |obj|
|
15
|
+
{ type: :instance, owner: channel, channel: InternalPolicy.channel_to_string(obj), auto_connect: !regulation.auto_connect_disabled?, status: :allowed }
|
16
|
+
end
|
17
|
+
end.flatten(1)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class InternalPolicy
|
22
|
+
def attribute_dump(acting_user)
|
23
|
+
# dump[channel]['@channel_status'] -> [owner, type, auto_connect, falsy/no connection/allowed]
|
24
|
+
# dump[channel][attribute] -> 'no connection/no channel/no policy/allowed'
|
25
|
+
dump = Hash.new { |h, k| h[k] = Hash.new }
|
26
|
+
connections = ClassConnectionRegulation.connections(acting_user) +
|
27
|
+
InstanceConnectionRegulation.connections(acting_user)
|
28
|
+
connections.each do |status|
|
29
|
+
status[:status] = 'allowed' if status[:status]
|
30
|
+
status[:status] ||= 'no connection'
|
31
|
+
dump[status[:channel]]['@channel_status'] = status
|
32
|
+
end
|
33
|
+
@channel_sets.each do |channel, attribute_set|
|
34
|
+
channel = InternalPolicy.channel_to_string(channel)
|
35
|
+
attribute_set.each do |attribute|
|
36
|
+
dump[channel]['@channel_status'] ||= { type: 'no channel' }
|
37
|
+
dump[channel][attribute] = dump[channel]['@channel_status'][:status] || 'no channel'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
dump.each_key do |channel|
|
41
|
+
@attribute_names.each do |attribute|
|
42
|
+
dump[channel][attribute] ||= 'no policy'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
dump
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
module PolicyDiagnostics
|
50
|
+
def self.policy_dump_hash(model, acting_user)
|
51
|
+
internal_policy = InternalPolicy.new(model, model.attribute_names, :all)
|
52
|
+
ChannelBroadcastRegulation.broadcast(internal_policy)
|
53
|
+
InstanceBroadcastRegulation.broadcast(model, internal_policy)
|
54
|
+
internal_policy.attribute_dump(acting_user)
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.policy_dump_for(model, acting_user)
|
58
|
+
dump = policy_dump_hash(model, acting_user)
|
59
|
+
attributes = model.attribute_names.map(&:to_sym)
|
60
|
+
acting_user_channel = InternalPolicy.channel_to_string(acting_user) if acting_user
|
61
|
+
pastel = Pastel.new
|
62
|
+
channels = dump.keys.collect do |channel|
|
63
|
+
c = channel == acting_user_channel ? "* #{channel} *" : channel
|
64
|
+
if dump[channel]['@channel_status'][:status] != 'allowed'
|
65
|
+
pastel.red(c)
|
66
|
+
elsif channel == acting_user_channel
|
67
|
+
pastel.blue(c)
|
68
|
+
else
|
69
|
+
c
|
70
|
+
end
|
71
|
+
end
|
72
|
+
table = TTY::Table.new header: [''] + channels
|
73
|
+
types = dump.keys.collect do |channel|
|
74
|
+
type = dump[channel]['@channel_status'][:type]
|
75
|
+
type = pastel.red(type) if type == 'no policy'
|
76
|
+
type
|
77
|
+
end
|
78
|
+
table << ['type'] + types
|
79
|
+
table << ['auto connect'] + dump.keys.collect { |channel| dump[channel]['@channel_status'][:auto_connect] }
|
80
|
+
table << ['status'] + dump.keys.collect { |channel| dump[channel]['@channel_status'][:status] }
|
81
|
+
attributes.each do |attribute|
|
82
|
+
allowed = false
|
83
|
+
statuses = dump.keys.collect do |channel|
|
84
|
+
status = dump[channel][attribute]
|
85
|
+
if status == 'allowed'
|
86
|
+
allowed = true
|
87
|
+
status
|
88
|
+
else
|
89
|
+
pastel.red(status)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
attribute = pastel.red(attribute) unless allowed
|
93
|
+
table << [attribute] + statuses
|
94
|
+
end
|
95
|
+
rendered = table.render(:unicode, indent: 4).split("\n")
|
96
|
+
rendered = rendered.insert(6, rendered[2]).join("\n")
|
97
|
+
model_string = "<##{model.class} id: #{model.id}>"
|
98
|
+
if acting_user
|
99
|
+
id = "id: #{acting_user.id}" if acting_user.respond_to? :id
|
100
|
+
acting_user_string = "by acting_user <##{acting_user.class} id: #{id}>"
|
101
|
+
end
|
102
|
+
" Attribute access policies for #{model_string} #{acting_user_string || 'with no acting_user'}:\n\n"\
|
103
|
+
"#{rendered}"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyper-operation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.alpha1.
|
4
|
+
version: 1.0.alpha1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mitch VanDuyn
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-01-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - '='
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 1.0.alpha1.
|
34
|
+
version: 1.0.alpha1.3
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - '='
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 1.0.alpha1.
|
41
|
+
version: 1.0.alpha1.3
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: mutations
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -68,19 +68,39 @@ dependencies:
|
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: 0.3.1
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
71
|
+
name: tty-table
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
|
-
type: :
|
77
|
+
type: :runtime
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: bundler
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 1.17.3
|
91
|
+
- - "<"
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '2.1'
|
94
|
+
type: :development
|
95
|
+
prerelease: false
|
96
|
+
version_requirements: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 1.17.3
|
101
|
+
- - "<"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.1'
|
84
104
|
- !ruby/object:Gem::Dependency
|
85
105
|
name: chromedriver-helper
|
86
106
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,14 +135,14 @@ dependencies:
|
|
115
135
|
requirements:
|
116
136
|
- - '='
|
117
137
|
- !ruby/object:Gem::Version
|
118
|
-
version: 1.0.alpha1.
|
138
|
+
version: 1.0.alpha1.3
|
119
139
|
type: :development
|
120
140
|
prerelease: false
|
121
141
|
version_requirements: !ruby/object:Gem::Requirement
|
122
142
|
requirements:
|
123
143
|
- - '='
|
124
144
|
- !ruby/object:Gem::Version
|
125
|
-
version: 1.0.alpha1.
|
145
|
+
version: 1.0.alpha1.3
|
126
146
|
- !ruby/object:Gem::Dependency
|
127
147
|
name: mysql2
|
128
148
|
requirement: !ruby/object:Gem::Requirement
|
@@ -400,6 +420,7 @@ files:
|
|
400
420
|
- lib/hyper-operation/transport/hyperstack_controller.rb
|
401
421
|
- lib/hyper-operation/transport/pluck.rb
|
402
422
|
- lib/hyper-operation/transport/policy.rb
|
423
|
+
- lib/hyper-operation/transport/policy_diagnostics.rb
|
403
424
|
- lib/hyper-operation/version.rb
|
404
425
|
- lib/sources/hyperstack/pusher.js
|
405
426
|
homepage: http://ruby-hyperstack.org
|
@@ -421,8 +442,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
421
442
|
- !ruby/object:Gem::Version
|
422
443
|
version: 1.3.1
|
423
444
|
requirements: []
|
424
|
-
|
425
|
-
rubygems_version: 2.7.8
|
445
|
+
rubygems_version: 3.0.2
|
426
446
|
signing_key:
|
427
447
|
specification_version: 4
|
428
448
|
summary: HyperOperations are the swiss army knife of the Hyperstack
|