mirror of
https://github.com/usetrmnl/image_processing.git
synced 2026-08-13 14:27:14 -07:00
Don't allow calling Kernel methods via loader/saver options
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
## HEAD
|
||||
|
||||
* [minimagick] Don't allow calling Kernel options via `loader`/`saver` options (@janko)
|
||||
|
||||
## 1.12.2 (2022-03-01)
|
||||
|
||||
* Prevent remote shell execution when using `#apply` with operations coming from user input (@janko)
|
||||
|
||||
@@ -213,9 +213,9 @@ module ImageProcessing
|
||||
def apply_options(magick, define: {}, **options)
|
||||
options.each do |option, value|
|
||||
case value
|
||||
when true, nil then magick.send(option)
|
||||
when false then magick.send(option).+
|
||||
else magick.send(option, *value)
|
||||
when true, nil then magick.public_send(option)
|
||||
when false then magick.public_send(option).+
|
||||
else magick.public_send(option, *value)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -173,6 +173,26 @@ describe "ImageProcessing::MiniMagick" do
|
||||
assert_dimensions [600, 800], result
|
||||
end
|
||||
|
||||
it "doesn't allow calling Kernel methods via loader/saver options" do
|
||||
error = assert_raises(MiniMagick::Error) do
|
||||
ImageProcessing::MiniMagick
|
||||
.source(@portrait)
|
||||
.loader(system: "touch test/malicious.txt")
|
||||
.call
|
||||
end
|
||||
|
||||
assert_match "unrecognized option `-system'", error.message
|
||||
|
||||
error = assert_raises(MiniMagick::Error) do
|
||||
ImageProcessing::MiniMagick
|
||||
.source(@portrait)
|
||||
.saver(system: "touch test/malicious.txt")
|
||||
.call
|
||||
end
|
||||
|
||||
assert_match "unrecognized option `-system'", error.message
|
||||
end
|
||||
|
||||
describe ".valid_image?" do
|
||||
it "returns true for correct images" do
|
||||
assert ImageProcessing::MiniMagick.valid_image?(@portrait)
|
||||
|
||||
Reference in New Issue
Block a user