From 3ab19c7bcc21c0db7220476dda5103a4aeaa63a9 Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 8 Jun 2023 09:34:45 +0200 Subject: [PATCH] Add a restrictive ImageMagick security policy tailored for Mastodon Signed-off-by: Claire --- config/imagemagick/policy.xml | 27 +++++++++++++++++++++++++++ config/initializers/paperclip.rb | 7 +++++++ 2 files changed, 34 insertions(+) create mode 100644 config/imagemagick/policy.xml 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 -- 2.47.3