From f752f82658a1746207457af4caf4edfa3d8e5436 Mon Sep 17 00:00:00 2001 From: Luka Murn Date: Fri, 26 Jan 2018 16:24:28 +0100 Subject: [PATCH] Fix canaid initializer so it only uses required Gems' permissions This should make sure that other addons that are located in /addons folder, but not actually required by the core, do not cause trouble. --- config/initializers/canaid.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/config/initializers/canaid.rb b/config/initializers/canaid.rb index d7a2a6614..716dd6989 100644 --- a/config/initializers/canaid.rb +++ b/config/initializers/canaid.rb @@ -1,4 +1,19 @@ Canaid.configure do |config| + include AddonsHelper + config.permissions_paths << 'app/permissions/**/*.rb' - config.permissions_paths << 'addons/**/app/permissions/**/*.rb' + + # Include the included addons' permissions folders + rx = %r{^.*(addons/.*/app/permissions)$} + list_all_addons.each do |addon| + full_path = addon::Engine + .instance + .config + .eager_load_paths + .select { |p| p.ends_with?('permissions') } + .first + continue unless full_path + res = rx.match(full_path) + config.permissions_paths << "#{res[1]}/**/*.rb" if res && res.length > 1 + end end \ No newline at end of file