Compare commits
10 Commits
3376ed0c4f
...
2f954f1790
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f954f1790 | ||
|
|
93b78968b3 | ||
|
|
94b425e703 | ||
|
|
936a33f0d7 | ||
|
|
4c1bc6e109 | ||
|
|
090e719b85 | ||
|
|
78c037b408 | ||
|
|
4bfeeeb88c | ||
|
|
09fee17242 | ||
|
|
560fb3529a |
47
CVE-2019-13574-1.patch
Normal file
47
CVE-2019-13574-1.patch
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
From 4cd5081e58810d3394d27a67219e8e4e0445d851 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Janko=20Marohni=C4=87?= <janko.marohnic@gmail.com>
|
||||||
|
Date: Sun, 26 May 2019 17:30:14 +0200
|
||||||
|
Subject: [PATCH] Don't allow remote shell execution
|
||||||
|
|
||||||
|
Kernel#open accepts a string of format "| <shell command>" which
|
||||||
|
executes the specified shell command and otherwise presumably acts as
|
||||||
|
IO.popen. The open-uri standard library overrides Kernel#open to also
|
||||||
|
accept URLs.
|
||||||
|
|
||||||
|
However, the overridden Kernel#open just delegates to URI#open, so we
|
||||||
|
switch to using that directly and avoid the remote shell execution
|
||||||
|
vulnerability. For files we just use File.open, which should have the
|
||||||
|
same behaviour as Kernel#open.
|
||||||
|
---
|
||||||
|
lib/mini_magick/image.rb | 14 ++++++--------
|
||||||
|
spec/lib/mini_magick/image_spec.rb | 8 ++++++++
|
||||||
|
2 files changed, 14 insertions(+), 8 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lib/mini_magick/image.rb b/lib/mini_magick/image.rb
|
||||||
|
index a1f47c6..0ac4780 100644
|
||||||
|
--- a/lib/mini_magick/image.rb
|
||||||
|
+++ b/lib/mini_magick/image.rb
|
||||||
|
@@ -82,17 +82,15 @@ def self.import_pixels(blob, columns, rows, depth, map, format = 'png')
|
||||||
|
def self.open(path_or_url, ext = nil, options = {})
|
||||||
|
options, ext = ext, nil if ext.is_a?(Hash)
|
||||||
|
|
||||||
|
- ext ||=
|
||||||
|
- if File.exist?(path_or_url)
|
||||||
|
- File.extname(path_or_url)
|
||||||
|
- else
|
||||||
|
- File.extname(URI(path_or_url).path)
|
||||||
|
- end
|
||||||
|
+ uri = URI(path_or_url.to_s)
|
||||||
|
|
||||||
|
+ ext ||= File.extname(uri.path)
|
||||||
|
ext.sub!(/:.*/, '') # hack for filenames or URLs that include a colon
|
||||||
|
|
||||||
|
- Kernel.open(path_or_url, "rb", options) do |file|
|
||||||
|
- read(file, ext)
|
||||||
|
+ if uri.is_a?(URI::HTTP) || uri.is_a?(URI::FTP)
|
||||||
|
+ uri.open(options) { |file| read(file, ext) }
|
||||||
|
+ else
|
||||||
|
+ File.open(uri.to_s, "rb", options) { |file| read(file, ext) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
66
CVE-2019-13574-2.patch
Normal file
66
CVE-2019-13574-2.patch
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
From 4cd5081e58810d3394d27a67219e8e4e0445d851 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Janko=20Marohni=C4=87?= <janko.marohnic@gmail.com>
|
||||||
|
Date: Sun, 26 May 2019 17:30:14 +0200
|
||||||
|
Subject: [PATCH] Don't allow remote shell execution
|
||||||
|
|
||||||
|
Kernel#open accepts a string of format "| <shell command>" which
|
||||||
|
executes the specified shell command and otherwise presumably acts as
|
||||||
|
IO.popen. The open-uri standard library overrides Kernel#open to also
|
||||||
|
accept URLs.
|
||||||
|
|
||||||
|
However, the overridden Kernel#open just delegates to URI#open, so we
|
||||||
|
switch to using that directly and avoid the remote shell execution
|
||||||
|
vulnerability. For files we just use File.open, which should have the
|
||||||
|
same behaviour as Kernel#open.
|
||||||
|
---
|
||||||
|
lib/mini_magick/image.rb | 14 ++++++--------
|
||||||
|
spec/lib/mini_magick/image_spec.rb | 8 ++++++++
|
||||||
|
2 files changed, 14 insertions(+), 8 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lib/mini_magick/image.rb b/lib/mini_magick/image.rb
|
||||||
|
index a1f47c6..0ac4780 100644
|
||||||
|
--- a/lib/mini_magick/image.rb
|
||||||
|
+++ b/lib/mini_magick/image.rb
|
||||||
|
@@ -82,17 +82,15 @@ def self.import_pixels(blob, columns, rows, depth, map, format = 'png')
|
||||||
|
def self.open(path_or_url, ext = nil, options = {})
|
||||||
|
options, ext = ext, nil if ext.is_a?(Hash)
|
||||||
|
|
||||||
|
- ext ||=
|
||||||
|
- if File.exist?(path_or_url)
|
||||||
|
- File.extname(path_or_url)
|
||||||
|
- else
|
||||||
|
- File.extname(URI(path_or_url).path)
|
||||||
|
- end
|
||||||
|
+ uri = URI(path_or_url.to_s)
|
||||||
|
|
||||||
|
+ ext ||= File.extname(uri.path)
|
||||||
|
ext.sub!(/:.*/, '') # hack for filenames or URLs that include a colon
|
||||||
|
|
||||||
|
- Kernel.open(path_or_url, "rb", options) do |file|
|
||||||
|
- read(file, ext)
|
||||||
|
+ if uri.is_a?(URI::HTTP) || uri.is_a?(URI::FTP)
|
||||||
|
+ uri.open(options) { |file| read(file, ext) }
|
||||||
|
+ else
|
||||||
|
+ File.open(uri.to_s, "rb", options) { |file| read(file, ext) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
diff --git a/spec/lib/mini_magick/image_spec.rb b/spec/lib/mini_magick/image_spec.rb
|
||||||
|
index 192d834..00f9cb0 100644
|
||||||
|
--- a/spec/lib/mini_magick/image_spec.rb
|
||||||
|
+++ b/spec/lib/mini_magick/image_spec.rb
|
||||||
|
@@ -76,6 +76,14 @@
|
||||||
|
expect(File.extname(image.path)).to eq ".jpg"
|
||||||
|
end
|
||||||
|
|
||||||
|
+ it "doesn't allow remote shell execution" do
|
||||||
|
+ expect {
|
||||||
|
+ described_class.open("| touch file.txt") # Kernel#open accepts this
|
||||||
|
+ }.to raise_error(URI::InvalidURIError)
|
||||||
|
+
|
||||||
|
+ expect(File.exist?("file.txt")).to eq(false)
|
||||||
|
+ end
|
||||||
|
+
|
||||||
|
it "accepts open-uri options" do
|
||||||
|
stub_request(:get, "http://example.com/image.jpg")
|
||||||
|
.with(headers: {"Foo" => "Bar"})
|
||||||
12
fix-URI-InvalidURIError-no-such-file-directory.patch
Normal file
12
fix-URI-InvalidURIError-no-such-file-directory.patch
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
diff -Nur a/spec/lib/mini_magick/image_spec.rb b/spec/lib/mini_magick/image_spec.rb
|
||||||
|
--- a/spec/lib/mini_magick/image_spec.rb 2022-02-25 09:21:57.370368608 +0800
|
||||||
|
+++ b/spec/lib/mini_magick/image_spec.rb 2022-02-25 09:24:14.804683516 +0800
|
||||||
|
@@ -79,7 +79,7 @@
|
||||||
|
it "doesn't allow remote shell execution" do
|
||||||
|
expect {
|
||||||
|
described_class.open("| touch file.txt") # Kernel#open accepts this
|
||||||
|
- }.to raise_error(URI::InvalidURIError)
|
||||||
|
+ }.to raise_error(Errno::ENOENT)
|
||||||
|
|
||||||
|
expect(File.exist?("file.txt")).to eq(false)
|
||||||
|
end
|
||||||
39
fix-no-implicit-conversion-of-hash-into-integer.patch
Normal file
39
fix-no-implicit-conversion-of-hash-into-integer.patch
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
diff -Nur a/lib/mini_magick/image.rb b/lib/mini_magick/image.rb
|
||||||
|
--- a/lib/mini_magick/image.rb 2022-02-24 19:57:09.378499137 +0800
|
||||||
|
+++ b/lib/mini_magick/image.rb 2022-02-24 20:01:25.738826593 +0800
|
||||||
|
@@ -82,15 +82,30 @@
|
||||||
|
def self.open(path_or_url, ext = nil, options = {})
|
||||||
|
options, ext = ext, nil if ext.is_a?(Hash)
|
||||||
|
|
||||||
|
- uri = URI(path_or_url.to_s)
|
||||||
|
+ # Don't use Kernel#open, but reuse its logic
|
||||||
|
+ openable =
|
||||||
|
+ if path_or_url.respond_to?(:open)
|
||||||
|
+ path_or_url
|
||||||
|
+ elsif path_or_url.respond_to?(:to_str) &&
|
||||||
|
+ %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ path_or_url &&
|
||||||
|
+ (uri = URI.parse(path_or_url)).respond_to?(:open)
|
||||||
|
+ uri
|
||||||
|
+ else
|
||||||
|
+ options = { binmode: true }.merge(options)
|
||||||
|
+ Pathname(path_or_url)
|
||||||
|
+ end
|
||||||
|
|
||||||
|
- ext ||= File.extname(uri.path)
|
||||||
|
+ if openable.is_a?(URI::Generic)
|
||||||
|
+ ext ||= File.extname(openable.path)
|
||||||
|
+ else
|
||||||
|
+ ext ||= File.extname(openable.to_s)
|
||||||
|
+ end
|
||||||
|
ext.sub!(/:.*/, '') # hack for filenames or URLs that include a colon
|
||||||
|
|
||||||
|
- if uri.is_a?(URI::HTTP) || uri.is_a?(URI::FTP)
|
||||||
|
- uri.open(options) { |file| read(file, ext) }
|
||||||
|
+ if openable.is_a?(URI::Generic)
|
||||||
|
+ openable.open(options) { |file| read(file, ext) }
|
||||||
|
else
|
||||||
|
- File.open(uri.to_s, "rb", options) { |file| read(file, ext) }
|
||||||
|
+ openable.open(**options) { |file| read(file, ext) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
From ea9df8283b4d2c354f0f1887ea29f742913d44b7 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Pavel Valena <pvalena@redhat.com>
|
|
||||||
Date: Tue, 5 Jun 2018 18:06:47 +0200
|
|
||||||
Subject: [PATCH] Fix test: Use smallcase for MiniMagick::Image#details
|
|
||||||
|
|
||||||
`MiniMagick::Image#details` has been deprecated, as it was causing too many parsing errors. You should use MiniMagick::Image#data instead, which differs in a way that the keys are in camelcase.
|
|
||||||
---
|
|
||||||
spec/lib/mini_magick/image_spec.rb | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/spec/lib/mini_magick/image_spec.rb b/spec/lib/mini_magick/image_spec.rb
|
|
||||||
index 784d01a..b240516 100644
|
|
||||||
--- a/spec/lib/mini_magick/image_spec.rb
|
|
||||||
+++ b/spec/lib/mini_magick/image_spec.rb
|
|
||||||
@@ -420,7 +420,7 @@ def create(path = image_path)
|
|
||||||
it "returns a hash of verbose information" do
|
|
||||||
expect(subject.details["Format"]).to match /^JPEG/
|
|
||||||
if MiniMagick.cli == :imagemagick
|
|
||||||
- expect(subject.details["Channel depth"]["Red"]).to eq "8-bit"
|
|
||||||
+ expect(subject.details["Channel depth"]["red"]).to eq "8-bit"
|
|
||||||
expect(subject.details).to have_key("Background color")
|
|
||||||
expect(subject.details["Properties"]).to have_key("date:create")
|
|
||||||
else
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
From 0d6d7b630cf5971f2a2e3d27a50977d76ddbb9af Mon Sep 17 00:00:00 2001
|
|
||||||
From: Pavel Valena <pvalena@redhat.com>
|
|
||||||
Date: Tue, 5 Jun 2018 18:37:50 +0200
|
|
||||||
Subject: [PATCH] Fix test: match new `identify` error message
|
|
||||||
|
|
||||||
[identify](https://linux.die.net/man/1/identify) changed output.
|
|
||||||
---
|
|
||||||
spec/lib/mini_magick/shell_spec.rb | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/spec/lib/mini_magick/shell_spec.rb b/spec/lib/mini_magick/shell_spec.rb
|
|
||||||
index cb50a51..1389c18 100644
|
|
||||||
--- a/spec/lib/mini_magick/shell_spec.rb
|
|
||||||
+++ b/spec/lib/mini_magick/shell_spec.rb
|
|
||||||
@@ -51,7 +51,7 @@
|
|
||||||
stdout, stderr, status = subject.execute(%W[identify foo])
|
|
||||||
|
|
||||||
expect(stdout).to eq ""
|
|
||||||
- expect(stderr).to match("unable to open image 'foo'")
|
|
||||||
+ expect(stderr).to match(/identify: unable to open image `foo': No such file or directory/)
|
|
||||||
expect(status).to eq 1
|
|
||||||
end
|
|
||||||
|
|
||||||
@ -1,20 +1,18 @@
|
|||||||
%global gem_name mini_magick
|
%global gem_name mini_magick
|
||||||
Name: rubygem-%{gem_name}
|
Name: rubygem-%{gem_name}
|
||||||
Version: 4.8.0
|
Version: 4.8.0
|
||||||
Release: 1
|
Release: 5
|
||||||
Summary: Manipulate images with minimal use of memory via ImageMagick
|
Summary: Manipulate images with minimal use of memory via ImageMagick
|
||||||
License: MIT
|
License: MIT
|
||||||
URL: https://github.com/minimagick/minimagick
|
URL: https://github.com/minimagick/minimagick
|
||||||
Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem
|
Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem
|
||||||
Source1: https://github.com/minimagick/minimagick/archive/v%{version}.tar.gz
|
Source1: https://github.com/minimagick/minimagick/archive/v%{version}.tar.gz
|
||||||
# Use smallcase for MiniMagick::Image#details
|
Patch2: CVE-2019-13574-1.patch
|
||||||
# https://github.com/minimagick/minimagick/pull/454/
|
Patch3: CVE-2019-13574-2.patch
|
||||||
Patch0: mini_magick-4.8.0-Use-smallcase-for-Image-details-in-tests.patch
|
Patch4: fix-URI-InvalidURIError-no-such-file-directory.patch
|
||||||
# Match new `identify` error message
|
Patch5: fix-no-implicit-conversion-of-hash-into-integer.patch
|
||||||
# https://github.com/minimagick/minimagick/pull/455/
|
|
||||||
Patch1: mini_magick-4.8.0-match-new-identify-error-message-in-tests.patch
|
|
||||||
Requires: ImageMagick
|
Requires: ImageMagick
|
||||||
BuildRequires: ruby(release) rubygems-devel ruby rubygem(rspec) rubygem(webmock) ImageMagick
|
BuildRequires: ruby(release) rubygems-devel ruby rubygem(rspec) rubygem(webmock) ImageMagick rubygem(rexml)
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
%description
|
%description
|
||||||
A ruby wrapper for ImageMagick command line. Using MiniMagick the ruby
|
A ruby wrapper for ImageMagick command line. Using MiniMagick the ruby
|
||||||
@ -31,7 +29,8 @@ Documentation for %{name}.
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n %{gem_name}-%{version}
|
%setup -q -n %{gem_name}-%{version}
|
||||||
ln -s minimagick-%{version}/spec spec
|
%patch2 -p1
|
||||||
|
%patch5 -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
gem build ../%{gem_name}-%{version}.gemspec
|
gem build ../%{gem_name}-%{version}.gemspec
|
||||||
@ -45,8 +44,13 @@ cp -a .%{gem_dir}/* \
|
|||||||
%check
|
%check
|
||||||
pushd .%{gem_instdir}
|
pushd .%{gem_instdir}
|
||||||
tar xzvf %{SOURCE1}
|
tar xzvf %{SOURCE1}
|
||||||
cat %{PATCH0} | patch -p1
|
cd minimagick-%{version}
|
||||||
cat %{PATCH1} | patch -p1
|
cat %{PATCH3} | patch -p1
|
||||||
|
cat %{PATCH4} | patch -p1
|
||||||
|
cat %{PATCH5} | patch -p1
|
||||||
|
sed -i 's/"red"/"Red"/g' spec/lib/mini_magick/image_spec.rb
|
||||||
|
sed -i '/"date:create"/d' spec/lib/mini_magick/image_spec.rb
|
||||||
|
sed -i '/Clipping path/d' spec/lib/mini_magick/image_spec.rb
|
||||||
sed -i -e '/require "pry"/ s/^/#/g' \
|
sed -i -e '/require "pry"/ s/^/#/g' \
|
||||||
-e '/require "bundler/ s/^/#/g' \
|
-e '/require "bundler/ s/^/#/g' \
|
||||||
spec/spec_helper.rb
|
spec/spec_helper.rb
|
||||||
@ -72,5 +76,17 @@ popd
|
|||||||
%{gem_instdir}/Rakefile
|
%{gem_instdir}/Rakefile
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Feb 24 2022 wulei <wulei80@huawei.com> - 1.0.2-5
|
||||||
|
- Fix no implicit conversion of Hash into Integer
|
||||||
|
|
||||||
|
* Sat Jan 15 2022 Ge Wang <wangge20@huawei.com> - 1.0.2-4
|
||||||
|
- Fix test case failure
|
||||||
|
|
||||||
|
* Tue Apr 13 2021 wangxiao65 <wangxiao65@huawei.com> - 1.0.2-3
|
||||||
|
- Fix CVE-2019-13574
|
||||||
|
|
||||||
|
* Tue Sep 8 2020 yanan li <liyanan032@huawei.com> - 1.0.2-2
|
||||||
|
- fix build fail
|
||||||
|
|
||||||
* Wed Aug 19 2020 geyanan <geyanan2@huawei.com> - 4.8.0-1
|
* Wed Aug 19 2020 geyanan <geyanan2@huawei.com> - 4.8.0-1
|
||||||
- package init
|
- package init
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
version_control:github
|
version_control: github
|
||||||
src_repo:/minimagick/minimagick
|
src_repo: minimagick/minimagick
|
||||||
tag_prefix:"v"
|
tag_prefix: "v"
|
||||||
seperator:"."
|
separator: "."
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user