From: Claire Date: Thu, 8 Jun 2023 07:34:45 +0000 (+0200) Subject: Add a restrictive ImageMagick security policy tailored for Mastodon X-Git-Url: https://git.xn--scling-oua.cat.family/?a=commitdiff_plain;h=3ab19c7bcc21c0db7220476dda5103a4aeaa63a9;p=mastodon.git Add a restrictive ImageMagick security policy tailored for Mastodon Signed-off-by: Claire --- diff --git a/config/imagemagick/policy.xml b/config/imagemagick/policy.xml new file mode 100644 index 000000000..1052476b3 --- /dev/null +++ b/config/imagemagick/policy.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb index 26b0a2f7c..7cccccd8e 100644 --- a/config/initializers/paperclip.rb +++ b/config/initializers/paperclip.rb @@ -146,3 +146,10 @@ unless defined?(Seahorse) end end end + +# Set our ImageMagick security policy, but allow admins to override it +ENV['MAGICK_CONFIGURE_PATH'] = begin + imagemagick_config_paths = ENV.fetch('MAGICK_CONFIGURE_PATH', '').split(File::PATH_SEPARATOR) + imagemagick_config_paths << Rails.root.join('config', 'imagemagick').expand_path.to_s + imagemagick_config_paths.join(File::PATH_SEPARATOR) +end