Expose ability to (un)block libvips ops by name

This commit is contained in:
Lovell Fuller
2023-07-19 16:53:52 +01:00
parent a0e1c39785
commit 739b317a6f
8 changed files with 178 additions and 1 deletions

View File

@@ -165,4 +165,59 @@ const simd = sharp.simd();
```js
const simd = sharp.simd(false);
// prevent libvips from using liborc at runtime
```
## block
Block libvips operations at runtime.
This is in addition to the `VIPS_BLOCK_UNTRUSTED` environment variable,
which when set will block all "untrusted" operations.
**Since**: 0.32.4
| Param | Type | Description |
| --- | --- | --- |
| options | <code>Object</code> | |
| options.operation | <code>Array.&lt;string&gt;</code> | List of libvips low-level operation names to block. |
**Example** *(Block all TIFF input.)*
```js
sharp.block({
operation: ['VipsForeignLoadTiff']
});
```
## unblock
Unblock libvips operations at runtime.
This is useful for defining a list of allowed operations.
**Since**: 0.32.4
| Param | Type | Description |
| --- | --- | --- |
| options | <code>Object</code> | |
| options.operation | <code>Array.&lt;string&gt;</code> | List of libvips low-level operation names to unblock. |
**Example** *(Block all input except WebP from the filesystem.)*
```js
sharp.block({
operation: ['VipsForeignLoad']
});
sharp.unblock({
operation: ['VipsForeignLoadWebpFile']
});
```
**Example** *(Block all input except JPEG and PNG from a Buffer or Stream.)*
```js
sharp.block({
operation: ['VipsForeignLoad']
});
sharp.unblock({
operation: ['VipsForeignLoadJpegBuffer', 'VipsForeignLoadPngBuffer']
});
```

View File

@@ -4,6 +4,10 @@
Requires libvips v8.14.2
### v0.32.4 - TBD
* Expose ability to (un)block low-level libvips operations by name.
### v0.32.3 - 14th July 2023
* Expose `preset` option for WebP output.

File diff suppressed because one or more lines are too long