- 
  Notifications
 You must be signed in to change notification settings 
- Fork 62
Allow to use vips_block_untrusted_set and vips_operation_block_set methods #382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e66b614 to
 cddd270  
 Compare
 
 Hi @aglushkov,
Thank you for doing this work, and sorry for sitting on it for so long.
Vips.vips_block_untrusted_set(true)
This is a little ugly. How about making a tiny wrapper, like the one for vips_vector_set_enabled()?
https://github.com/libvips/ruby-vips/blob/master/lib/vips.rb#L703-L708
So eg. maybe:
# Block untrusted loaders from executing. def self.block_untrusted enabled vips_block_untrusted_set(enabled ? 1 : 0) end # Set or clear the block flag on a named operation. def self.block name vips_operation_block_set(name) end
@jcupitt No worries, added commit with wrappers
Not sure if it's ok to have second enabled parameter, or you want a separate unblock methods. 
Also not sure its correct place for wrappers and attach_functions in operation.rb file. 
And I would like to check if provided operation name exists, but don't know how I can do this easily
We have the global Vips stuff in lib/vips.rb, the wrappers should probably go in there.
Ah you're right, I forgot the enabled param to vips_operation_block_set(). It should probably be required and not optional.
... could you also add a line to CHANGELOG and credit yourself?
6f54bbc to
 860b7c4  
 Compare
 
 ...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.
 860b7c4 to
 83a8340  
 Compare
 
 This looks really nice. Thank you for adding this feature @aglushkov !
Some forgotten stuff I think...
I wrote tests same way as they are in python library
https://github.com/libvips/pyvips/blob/a9688b9c7c2a4b448eec0f0a9375c8f34e76354e/tests/test_block.py#L38