Skip to content
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

Allow to use vips_block_untrusted_set and vips_operation_block_set methods #382

Merged
merged 1 commit into from Feb 21, 2024

Conversation

aglushkov
Copy link
Contributor

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

@jcupitt
Copy link
Member

jcupitt commented Feb 19, 2024

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

@aglushkov
Copy link
Contributor Author

@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

@jcupitt
Copy link
Member

jcupitt commented Feb 20, 2024

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.

@jcupitt
Copy link
Member

jcupitt commented Feb 20, 2024

... could you also add a line to CHANGELOG and credit yourself?

…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.
@jcupitt jcupitt merged commit 0c110b0 into libvips:master Feb 21, 2024
24 checks passed
@jcupitt
Copy link
Member

jcupitt commented Feb 21, 2024

This looks really nice. Thank you for adding this feature @aglushkov !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants