redis-memory-server
Advanced tools
@@ -9,2 +9,3 @@ export declare const LATEST_VERSION: string; | ||
| systemBinary?: string; | ||
| ignoreDownloadCache?: boolean; | ||
| } | ||
@@ -11,0 +12,0 @@ export default class RedisBinary { |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || (function () { | ||
| var ownKeys = function(o) { | ||
| ownKeys = Object.getOwnPropertyNames || function (o) { | ||
| var ar = []; | ||
| for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; | ||
| return ar; | ||
| }; | ||
| return ownKeys(o); | ||
| }; | ||
| return function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| })(); | ||
| var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -24,3 +57,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
| const RedisBinaryDownload_1 = __importDefault(require("./RedisBinaryDownload")); | ||
| const resolve_config_1 = __importDefault(require("./resolve-config")); | ||
| const resolve_config_1 = __importStar(require("./resolve-config")); | ||
| const debug_1 = __importDefault(require("debug")); | ||
@@ -63,3 +96,3 @@ const log = (0, debug_1.default)('RedisMS:RedisBinary'); | ||
| return __awaiter(this, void 0, void 0, function* () { | ||
| const { downloadDir, version } = options; | ||
| const { downloadDir, version, ignoreDownloadCache } = options; | ||
| // create downloadDir | ||
@@ -84,6 +117,7 @@ yield (0, promises_1.mkdir)(downloadDir, { recursive: true }); | ||
| // check cache if it got already added to the cache | ||
| if (!this.getCachePath(version)) { | ||
| if (!this.getCachePath(version) || ignoreDownloadCache) { | ||
| const downloader = new RedisBinaryDownload_1.default({ | ||
| downloadDir, | ||
| version, | ||
| ignoreDownloadCache, | ||
| }); | ||
@@ -129,2 +163,3 @@ this.cache[version] = yield downloader.getRedisServerPath(); | ||
| systemBinary: (0, resolve_config_1.default)('SYSTEM_BINARY'), | ||
| ignoreDownloadCache: (0, resolve_config_1.envToBool)((0, resolve_config_1.default)('IGNORE_DOWNLOAD_CACHE')), | ||
| }; | ||
@@ -154,3 +189,3 @@ /** Provided Options combined with the Default Options */ | ||
| } | ||
| if (!binaryPath) { | ||
| if (!binaryPath && !options.ignoreDownloadCache) { | ||
| binaryPath = this.getCachePath(options.version); | ||
@@ -157,0 +192,0 @@ } |
@@ -7,2 +7,3 @@ import { DownloadProgressT } from '../types'; | ||
| downloadDir?: string; | ||
| ignoreDownloadCache?: boolean; | ||
| } | ||
@@ -26,3 +27,4 @@ interface HttpDownloadOptions { | ||
| version: string; | ||
| constructor({ downloadDir, version }: RedisBinaryDownloadOpts); | ||
| ignoreDownloadCache: boolean; | ||
| constructor({ downloadDir, version, ignoreDownloadCache }: RedisBinaryDownloadOpts); | ||
| /** | ||
@@ -29,0 +31,0 @@ * Get the path of the already downloaded "redis-server" file |
@@ -35,5 +35,6 @@ "use strict"; | ||
| class RedisBinaryDownload { | ||
| constructor({ downloadDir, version }) { | ||
| constructor({ downloadDir, version, ignoreDownloadCache }) { | ||
| this.version = version !== null && version !== void 0 ? version : RedisBinary_1.LATEST_VERSION; | ||
| this.downloadDir = path_1.default.resolve(downloadDir || 'redis-download'); | ||
| this.ignoreDownloadCache = ignoreDownloadCache !== null && ignoreDownloadCache !== void 0 ? ignoreDownloadCache : false; | ||
| this.dlProgress = { | ||
@@ -55,3 +56,7 @@ current: 0, | ||
| if (yield this.locationExists(redisServerPath)) { | ||
| return redisServerPath; | ||
| if (!this.ignoreDownloadCache) { | ||
| log('Redis binary found, skipping download and install'); | ||
| return redisServerPath; | ||
| } | ||
| log('Redis binary found, but ignoring due to "ignoreDownloadCache" being set'); | ||
| } | ||
@@ -125,4 +130,7 @@ const redisArchive = yield this.startDownload(); | ||
| if (yield this.locationExists(downloadLocation)) { | ||
| log('Already downloaded archive found, skipping download'); | ||
| return downloadLocation; | ||
| if (!this.ignoreDownloadCache) { | ||
| log('Already downloaded archive found, skipping download'); | ||
| return downloadLocation; | ||
| } | ||
| log('Already downloaded archive found, but ignoring due to "ignoreDownloadCache" being set'); | ||
| } | ||
@@ -157,3 +165,3 @@ this._downloadingUrl = downloadUrl; | ||
| else { | ||
| throw new Error(`RedisBinaryDownload: unsupported archive ${redisArchive} (downloaded from ${(_a = this._downloadingUrl) !== null && _a !== void 0 ? _a : 'unkown'}). Broken archive from Redis Provider?`); | ||
| throw new Error(`RedisBinaryDownload: unsupported archive ${redisArchive} (downloaded from ${(_a = this._downloadingUrl) !== null && _a !== void 0 ? _a : 'unknown'}). Broken archive from Redis Provider?`); | ||
| } | ||
@@ -160,0 +168,0 @@ return extractDir; |
+1
-1
| { | ||
| "name": "redis-memory-server", | ||
| "version": "0.13.0", | ||
| "version": "0.14.0", | ||
| "description": "Redis Server for testing. The server will allow you to connect your favorite client library to the Redis Server and run parallel integration tests isolated from each other.", | ||
@@ -5,0 +5,0 @@ "bin": "bin/index.js", |
+26
-0
@@ -15,2 +15,4 @@ # Redis In-Memory Server | ||
| All further runs will be fast because they will use the downloaded binaries. | ||
| NOTE: If no `version` is specified (or `version` is set to `stable`), | ||
| the binary will not be updated after the first run. | ||
@@ -30,2 +32,3 @@ This package automatically downloads source code from [https://download.redis.io/](https://download.redis.io/). | ||
| - [Configuring which `redis-server` binary to use](#configuring-which-redis-server-binary-to-use) | ||
| - [Using the `stable` version of the binary](#using-the-stable-version-of-the-binary) | ||
| - [Usage](#usage) | ||
@@ -69,2 +72,22 @@ - [Simple server start](#simple-server-start) | ||
| #### Using the `stable` version of the binary | ||
| After the first install of the `stable` version on a machine, | ||
| the binary will not be automatically updated on that machine. | ||
| This may be a concern because: | ||
| 1. the install is less deterministic | ||
| 2. some machines could have vulnerable versions | ||
| If this is a concern, either: | ||
| 1. specify a `version` other than `stable` | ||
| 2. forcibly update the `stable` binary on demand using a command like: | ||
| ```bash | ||
| REDISMS_IGNORE_DOWNLOAD_CACHE=1 yarn rebuild redis-memory-server | ||
| # OR | ||
| REDISMS_IGNORE_DOWNLOAD_CACHE=1 npm rebuild redis-memory-server | ||
| ``` | ||
| 3. specify the `ignoreDownloadCache` option | ||
| (NOTE: this will make installs/runs slower) | ||
| ## Usage | ||
@@ -120,2 +143,3 @@ | ||
| downloadDir: string, // by default, 'node_modules/.cache/redis-memory-server/redis-binaries' | ||
| ignoreDownloadCache: boolean, // by default, false | ||
| systemBinary: string, // by default, undefined | ||
@@ -132,2 +156,3 @@ }, | ||
| REDISMS_VERSION=6.0.10 # default version to download | ||
| REDISMS_IGNORE_DOWNLOAD_CACHE=1 # if you want to ignore already downloaded/installed binaries | ||
| REDISMS_DEBUG=1 # debug mode, also available case-insensitive values: "on" "yes" "true" | ||
@@ -151,2 +176,3 @@ REDISMS_DOWNLOAD_MIRROR=host # your mirror host to download the redis binary | ||
| "version": "6.0.10", | ||
| "ignoreDownloadCache": "1", | ||
| "debug": "1", | ||
@@ -153,0 +179,0 @@ "downloadMirror": "url", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 11 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 11 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
123913
3.29%1773
2.66%219
13.47%20
-4.76%