High performance Node.js image processing library for resizing JPEG, PNG, WebP, GIF, AVIF and TIFF images
80
A utility module for safely processing untrusted user-uploaded images by controlling which image operations are permitted at runtime.
You need to build a system that processes user-uploaded images in a multi-tenant environment. Different tenants have different security requirements - some allow full image processing capabilities while others require restricted operation sets to prevent resource exhaustion or malicious use.
Your task is to implement a security manager that can dynamically enable or disable specific image processing operations based on tenant security policies.
The system must support three security levels:
Create a module that:
@generates
/**
* Applies a security policy by blocking specific libvips operations.
*
* @param {string} policyName - The security policy to apply: 'restricted', 'standard', or 'full'
* @throws {Error} If an invalid policy name is provided
*/
function applySecurityPolicy(policyName) {
// IMPLEMENTATION HERE
}
/**
* Resets to full mode by unblocking all operations.
*/
function resetToFullMode() {
// IMPLEMENTATION HERE
}
/**
* Checks if a specific operation is currently blocked.
*
* @param {string} operationName - The name of the libvips operation to check
* @returns {boolean} True if the operation is blocked, false otherwise
*/
function isOperationBlocked(operationName) {
// IMPLEMENTATION HERE
}
module.exports = {
applySecurityPolicy,
resetToFullMode,
isOperationBlocked
};High-performance image processing library that provides control over libvips operations.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-sharpdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10