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

validate-dockerfile

Package Overview
Dependencies
Maintainers
3
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

validate-dockerfile - npm Package Compare versions

Comparing version 1.7.0 to 1.8.0

.idea/.name

25

index.js

@@ -22,4 +22,4 @@ 'use strict';

entrypoint: /.+/,
add: /^(~?[A-z0-9\/_.-]+|https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&\/\/=]*))\s~?[A-z0-9\/_.-]+$/,
copy: /^(~?[A-z0-9\/_.-]+|https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&\/\/=]*))\s~?[A-z0-9\/_.-]+$/,
add: /^((\[\s*\")?~?[A-z0-9\/_.-]+|https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&\/\/=]*))(\"\s*,\s*)?\s\"?~?[A-z0-9\/_.-]+(\"\s*\])?$/,
copy: /^((\[\s*\")?~?[A-z0-9\/_.-]+|https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&\/\/=]*))(\"\s*,\s*)?\s\"?~?[A-z0-9\/_.-]+(\"\s*\])?$/,
volume: /^~?([A-z0-9\/_.-]+|\[(\s*)?("[A-z0-9\/_. -]+"(,\s*)?)+(\s*)?\])$/,

@@ -29,2 +29,14 @@ workdir: /^~?[A-z0-9\/_.-]+$/

var arrayDisplayed = {
initialTestRegex: /^\[\s*\"/,
regex: /(^\[\s*\")([^"]+(\"\s*,\s*\"))*[^"]+(\"\s*\]$)/,
isAllowed: {
add: true,
cmd: true,
copy: true,
volume: true
}
};
function isDirValid (dir) {

@@ -128,2 +140,11 @@ return path.normalize(dir).indexOf('..') !== 0;

return false;
} else if (!opts.quiet && arrayDisplayed.isAllowed[instruction] &&
arrayDisplayed.initialTestRegex.test(params) && !arrayDisplayed.regex.test(params)) {
// Run the initial test to make sure the array is present first. Then check that the array
// is valid
errors.push({
message: 'Malformed parameters',
line: currentLine,
priority: 1
});
}

@@ -130,0 +151,0 @@ if (instruction === 'cmd') {

2

package.json
{
"name": "validate-dockerfile",
"version": "1.7.0",
"version": "1.8.0",
"description": "Validates a Dockerfile",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -24,3 +24,3 @@ 'use strict';

if (!isValid.valid) {
counter.next(new Error(isValid.errors[0].message));
counter.next(new Error(isValid.errors[0].message + ' ' + isValid.errors[0].line + ' ' + file));
}

@@ -79,2 +79,37 @@ counter.next();

it('should complain about bad format of an array', function () {
var dockerfile = ['FROM thyferra/bacta',
'CMD ["heal, "paitent"]'
].join(EOL);
var result = validateDockerfile(dockerfile);
result.should.be.an.Object;
result.should.have.property('valid', false);
result.should.have.property('errors');
result.errors.should.be.an.Array;
result.errors.length.should.eql(1);
result.errors[0].should.have.property('message', 'Malformed parameters');
result.errors[0].should.have.property('line', 2);
result.errors[0].should.have.property('priority', 1);
});
it('should complain about bad input in an array', function () {
var dockerfile = ['FROM thyferra/bacta',
'CMD ["asdfasdf", ""]'
].join(EOL);
var result = validateDockerfile(dockerfile);
result.should.be.an.Object;
result.should.have.property('valid', false);
result.should.have.property('errors');
result.errors.should.be.an.Array;
result.errors.length.should.eql(1);
result.errors[0].should.have.property('message', 'Malformed parameters');
result.errors[0].should.have.property('line', 2);
result.errors[0].should.have.property('priority', 1);
});
it('should flunk a file with no FROM', function () {

@@ -81,0 +116,0 @@ var dockerfile = 'Hi mom!';

Sorry, the diff of this file is not supported yet

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