Skip to content

Commit

Permalink
Added check to verify that plugin diretories are owned by root
Browse files Browse the repository at this point in the history
  • Loading branch information
abujeda committed Dec 9, 2024
1 parent 92583d9 commit f9ec615
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apps/dashboard/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class Application < Rails::Application
if plugins_dir.directory?
plugins_dir.children.select(&:directory?).each do |installed_plugin|
next unless installed_plugin.readable?
# Ignore plugins not installed by admins - plugin directory should be owned by root
next if ::Configuration.rails_env_production? && !File.stat(installed_plugin.to_s).uid.zero?

config.paths["config/initializers"] << installed_plugin.join("initializers").to_s
config.autoload_paths << installed_plugin.join("lib").to_s
Expand Down
4 changes: 4 additions & 0 deletions apps/dashboard/config/configuration_singleton.rb
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,10 @@ def connect_sources
sources
end

def rails_env_production?
rails_env == 'production'
end

private

def can_access_core_app?(name)
Expand Down
16 changes: 16 additions & 0 deletions apps/dashboard/test/config/configuration_singleton_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -535,4 +535,20 @@ def no_config_env
assert_equal(30_000, ConfigurationSingleton.new.bc_sessions_poll_delay)
end
end

test "rails_env_production? should return true if production environment" do
with_modified_env(RAILS_ENV: 'production') do
assert ConfigurationSingleton.new.rails_env_production?
end
end

test "rails_env_production? should return false if development or test environment" do
with_modified_env(RAILS_ENV: 'development') do
refute ConfigurationSingleton.new.rails_env_production?
end

with_modified_env(RAILS_ENV: 'test') do
refute ConfigurationSingleton.new.rails_env_production?
end
end
end

0 comments on commit f9ec615

Please sign in to comment.