code
stringlengths
14
2.05k
label
int64
0
1
programming_language
stringclasses
7 values
cwe_id
stringlengths
6
14
cwe_name
stringlengths
5
98
description
stringlengths
36
379
url
stringlengths
36
48
label_name
stringclasses
2 values
var preparePayload = function (modules, payload) { var stringifiedPayload = JSON.stringify(payload); if (modules.cryptoModule) { var encrypted = modules.cryptoModule.encrypt(stringifiedPayload); stringifiedPayload = typeof encrypted === 'string' ? encrypted : (0, base64_codec_1.encode)(encrypted); stringifiedPayload = JSON.stringify(stringifiedPayload); } return stringifiedPayload || ''; };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function __processMessage(modules, message) { if (!modules.cryptoModule) return message; try { var decryptedData = modules.cryptoModule.decrypt(message); var decryptedPayload = decryptedData instanceof ArrayBuffer ? JSON.parse(new TextDecoder().decode(decryptedData)) : decryptedData; return decryptedPayload; } catch (e) { if (console && console.log) console.log('decryption error', e.message); return message; } }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function prepareMessagePayload(modules, messagePayload) { var stringifiedPayload = JSON.stringify(messagePayload); if (modules.cryptoModule) { var encrypted = modules.cryptoModule.encrypt(stringifiedPayload); stringifiedPayload = typeof encrypted === 'string' ? encrypted : (0, base64_codec_1.encode)(encrypted); stringifiedPayload = JSON.stringify(stringifiedPayload); } return stringifiedPayload || ''; }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
this.decrypt = function (data, key) { if (typeof key === 'undefined' && cryptoModule) { var decrypted = modules.cryptoModule.decrypt(data); return decrypted instanceof ArrayBuffer ? (0, base64_codec_1.encode)(decrypted) : decrypted; } else { return crypto.decrypt(data, key); } };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
this.setCipherKey = function (key) { return modules.config.setCipherKey(key, setup, modules); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
this.encryptFile = function (key, file) { if (arguments.length == 1 && typeof key != 'string' && modules.cryptoModule) { file = key; return modules.cryptoModule.encryptFile(file, this.File); } return cryptography.encryptFile(key, file, this.File); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
this.encrypt = function (data, key) { if (typeof key === 'undefined' && modules.cryptoModule) { var encrypted = modules.cryptoModule.encrypt(data); return typeof encrypted === 'string' ? encrypted : (0, base64_codec_1.encode)(encrypted); } else { return crypto.encrypt(data, key); } };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
this.decryptFile = function (key, file) { if (arguments.length == 1 && typeof key != 'string' && modules.cryptoModule) { file = key; return modules.cryptoModule.decryptFile(file, this.File); } return cryptography.decryptFile(key, file, this.File); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function stringToArrayBuffer(str) { var buf = new ArrayBuffer(str.length * 2); var bufView = new Uint16Array(buf); for (var i = 0, strLen = str.length; i < strLen; i++) { bufView[i] = str.charCodeAt(i); } return buf; }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
CryptoModule.prototype.onStreamReadable = function (stream, file, File) { return __awaiter(this, void 0, void 0, function () { var magicBytes, versionByte, identifier, cryptor, headerSize, _a, _b; var _c; return __generator(this, function (_d) { switch (_d.label) { case 0: stream.removeAllListeners('readable'); magicBytes = stream.read(4); if (!CryptorHeader.isSentinel(magicBytes)) { if (magicBytes === null) throw new Error('decryption error. empty content'); stream.unshift(magicBytes); return [2 /*return*/, this.decryptLegacyFileStream(stream, file, File)]; } versionByte = stream.read(1); CryptorHeader.validateVersion(versionByte[0]); identifier = stream.read(4); cryptor = this.getCryptorFromId(CryptorHeader.tryGetIdentifier(identifier)); headerSize = CryptorHeader.tryGetMetadataSizeFromStream(stream); if (file.contentLength <= CryptorHeader.MIN_HEADER_LEGTH + headerSize) throw new Error('decryption error. empty content'); _b = (_a = File).create; _c = { name: file.name, mimeType: 'application/octet-stream' }; return [4 /*yield*/, cryptor.decryptStream({ stream: stream, metadataLength: headerSize })]; case 1: return [2 /*return*/, _b.apply(_a, [(_c.stream = _d.sent(), _c)])]; } }); }); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
CryptoModule.prototype.encrypt = function (data) { var encrypted = this.defaultCryptor.encrypt(data); if (!encrypted.metadata) return encrypted.data; var header = CryptorHeader.from(this.defaultCryptor.identifier, encrypted.metadata); var headerData = new Uint8Array(header.length); var pos = 0; headerData.set(header.data, pos); pos = header.length - encrypted.metadata.length; headerData.set(encrypted.metadata, pos); return Buffer.concat([headerData, Buffer.from(encrypted.data)]); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
CryptorHeader.tryGetIdentifier = function (data) { if (data.byteLength < 4) { throw new Error('unknown cryptor error. decryption failed'); } else { return data.toString('utf8'); } };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
CryptorHeader.tryParse = function (encryptedData) { var sentinel = ''; var version = null; if (encryptedData.length >= 4) { sentinel = encryptedData.slice(0, 4); if (sentinel.toString('utf8') !== CryptorHeader.SENTINEL) return ''; } if (encryptedData.length >= 5) { version = encryptedData[4]; } else { throw new Error('decryption error. invalid header version'); } if (version > CryptorHeader.MAX_VERSION) throw new Error('unknown cryptor error'); var identifier; var pos = 5 + CryptorHeader.IDENTIFIER_LENGTH; if (encryptedData.length >= pos) { identifier = encryptedData.slice(5, pos); } else { throw new Error('decryption error. invalid crypto identifier'); } var metadataLength = null; if (encryptedData.length >= pos + 1) { metadataLength = encryptedData[pos]; } else { throw new Error('decryption error. invalid metadata length'); } pos += 1; if (metadataLength === 255 && encryptedData.length >= pos + 2) { metadataLength = new Uint16Array(encryptedData.slice(pos, pos + 2)).reduce(function (acc, val) { return (acc << 8) + val; }, 0); pos += 2; } return new CryptorHeaderV1(identifier.toString('utf8'), metadataLength); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
CryptorHeader.from = function (id, metadata) { if (id === CryptorHeader.LEGACY_IDENTIFIER) return; return new CryptorHeaderV1(id, metadata.length); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
CryptorHeader.validateVersion = function (data) { if (data && data > CryptorHeader.MAX_VERSION) throw new Error('decryption error. invalid header version'); return data; };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
CryptoModule.prototype.decryptLegacyFileStream = function (stream, file, File) { return __awaiter(this, void 0, void 0, function () { var cryptor; return __generator(this, function (_a) { if (file.contentLength <= 16) throw new Error('decryption error: empty content'); cryptor = this.getLegacyCryptor(); if (cryptor) { return [2 /*return*/, cryptor.decryptFile(File.create({ name: file.name, stream: stream, }), File)]; } else { throw new Error('unknown cryptor error'); } return [2 /*return*/]; }); }); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function CryptorHeader() { }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
CryptoModule.prototype.getCryptorFromId = function (id) { var cryptor = this.getAllCryptors().find(function (c) { return id === c.identifier; }); if (cryptor) { return cryptor; } throw new Error('unknown cryptor error'); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
get: function () { return this._identifier; },
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
CryptoModule.prototype.getCryptor = function (header) { if (header === '') { var cryptor = this.getAllCryptors().find(function (c) { return c.identifier === ''; }); if (cryptor) return cryptor; throw new Error('unknown cryptor error'); } else if (header instanceof CryptorHeaderV1) { return this.getCryptorFromId(header.identifier); } };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
CryptorHeader.tryGetMetadataSizeFromStream = function (stream) { var sizeBuf = stream.read(1); if (sizeBuf && sizeBuf[0] < 255) { return sizeBuf[0]; } if (sizeBuf[0] === 255) { var nextBuf = stream.read(2); if (nextBuf.length >= 2) { return new Uint16Array([nextBuf[0], nextBuf[1]]).reduce(function (acc, val) { return (acc << 8) + val; }, 0); } } throw new Error('decryption error. Invalid metadata size'); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
default: new legacyCryptor_1.default({ cipherKey: config.cipherKey, useRandomIVs: (_a = config.useRandomIVs) !== null && _a !== void 0 ? _a : true, }), cryptors: [new aesCbcCryptor_1.default({ cipherKey: config.cipherKey })], });
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
CryptoModule.legacyCryptoModule = function (config) { var _a; return new this({ default: new legacyCryptor_1.default({ cipherKey: config.cipherKey, useRandomIVs: (_a = config.useRandomIVs) !== null && _a !== void 0 ? _a : true, }), cryptors: [new aesCbcCryptor_1.default({ cipherKey: config.cipherKey })], });
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
CryptorHeader.isSentinel = function (bytes) { if (bytes && bytes.byteLength >= 4) { if (bytes.toString('utf8') == CryptorHeader.SENTINEL) return true; } };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
data: Buffer.from(this.decrypt(file === null || file === void 0 ? void 0 : file.data)), })]; }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
CryptoModule.withDefaultCryptor = function (defaultCryptor) { return new this({ default: defaultCryptor }); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
CryptoModule.prototype.getAllCryptors = function () { return __spreadArray([this.defaultCryptor], __read(this.cryptors), false); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function CryptoModule(cryptoModuleConfiguration) { var _a; this.defaultCryptor = cryptoModuleConfiguration.default; this.cryptors = (_a = cryptoModuleConfiguration.cryptors) !== null && _a !== void 0 ? _a : []; }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
set: function (value) { this._identifier = value; },
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
data: encryptedData.slice(header.length), metadata: metadata, }); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
data: Buffer.from(this.encrypt(file.data)), })]; } if (!(file.data instanceof stream_1.Readable)) return [3 /*break*/, 2]; if (file.contentLength === 0) throw new Error('encryption error. empty content'); return [4 /*yield*/, this.defaultCryptor.encryptStream(file.data)]; case 1: encryptedStream = _a.sent(); header = CryptorHeader.from(this.defaultCryptor.identifier, encryptedStream.metadata); payload = new Uint8Array(header.length); pos = 0; payload.set(header.data, pos); pos += header.length; if (encryptedStream.metadata) { pos -= encryptedStream.metadata.length; payload.set(encryptedStream.metadata, pos); } output = new stream_1.PassThrough(); output.write(payload); encryptedStream.stream.pipe(output); return [2 /*return*/, File.create({ name: file.name, mimeType: 'application/octet-stream', stream: output, })]; case 2: return [2 /*return*/]; }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function CryptorHeaderV1(id, metadataLength) { this._identifier = id; this._metadataLength = metadataLength; }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
CryptoModule.prototype.getLegacyCryptor = function () { return this.getAllCryptors().find(function (c) { return c.identifier === ''; }); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function verb(n) { return function (v) { return step([n, v]); }; }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
data: Buffer.concat([aes.update(bPlain), aes.final()]), }; };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
get: function () { return 'aes-256-cbc'; },
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
AesCbcCryptor.prototype.encryptStream = function (stream) { return __awaiter(this, void 0, void 0, function () { var output, bIv, aes; return __generator(this, function (_a) { output = new stream_1.PassThrough(); bIv = this.getIv(); if (stream.readable === false) throw new Error('encryption error. empty stream'); aes = (0, crypto_1.createCipheriv)(this.algo, this.getKey(), bIv); stream.pipe(aes).pipe(output); return [2 /*return*/, { stream: output, metadata: bIv, metadataLength: AesCbcCryptor.BLOCK_SIZE, }]; }); }); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
onReadable = function () { var data = encryptedStream.stream.read(); while (data !== null) { if (data) { var bChunk = Buffer.from(data); var sliceLen = encryptedStream.metadataLength - bIv.byteLength; if (bChunk.byteLength < sliceLen) { bIv = Buffer.concat([bIv, bChunk]); } else { bIv = Buffer.concat([bIv, bChunk.slice(0, sliceLen)]); aes = (0, crypto_1.createDecipheriv)(_this.algo, _this.getKey(), bIv); aes.pipe(decryptedStream); aes.write(bChunk.slice(sliceLen)); } } data = encryptedStream.stream.read(); } };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
AesCbcCryptor.prototype.decrypt = function (encryptedData) { var data = typeof encryptedData.data === 'string' ? new TextEncoder().encode(encryptedData.data) : encryptedData.data; if (data.byteLength <= 0) throw new Error('decryption error: empty content'); var aes = (0, crypto_1.createDecipheriv)(this.algo, this.getKey(), encryptedData.metadata); return Uint8Array.from(Buffer.concat([aes.update(data), aes.final()])).buffer; };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
AesCbcCryptor.prototype.getIv = function () { return (0, crypto_1.randomBytes)(AesCbcCryptor.BLOCK_SIZE); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
AesCbcCryptor.prototype.getKey = function () { var sha = (0, crypto_1.createHash)('sha256'); sha.update(Buffer.from(this.cipherKey, 'utf8')); return Buffer.from(sha.digest()); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
AesCbcCryptor.prototype.decryptStream = function (encryptedStream) { return __awaiter(this, void 0, void 0, function () { var decryptedStream, bIv, aes, onReadable; var _this = this; return __generator(this, function (_a) { decryptedStream = new stream_1.PassThrough(); bIv = Buffer.alloc(0); aes = null; onReadable = function () { var data = encryptedStream.stream.read(); while (data !== null) { if (data) { var bChunk = Buffer.from(data); var sliceLen = encryptedStream.metadataLength - bIv.byteLength; if (bChunk.byteLength < sliceLen) { bIv = Buffer.concat([bIv, bChunk]); } else { bIv = Buffer.concat([bIv, bChunk.slice(0, sliceLen)]); aes = (0, crypto_1.createDecipheriv)(_this.algo, _this.getKey(), bIv); aes.pipe(decryptedStream); aes.write(bChunk.slice(sliceLen)); } } data = encryptedStream.stream.read(); } }; encryptedStream.stream.on('readable', onReadable); encryptedStream.stream.on('end', function () { if (aes) { aes.end(); } decryptedStream.end(); }); return [2 /*return*/, decryptedStream]; }); }); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function AesCbcCryptor(configuration) { this.cipherKey = configuration.cipherKey; }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
data: Buffer.concat([aes.update(bPlain), aes.final()]), };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function verb(n) { return function (v) { return step([n, v]); }; }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
get: function () { return ''; },
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
LegacyCryptor.prototype.encrypt = function (data) { if (data.length === 0) throw new Error('encryption error. empty content'); return { data: this.cryptor.encrypt(data), metadata: null, }; }; LegacyCryptor.prototype.decrypt = function (encryptedData) { var data = typeof encryptedData.data === 'string' ? encryptedData.data : (0, base64_codec_1.encode)(encryptedData.data); return this.cryptor.decrypt(data); }; LegacyCryptor.prototype.encryptFile = function (file, File) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/, this.fileCryptor.encryptFile(this.config.cipherKey, file, File)]; }); }); }; LegacyCryptor.prototype.decryptFile = function (file, File) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/, this.fileCryptor.decryptFile(this.config.cipherKey, file, File)]; }); }); }; return LegacyCryptor; }());
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
data: this.cryptor.encrypt(data), metadata: null, }; };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
LegacyCryptor.prototype.decrypt = function (encryptedData) { var data = typeof encryptedData.data === 'string' ? encryptedData.data : (0, base64_codec_1.encode)(encryptedData.data); return this.cryptor.decrypt(data); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
LegacyCryptor.prototype.encryptFile = function (file, File) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/, this.fileCryptor.encryptFile(this.config.cipherKey, file, File)]; }); }); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
LegacyCryptor.prototype.decryptFile = function (file, File) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/, this.fileCryptor.decryptFile(this.config.cipherKey, file, File)]; }); }); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function LegacyCryptor(config) { this.config = config; this.cryptor = new index_1.default({ config: config }); this.fileCryptor = new node_1.default(); }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function verb(n) { return function (v) { return step([n, v]); }; }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
CryptoModule.prototype.onStreamReadable = function (stream, file, File) { return __awaiter(this, void 0, void 0, function () { var magicBytes, versionByte, identifier, cryptor, headerSize, _a, _b; var _c; return __generator(this, function (_d) { switch (_d.label) { case 0: stream.removeAllListeners('readable'); magicBytes = stream.read(4); if (!CryptorHeader.isSentinel(magicBytes)) { if (magicBytes === null) throw new Error('decryption error. empty content'); stream.unshift(magicBytes); return [2 /*return*/, this.decryptLegacyFileStream(stream, file, File)]; } versionByte = stream.read(1); CryptorHeader.validateVersion(versionByte[0]); identifier = stream.read(4); cryptor = this.getCryptorFromId(CryptorHeader.tryGetIdentifier(identifier)); headerSize = CryptorHeader.tryGetMetadataSizeFromStream(stream); if (file.contentLength <= CryptorHeader.MIN_HEADER_LEGTH + headerSize) throw new Error('decryption error. empty content'); _b = (_a = File).create; _c = { name: file.name, mimeType: 'application/octet-stream' }; return [4 /*yield*/, cryptor.decryptStream({ stream: stream, metadataLength: headerSize })]; case 1: return [2 /*return*/, _b.apply(_a, [(_c.stream = _d.sent(), _c)])]; } }); }); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
CryptoModule.prototype.encrypt = function (data) { var encrypted = this.defaultCryptor.encrypt(data); if (!encrypted.metadata) return encrypted.data; var header = CryptorHeader.from(this.defaultCryptor.identifier, encrypted.metadata); var headerData = new Uint8Array(header.length); var pos = 0; headerData.set(header.data, pos); pos = header.length - encrypted.metadata.length; headerData.set(encrypted.metadata, pos); return Buffer.concat([headerData, Buffer.from(encrypted.data)]); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
CryptorHeader.tryGetIdentifier = function (data) { if (data.byteLength < 4) { throw new Error('unknown cryptor error. decryption failed'); } else { return data.toString('utf8'); } };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
CryptorHeader.tryParse = function (encryptedData) { var sentinel = ''; var version = null; if (encryptedData.length >= 4) { sentinel = encryptedData.slice(0, 4); if (sentinel.toString('utf8') !== CryptorHeader.SENTINEL) return ''; } if (encryptedData.length >= 5) { version = encryptedData[4]; } else { throw new Error('decryption error. invalid header version'); } if (version > CryptorHeader.MAX_VERSION) throw new Error('unknown cryptor error'); var identifier; var pos = 5 + CryptorHeader.IDENTIFIER_LENGTH; if (encryptedData.length >= pos) { identifier = encryptedData.slice(5, pos); } else { throw new Error('decryption error. invalid crypto identifier'); } var metadataLength = null; if (encryptedData.length >= pos + 1) { metadataLength = encryptedData[pos]; } else { throw new Error('decryption error. invalid metadata length'); } pos += 1; if (metadataLength === 255 && encryptedData.length >= pos + 2) { metadataLength = new Uint16Array(encryptedData.slice(pos, pos + 2)).reduce(function (acc, val) { return (acc << 8) + val; }, 0); pos += 2; } return new CryptorHeaderV1(identifier.toString('utf8'), metadataLength); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
CryptorHeader.from = function (id, metadata) { if (id === CryptorHeader.LEGACY_IDENTIFIER) return; return new CryptorHeaderV1(id, metadata.length); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
CryptorHeader.validateVersion = function (data) { if (data && data > CryptorHeader.MAX_VERSION) throw new Error('decryption error. invalid header version'); return data; };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
CryptoModule.prototype.decryptLegacyFileStream = function (stream, file, File) { return __awaiter(this, void 0, void 0, function () { var cryptor; return __generator(this, function (_a) { if (file.contentLength <= 16) throw new Error('decryption error: empty content'); cryptor = this.getLegacyCryptor(); if (cryptor) { return [2 /*return*/, cryptor.decryptFile(File.create({ name: file.name, stream: stream, }), File)]; } else { throw new Error('unknown cryptor error'); } return [2 /*return*/]; }); }); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function CryptorHeader() { }
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
CryptoModule.prototype.getCryptorFromId = function (id) { var cryptor = this.getAllCryptors().find(function (c) { return id === c.identifier; }); if (cryptor) { return cryptor; } throw new Error('unknown cryptor error'); };
1
JavaScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe