Socket
Socket
Sign inDemoInstall

express-fileupload

Package Overview
Dependencies
Maintainers
0
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-fileupload - npm Package Compare versions

Comparing version 1.5.0 to 1.5.1

3

lib/index.js

@@ -23,3 +23,4 @@ 'use strict';

useTempFiles: false,
tempFileDir: path.join(process.cwd(), 'tmp')
tempFileDir: path.join(process.cwd(), 'tmp'),
hashAlgorithm: 'md5'
};

@@ -26,0 +27,0 @@

@@ -13,3 +13,3 @@ const crypto = require('crypto');

const buffers = [];
const hash = crypto.createHash('md5');
const hash = crypto.createHash(options.hashAlgorithm);
let fileSize = 0;

@@ -16,0 +16,0 @@ let completed = false;

@@ -17,4 +17,4 @@ const fs = require('fs');

debugLog(options, `Temporary file path is ${tempFilePath}`);
const hash = crypto.createHash('md5');
const hash = crypto.createHash(options.hashAlgorithm);
let fileSize = 0;

@@ -21,0 +21,0 @@ let completed = false;

@@ -5,2 +5,3 @@ 'use strict';

const path = require('path');
const crypto = require('crypto');
const { Readable } = require('stream');

@@ -72,2 +73,3 @@

* @returns {Object} - result options.
* @throws {Error} - when a valid hashAlgorithm option is not provided.
*/

@@ -80,2 +82,11 @@ const buildOptions = function() {

});
// Ensure the configured hashAlgorithm is available on the system
if (crypto.getHashes().find(h => result.hashAlgorithm === h) === undefined) {
throw Error(
`Hashing algorithm '${result.hashAlgorithm}' is not supported by this system's OpenSSL `
+ `version`
);
}
return result;

@@ -82,0 +93,0 @@ };

{
"name": "express-fileupload",
"version": "1.5.0",
"version": "1.5.1",
"author": "Richard Girges <richardgirges@gmail.com>",

@@ -5,0 +5,0 @@ "description": "Simple express file upload middleware that wraps around Busboy",

@@ -53,3 +53,4 @@ # express-fileupload

* From 1.0.0 until 1.1.1, `md5` is a function to compute an MD5 hash ([Read about it here.](https://github.com/richardgirges/express-fileupload/releases/tag/v1.0.0-alpha.1)).
* From 1.1.1 onward, `md5` is reverted back to MD5 checksum value and also added full MD5 support in case you are using temporary files.
* From 1.1.1 until 1.5.1, `md5` is reverted back to MD5 checksum value and also added full MD5 support in case you are using temporary files.
* From 1.5.1 onward, `md5` still holds the checksum value, but the checksum is generated with the provided `hashAlgorithm` option. The property name remains `md5` for backwards compatibility.

@@ -128,2 +129,3 @@

uploadTimeout | <ul><li><code>60000</code>&nbsp;**(default)**</li><li><code>Integer</code></ul> | This defines how long to wait for data before aborting. Set to 0 if you want to turn off timeout checks.
hashAlgorithm | <ul><li><code>md5</code>&nbsp;**(default)**</li><li><code>String</code></li></ul> | Allows the usage of alternative hashing algorithms for file integrity checks. This option must be an algorithm that is supported on the running system's installed OpenSSL version. On recent releases of OpenSSL, <code>openssl list -digest-algorithms</code> will display the available digest algorithms.

@@ -130,0 +132,0 @@ # Help Wanted

@@ -201,8 +201,8 @@ 'use strict';

const source = { option1: '1', option2: '2' };
const sourceAddon = { option3: '3'};
const expected = { option1: '1', option2: '2' };
const expectedAddon = { option1: '1', option2: '2', option3: '3'};
const source = { option1: '1', option2: '2', hashAlgorithm: 'md5' };
const sourceAddon = { option3: '3', hashAlgorithm: 'sha256'};
const expected = { option1: '1', option2: '2', hashAlgorithm: 'md5' };
const expectedAddon = { option1: '1', option2: '2', option3: '3', hashAlgorithm: 'sha256'};
it('buildOptions returns and equal object to the object which was paased', () => {
it('buildOptions returns an equal object to the object which was passed', () => {
let result = buildOptions(source);

@@ -217,3 +217,3 @@ assert.deepStrictEqual(result, source);

it('buildOptions adds value to the result from the several source argumets', () => {
it('buildOptions adds value to the result from the several source arguments', () => {
let result = buildOptions(source, sourceAddon);

@@ -223,2 +223,9 @@ assert.deepStrictEqual(result, expectedAddon);

it('buildOptions throws an error when not provided a supported hashAlgorithm', () => {
assert.throws(() => buildOptions({}));
});
it('buildOptions throws an error when given an unsupported hashAlgorithm', () => {
assert.throws(() => buildOptions({ hashAlgorithm: 'not-actual-algo' }));
});
});

@@ -225,0 +232,0 @@ //buildFields tests

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc