CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-tmp-promise

The tmp package with promises support and disposers.

93

1.78x
Overview
Eval results
Files

task.mdevals/scenario-10/

Secure Configuration Manager

Build a configuration management system that securely stores sensitive application settings in temporary files with appropriate permissions.

Requirements

Your system should create temporary files to store sensitive configuration data (such as API keys, database credentials, or authentication tokens) with restricted file permissions to prevent unauthorized access.

Implement a function storeSecureConfig that:

  • Accepts a configuration object as input
  • Creates a temporary file with owner-only read/write permissions (mode 0600)
  • Writes the configuration data to the file as JSON
  • Returns the file path

Implement a function createSecureWorkspace that:

  • Creates a temporary directory with owner-only access (mode 0700)
  • Returns the directory path and a cleanup function

Both functions should properly handle cleanup of created resources.

Test Cases

  • Creating a secure config file with mode 0600 results in a file where only the owner can read/write @test
  • Creating a secure workspace with mode 0700 results in a directory where only the owner has full access @test
  • Attempting to read a secure config file as a different user fails due to permission restrictions @test

Implementation

@generates

API

/**
 * Stores sensitive configuration data in a temporary file with restricted permissions.
 *
 * @param {Object} config - Configuration object to store
 * @returns {Promise<{path: string, cleanup: () => Promise<void>}>} File path and cleanup function
 */
async function storeSecureConfig(config) {
  // IMPLEMENTATION HERE
}

/**
 * Creates a secure temporary workspace directory with restricted permissions.
 *
 * @returns {Promise<{path: string, cleanup: () => Promise<void>}>} Directory path and cleanup function
 */
async function createSecureWorkspace() {
  // IMPLEMENTATION HERE
}

module.exports = {
  storeSecureConfig,
  createSecureWorkspace
};

Dependencies { .dependencies }

tmp-promise { .dependency }

Provides temporary file and directory creation with permission control.

fs/promises { .dependency }

Provides file system operations for writing configuration data.

Install with Tessl CLI

npx tessl i tessl/npm-tmp-promise

tile.json