-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add wrappers for vips_block_untrusted_set and vips_operation_block_se…
…t methods ```ruby Vips.block("VipsForeignLoad", true); Vips.block("VipsForeignLoadJpeg", false) Vips.block_untrusted(true) ``` Use `vips -l` at the command-line to see the operations classes hierarchy.
- Loading branch information
Showing
5 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require "spec_helper" | ||
|
||
RSpec.describe Vips, version: [8, 13] do | ||
let(:svg_image) { simg("lion.svg") } | ||
let(:jpg_image) { simg("wagon.jpg") } | ||
|
||
if has_svg? | ||
it "can block untrusted operations" do | ||
untrusted_image = svg_image # svgload operation is known as untrusted | ||
|
||
# Block | ||
Vips.block_untrusted(true) | ||
expect { Vips::Image.new_from_file(untrusted_image) }.to raise_error Vips::Error, /svgload/ | ||
|
||
# Unblock | ||
Vips.block_untrusted(false) | ||
expect { Vips::Image.new_from_file(untrusted_image) }.not_to raise_error | ||
end | ||
end | ||
|
||
if has_jpeg? && has_svg? | ||
it "can block specific operations" do | ||
# Block all loaders except jpeg | ||
Vips.block("VipsForeignLoad", true) | ||
Vips.block("VipsForeignLoadJpeg", false) | ||
expect { Vips::Image.new_from_file(svg_image) }.to raise_error Vips::Error, /svgload/ | ||
expect { Vips::Image.new_from_file(jpg_image) }.not_to raise_error | ||
|
||
# Unblock all loaders | ||
Vips.block("VipsForeignLoad", false) | ||
expect { Vips::Image.new_from_file(svg_image) }.not_to raise_error | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters