rails-acu 3.0.3 → 3.0.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.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -0
  3. data/.project +0 -0
  4. data/.rspec +0 -0
  5. data/.travis.yml +2 -2
  6. data/Gemfile +3 -0
  7. data/Gemfile.lock +6 -5
  8. data/MIT-LICENSE +0 -0
  9. data/README.md +8 -0
  10. data/Rakefile +0 -0
  11. data/lib/acu/configs.rb +0 -0
  12. data/lib/acu/engine.rb +0 -0
  13. data/lib/acu/errors.rb +0 -0
  14. data/lib/acu/helpers/helpers.rb +7 -1
  15. data/lib/acu/listeners.rb +0 -0
  16. data/lib/acu/monitor.rb +0 -0
  17. data/lib/acu/rules.rb +17 -2
  18. data/lib/acu/utilities.rb +0 -0
  19. data/lib/acu/version.rb +1 -1
  20. data/lib/generators/acu/install_generator.rb +0 -0
  21. data/lib/generators/templates/rules.rb +0 -0
  22. data/lib/generators/templates/setup.rb +0 -0
  23. data/lib/rails-acu.rb +0 -0
  24. data/rails-acu.gemspec +0 -0
  25. data/spec/dummy/Rakefile +0 -0
  26. data/spec/dummy/app/assets/config/manifest.js +0 -0
  27. data/spec/dummy/app/assets/javascripts/admin/booking/chats.js +0 -0
  28. data/spec/dummy/app/assets/javascripts/admin/booking/lists.js +0 -0
  29. data/spec/dummy/app/assets/javascripts/admin/manage.js +0 -0
  30. data/spec/dummy/app/assets/javascripts/application.js +0 -0
  31. data/spec/dummy/app/assets/javascripts/books.js +0 -0
  32. data/spec/dummy/app/assets/javascripts/cable.js +0 -0
  33. data/spec/dummy/app/assets/javascripts/comments.js +0 -0
  34. data/spec/dummy/app/assets/javascripts/home.js +0 -0
  35. data/spec/dummy/app/assets/stylesheets/admin/booking/chats.css +0 -0
  36. data/spec/dummy/app/assets/stylesheets/admin/booking/lists.css +0 -0
  37. data/spec/dummy/app/assets/stylesheets/admin/manage.css +0 -0
  38. data/spec/dummy/app/assets/stylesheets/application.css +0 -0
  39. data/spec/dummy/app/assets/stylesheets/books.css +0 -0
  40. data/spec/dummy/app/assets/stylesheets/comments.css +0 -0
  41. data/spec/dummy/app/assets/stylesheets/home.css +0 -0
  42. data/spec/dummy/app/assets/stylesheets/scaffold.css +0 -0
  43. data/spec/dummy/app/channels/application_cable/channel.rb +0 -0
  44. data/spec/dummy/app/channels/application_cable/connection.rb +0 -0
  45. data/spec/dummy/app/controllers/admin/booking/chats_controller.rb +0 -0
  46. data/spec/dummy/app/controllers/admin/booking/lists_controller.rb +0 -0
  47. data/spec/dummy/app/controllers/admin/manage_controller.rb +0 -0
  48. data/spec/dummy/app/controllers/application_controller.rb +0 -0
  49. data/spec/dummy/app/controllers/home_controller.rb +0 -0
  50. data/spec/dummy/app/helpers/admin/booking/chats_helper.rb +0 -0
  51. data/spec/dummy/app/helpers/admin/booking/lists_helper.rb +0 -0
  52. data/spec/dummy/app/helpers/admin/manage_helper.rb +0 -0
  53. data/spec/dummy/app/helpers/application_helper.rb +0 -0
  54. data/spec/dummy/app/helpers/home_helper.rb +0 -0
  55. data/spec/dummy/app/jobs/application_job.rb +0 -0
  56. data/spec/dummy/app/mailers/application_mailer.rb +0 -0
  57. data/spec/dummy/app/models/admin/booking.rb +0 -0
  58. data/spec/dummy/app/models/admin/booking/chat.rb +0 -0
  59. data/spec/dummy/app/models/admin/booking/list.rb +0 -0
  60. data/spec/dummy/app/models/application_record.rb +0 -0
  61. data/spec/dummy/app/models/user.rb +0 -0
  62. data/spec/dummy/app/models/user_type.rb +0 -0
  63. data/spec/dummy/app/views/admin/booking/chats/_form.html.erb +0 -0
  64. data/spec/dummy/app/views/admin/booking/chats/edit.html.erb +0 -0
  65. data/spec/dummy/app/views/admin/booking/chats/index.html.erb +0 -0
  66. data/spec/dummy/app/views/admin/booking/chats/new.html.erb +0 -0
  67. data/spec/dummy/app/views/admin/booking/chats/show.html.erb +0 -0
  68. data/spec/dummy/app/views/admin/booking/lists/_form.html.erb +0 -0
  69. data/spec/dummy/app/views/admin/booking/lists/edit.html.erb +0 -0
  70. data/spec/dummy/app/views/admin/booking/lists/index.html.erb +0 -0
  71. data/spec/dummy/app/views/admin/booking/lists/new.html.erb +0 -0
  72. data/spec/dummy/app/views/admin/booking/lists/show.html.erb +0 -0
  73. data/spec/dummy/app/views/admin/manage/add.html.erb +0 -0
  74. data/spec/dummy/app/views/admin/manage/delete.html.erb +0 -0
  75. data/spec/dummy/app/views/admin/manage/index.html.erb +0 -0
  76. data/spec/dummy/app/views/admin/manage/list.html.erb +0 -0
  77. data/spec/dummy/app/views/admin/manage/prove.html.erb +0 -0
  78. data/spec/dummy/app/views/admin/manage/show.html.erb +0 -0
  79. data/spec/dummy/app/views/home/contact.html.erb +0 -0
  80. data/spec/dummy/app/views/home/index.html.erb +0 -0
  81. data/spec/dummy/app/views/layouts/application.html.erb +0 -0
  82. data/spec/dummy/app/views/layouts/mailer.html.erb +0 -0
  83. data/spec/dummy/app/views/layouts/mailer.text.erb +0 -0
  84. data/spec/dummy/config.ru +0 -0
  85. data/spec/dummy/config/application.rb +0 -0
  86. data/spec/dummy/config/boot.rb +0 -0
  87. data/spec/dummy/config/cable.yml +0 -0
  88. data/spec/dummy/config/database.yml +0 -0
  89. data/spec/dummy/config/environment.rb +0 -0
  90. data/spec/dummy/config/environments/development.rb +0 -0
  91. data/spec/dummy/config/environments/production.rb +0 -0
  92. data/spec/dummy/config/environments/test.rb +0 -0
  93. data/spec/dummy/config/initializers/acu_rules.rb +0 -0
  94. data/spec/dummy/config/initializers/acu_setup.rb +0 -0
  95. data/spec/dummy/config/initializers/application_controller_renderer.rb +0 -0
  96. data/spec/dummy/config/initializers/assets.rb +0 -0
  97. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -0
  98. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -0
  99. data/spec/dummy/config/initializers/devise.rb +0 -0
  100. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -0
  101. data/spec/dummy/config/initializers/inflections.rb +0 -0
  102. data/spec/dummy/config/initializers/mime_types.rb +0 -0
  103. data/spec/dummy/config/initializers/new_framework_defaults.rb +0 -0
  104. data/spec/dummy/config/initializers/session_store.rb +0 -0
  105. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -0
  106. data/spec/dummy/config/locales/devise.en.yml +0 -0
  107. data/spec/dummy/config/locales/en.yml +0 -0
  108. data/spec/dummy/config/puma.rb +0 -0
  109. data/spec/dummy/config/routes.rb +0 -0
  110. data/spec/dummy/config/secrets.yml +0 -0
  111. data/spec/dummy/config/spring.rb +0 -0
  112. data/spec/dummy/db/migrate/20170329111257_create_books.rb +0 -0
  113. data/spec/dummy/db/migrate/20170329111323_create_comments.rb +0 -0
  114. data/spec/dummy/db/migrate/20170329114943_devise_create_users.rb +0 -0
  115. data/spec/dummy/db/migrate/20170329120950_create_admin_user_types.rb +0 -0
  116. data/spec/dummy/db/migrate/20170329121612_add_user_type_id_to_users.rb +0 -0
  117. data/spec/dummy/db/migrate/20170506054319_create_admin_booking_lists.rb +0 -0
  118. data/spec/dummy/db/migrate/20170506081928_create_admin_booking_chats.rb +0 -0
  119. data/spec/dummy/db/schema.rb +0 -0
  120. data/spec/dummy/db/seeds.rb +0 -0
  121. data/spec/dummy/public/404.html +0 -0
  122. data/spec/dummy/public/422.html +0 -0
  123. data/spec/dummy/public/500.html +0 -0
  124. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  125. data/spec/dummy/public/apple-touch-icon.png +0 -0
  126. data/spec/dummy/public/favicon.ico +0 -0
  127. data/spec/dummy/spec/controllers/admin/booking/chats_controller_spec.rb +0 -0
  128. data/spec/dummy/spec/controllers/admin/booking/lists_controller_spec.rb +0 -0
  129. data/spec/dummy/spec/controllers/admin/manage_controller_spec.rb +0 -0
  130. data/spec/dummy/spec/controllers/application_controller_spec.rb +0 -0
  131. data/spec/dummy/spec/controllers/home_controller_spec.rb +26 -0
  132. data/spec/rails_helper.rb +0 -0
  133. data/spec/spec_helper.rb +0 -0
  134. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 123859955ecca0946fcf6fa035b496cfa33288b2
4
- data.tar.gz: f40b6bffd605127cdc3670385c22e160f0282f3d
3
+ metadata.gz: 4f50692b816fca643b3e84d4d1df13fe2ffabb6d
4
+ data.tar.gz: 0b84f06cdfc0d7f9afc943b518fa497252ebfba0
5
5
  SHA512:
6
- metadata.gz: 4ff706de1febaa671c88d7d71c757645f5ef1dd12891b994117ccd1da1a077f1a1098009dc7a3708f2159ddc30b5fa90c29b481f62fb85e233868da2775ad65d
7
- data.tar.gz: a68cec0ae7ffcebe783c5102064141f52dce64cb3d29fcc450fc324da1f2b2595815d6582ad9aa4190f8180cb121c388c61ce92a2d039ce953236bfa798e812d
6
+ metadata.gz: b2a8d834f7029c6b280d84286212d8b8fc03602fd6d22e1d493b89106828f4c836d85b59325700bb84eebbf49c4a7d4808379561d699531b39ddc9e5a93deac5
7
+ data.tar.gz: 15e6e64d16586ee43948289b9e697ed487d27e0f5816ccaeb74f6c27a6a131e3c846caef39bf06b45e7bdf495c7eb7e51a54930e78129a89718200fe284ee70b
data/.gitignore CHANGED
File without changes
data/.project CHANGED
File without changes
data/.rspec CHANGED
File without changes
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 2.4.0
4
+ - 2.4.1
5
5
 
6
6
  cache: bundler
7
7
 
@@ -27,4 +27,4 @@ script:
27
27
  notifications:
28
28
  email:
29
29
  recipients:
30
- - b.g.dariush@gmail.com
30
+ - b.g.dariush@gmail.com
data/Gemfile CHANGED
@@ -17,6 +17,9 @@ gemspec
17
17
  # Git. Remember to move these dependencies to your gemspec before releasing
18
18
  # your gem to rubygems.org.
19
19
 
20
+ # to fix security bug CVE-2018-3760
21
+ gem 'sprockets', '~> 3.7.2'
22
+
20
23
  # To use a debugger
21
24
  # gem 'byebug', group: [:development, :test]
22
25
 
data/Gemfile.lock CHANGED
@@ -7,8 +7,8 @@ GIT
7
7
  PATH
8
8
  remote: .
9
9
  specs:
10
- rails-acu (3.0.2)
11
- rails (~> 5.2.0)
10
+ rails-acu (3.0.4)
11
+ rails (>= 5.0.0)
12
12
 
13
13
  GEM
14
14
  remote: https://rubygems.org/
@@ -85,7 +85,7 @@ GEM
85
85
  mimemagic (~> 0.3.2)
86
86
  method_source (0.9.0)
87
87
  mimemagic (0.3.2)
88
- mini_mime (1.0.0)
88
+ mini_mime (1.0.1)
89
89
  mini_portile2 (2.3.0)
90
90
  minitest (5.11.3)
91
91
  nio4r (2.3.1)
@@ -144,7 +144,7 @@ GEM
144
144
  rspec-mocks (~> 3.7.0)
145
145
  rspec-support (~> 3.7.0)
146
146
  rspec-support (3.7.1)
147
- sprockets (3.7.1)
147
+ sprockets (3.7.2)
148
148
  concurrent-ruby (~> 1.0)
149
149
  rack (> 1, < 3)
150
150
  sprockets-rails (3.2.1)
@@ -173,10 +173,11 @@ DEPENDENCIES
173
173
  rails-acu!
174
174
  rails-controller-testing
175
175
  rspec-rails (~> 3.5)
176
+ sprockets (~> 3.7.2)
176
177
  sqlite3
177
178
 
178
179
  RUBY VERSION
179
180
  ruby 2.4.1p111
180
181
 
181
182
  BUNDLED WITH
182
- 1.16.1
183
+ 1.16.2
data/MIT-LICENSE CHANGED
File without changes
data/README.md CHANGED
@@ -94,6 +94,14 @@ Acu::Rules.define do
94
94
  allow :client
95
95
  end
96
96
  end
97
+
98
+ # negated entities (since v3.0.4)
99
+ namespace do
100
+ controller :profile do
101
+ # only owners can edit the profile page
102
+ deny :not_owner, on: [:edit]
103
+ end
104
+ end
97
105
  end
98
106
  ```
99
107
 
data/Rakefile CHANGED
File without changes
data/lib/acu/configs.rb CHANGED
File without changes
data/lib/acu/engine.rb CHANGED
File without changes
data/lib/acu/errors.rb CHANGED
File without changes
@@ -1,6 +1,12 @@
1
1
  def acu_is? symbol
2
2
  flag = false
3
- [symbol].flatten.each { |s| flag |= Acu::Monitor.valid_for? s }
3
+ [symbol].flatten.each do |s|
4
+ if s.to_s =~ /\Anot_/
5
+ flag |= not(Acu::Monitor.valid_for?(s.to_s.gsub(/\Anot_/, "").to_sym))
6
+ else
7
+ flag |= Acu::Monitor.valid_for? s
8
+ end
9
+ end
4
10
  flag
5
11
  end
6
12
 
data/lib/acu/listeners.rb CHANGED
File without changes
data/lib/acu/monitor.rb CHANGED
File without changes
data/lib/acu/rules.rb CHANGED
@@ -111,6 +111,7 @@ module Acu
111
111
 
112
112
  def op *symbol, opr, on
113
113
  symbol = symbol.flatten
114
+ process_symbol *symbol
114
115
  raise Errors::InvalidData.new("invalid argument") if not symbol or symbol.to_s.blank? or opr.to_s.blank?
115
116
  raise Errors::AmbiguousRule.new("cannot have `on` argument inside the action `#{@_params[:action][:name]}`") if not on.empty? and (@_params[:action] and not @_params[:action].empty?)
116
117
  raise Errors::InvalidData.new("the symbol `#{symbol}` is not defined by `whois`") if not symbol.all? { |s| @entities.include? s }
@@ -123,9 +124,23 @@ module Acu
123
124
  end
124
125
  end
125
126
 
126
- def build_rule rule
127
+ def process_symbol *symbols
128
+ symbols.each do |symbol|
129
+ # check if negated symbol used?
130
+ if symbol.to_s.downcase =~ /\Anot_/ and not @entities.include?(symbol)
131
+ # remove the not symbol
132
+ not_symbol = (symbol.to_s.gsub /\Anot_/, "").to_sym
133
+ # add the negated symbol
134
+ whois(symbol, args: @entities[not_symbol][:args]) { |*args| not @entities[not_symbol][:callback].call(*args) }
135
+ end
136
+ end
137
+ end
138
+
139
+ def build_rule *_rules
127
140
  @rules[@_params.deep_dup] ||= {}
128
- @rules[@_params.deep_dup] = rules[@_params.clone].merge(rule);
141
+ _rules.each do |rule|
142
+ @rules[@_params.deep_dup] = @rules[@_params.clone].merge(rule);
143
+ end
129
144
  end
130
145
 
131
146
  def build_rule_entry
data/lib/acu/utilities.rb CHANGED
File without changes
data/lib/acu/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Acu
2
- VERSION = '3.0.3'
2
+ VERSION = '3.0.6'
3
3
  end
File without changes
File without changes
File without changes
data/lib/rails-acu.rb CHANGED
File without changes
data/rails-acu.gemspec CHANGED
File without changes
data/spec/dummy/Rakefile CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
data/spec/dummy/config.ru CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -428,6 +428,32 @@ RSpec.describe HomeController, type: :controller do
428
428
  expect {get :contact}.to raise_error(Acu::Errors::AccessDenied)
429
429
  expect(`tail -n 1 #{Acu::Configs.get :audit_log_file}`).to match /access DENIED to.*namespace=\[nil\].*controller=\["home"\].*action=\["contact"\].*as `:everyone`/
430
430
  end
431
+ it "[negated entities]" do
432
+ Acu::Rules.define do
433
+ whois :everyone { true }
434
+ whois :client { false }
435
+ namespace do
436
+ controller :home do
437
+ deny :not_client, on: [:index, :contact]
438
+ end
439
+ end
440
+ end
441
+ expect {get :index}.to raise_error(Acu::Errors::AccessDenied)
442
+ expect(`tail -n 1 #{Acu::Configs.get :audit_log_file}`).to match /access DENIED to.*namespace=\[nil\].*controller=\["home"\].*action=\["index"\].*as `:not_client`/
443
+ expect {get :contact}.to raise_error(Acu::Errors::AccessDenied)
444
+ expect(`tail -n 1 #{Acu::Configs.get :audit_log_file}`).to match /access DENIED to.*namespace=\[nil\].*controller=\["home"\].*action=\["contact"\].*as `:not_client`/
445
+ Acu::Rules.define do
446
+ namespace do
447
+ controller :home do
448
+ allow :not_client, on: [:index, :contact]
449
+ end
450
+ end
451
+ end
452
+ get :index
453
+ expect(`tail -n 1 #{Acu::Configs.get :audit_log_file}`).to match /access GRANTED to.*namespace=\[nil\].*controller=\["home"\].*action=\["index"\].*as `:not_client`/
454
+ get :contact
455
+ expect(`tail -n 1 #{Acu::Configs.get :audit_log_file}`).to match /access GRANTED to.*namespace=\[nil\].*controller=\["home"\].*action=\["contact"\].*as `:not_client`/
456
+ end
431
457
  end
432
458
  context "[bulk settings]" do
433
459
  it "[allow/deny]" do
data/spec/rails_helper.rb CHANGED
File without changes
data/spec/spec_helper.rb CHANGED
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-acu
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dariush Hasanpour
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-11 00:00:00.000000000 Z
11
+ date: 2018-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails