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

Support blocking untrusted operations #24

Merged
merged 17 commits into from
Sep 4, 2022

Conversation

atjn
Copy link
Contributor

@atjn atjn commented Aug 22, 2022

Support blocking untrusted and arbitrary operations with vips_block_untrusted_set and vips_operation_block_set:

// Block all untrusted operations
vips.blockUntrusted(true);

// Block all foreign loaders
vips.operationBlock("VipsForeignLoad", true);

// Reenable the jpeg loader
vips.operationBlock("VipsForeignLoadJpeg", true);

Note that it was already possible to use vips_block_untrusted_set before, by setting the module.ENV.VIPS_BLOCK_UNTRUSTED parameter on initialization.

Related: #21 (comment)

@atjn
Copy link
Contributor Author

atjn commented Aug 22, 2022

I considered integrating this a bit deeper, allowing for things like:

vips.Operation.block(vips.Image.pngsave, true);

vips.Image.jpegsave.block(true);

vips.Image.jpegsave.block(); // returns true
vips.Image.jpegsave.untrusted(); // returns false

But AFAICT it would require a massive amount of work, and I wasn't even sure if it would be desirable, given that it is pretty different from the core libvips API.

@atjn atjn marked this pull request as ready for review August 22, 2022 14:48
Copy link
Owner

@kleisauke kleisauke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! I left a couple of comments inline.

build/preamble_vips.d.ts Outdated Show resolved Hide resolved
build/preamble_vips.d.ts Outdated Show resolved Hide resolved
build/preamble_vips.d.ts Outdated Show resolved Hide resolved
src/vips-emscripten.cpp Outdated Show resolved Hide resolved
test/unit/helpers.js Outdated Show resolved Hide resolved
test/unit/test_block.js Outdated Show resolved Hide resolved
test/unit/test_block.js Outdated Show resolved Hide resolved
test/unit/test_block.js Outdated Show resolved Hide resolved
atjn and others added 12 commits September 4, 2022 14:03
Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl>
Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl>
Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl>
To match build/preamble
Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl>
Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl>
Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl>
Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl>
- Ensure `test_block.js` suite is also being tested on the browser.
- Move `before` and `after{,Each}` hooks inside the `describe` block.
- Simplify `blockUntrusted` test.
- Escape boolean types between grave accents in `vips.d.ts`.
@kleisauke kleisauke added this to the v0.0.4 milestone Sep 4, 2022
jcupitt added a commit to libvips/libvips that referenced this pull request Sep 4, 2022
We could return an operation from cache even after the operatuion had
been blocked. This was harmless, but could cause confusion.

see kleisauke/wasm-vips#24
Non-functional change.
Copy link
Owner

@kleisauke kleisauke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks all! This will be in v0.0.4.

@kleisauke kleisauke merged commit 5b7f0fc into kleisauke:master Sep 4, 2022
@atjn atjn deleted the block-untrusted branch September 4, 2022 17:10
kleisauke added a commit that referenced this pull request Sep 4, 2022
RReverser pushed a commit to RReverser/libvips that referenced this pull request Oct 28, 2022
We could return an operation from cache even after the operatuion had
been blocked. This was harmless, but could cause confusion.

see kleisauke/wasm-vips#24
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

3 participants