Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

inert

Package Overview
Dependencies
Maintainers
2
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inert - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

10

lib/file.js

@@ -208,3 +208,11 @@ // Load modules

if (err) {
return callback(Boom.notFound());
if (err.code === 'ENOENT') {
return callback(Boom.notFound());
}
if (err.code === 'EACCES' || err.code === 'EPERM') {
return callback(Boom.forbidden());
}
return callback(Boom.wrap(err, null, 'failed to open file'));
}

@@ -211,0 +219,0 @@

2

package.json
{
"name": "inert",
"description": "Static file and directory handlers plugin for hapi.js",
"version": "2.1.0",
"version": "2.1.1",
"repository": "git://github.com/hapijs/inert",

@@ -6,0 +6,0 @@ "main": "index",

@@ -939,2 +939,80 @@ // Load modules

it('returns error when open fails unexpectedly', function (done) {
var filename = Hoek.uniqueFilename(Os.tmpDir()) + '.package.json';
Fs.writeFileSync(filename, 'data');
var orig = Fs.open;
Fs.open = function () { // can return EMFILE error
Fs.open = orig;
var callback = arguments[arguments.length - 1];
callback(new Error('failed'));
};
var server = provisionServer();
server.route({ method: 'GET', path: '/', handler: { file: filename } });
server.inject('/', function (res) {
expect(res.statusCode).to.equal(500);
done();
});
});
it('returns a 403 when missing file read permission', function (done) {
var filename = Hoek.uniqueFilename(Os.tmpDir()) + '.package.json';
Fs.writeFileSync(filename, 'data');
var fd;
if (process.platform === 'win32') {
// make a permissionless file by unlinking an open file
fd = Fs.openSync(filename, 'r');
Fs.unlinkSync(filename);
} else {
Fs.chmodSync(filename, 0);
}
var server = provisionServer();
server.route({ method: 'GET', path: '/', handler: { file: filename } });
server.inject('/', function (res1) {
var orig = Fs.open;
Fs.open = function (path, mode, callback) { // fake alternate permission error
Fs.open = orig;
return Fs.open(path, mode, function(err, fd) {
if (err) {
if (err.code === 'EACCES') {
err.code = 'EPERM';
err.errno = -1;
} else if (err.code === 'EPERM') {
err.code = 'EPERM';
err.errno = -13;
}
}
return callback(err, fd);
});
};
server.inject('/', function (res2) {
// cleanup
if (typeof fd === 'number') {
Fs.closeSync(fd);
} else {
Fs.unlinkSync(filename);
}
expect(res1.statusCode).to.equal(403);
expect(res2.statusCode).to.equal(403);
done();
});
});
});
describe('response range', function () {

@@ -941,0 +1019,0 @@

Sorry, the diff of this file is not supported yet

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