validate-dockerfile
Advanced tools
Comparing version 1.4.9 to 1.5.0
20
index.js
@@ -6,3 +6,3 @@ 'use strict'; | ||
var instructionsRegex = /^(CMD|FROM|MAINTAINER|RUN|EXPOSE|ENV|ADD|ENTRYPOINT|VOLUME|USER|WORKDIR|ONBUILD)(\s*)/i; | ||
var instructionsRegex = /^(CMD|FROM|MAINTAINER|RUN|EXPOSE|ENV|ADD|ENTRYPOINT|VOLUME|USER|WORKDIR|ONBUILD|COPY)(\s*)/i; | ||
@@ -24,2 +24,3 @@ // Some regexes sourced from: | ||
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\/_.-]+$/, | ||
volume: /^~?([A-z0-9\/_.-]+|\[(\s*)?("[A-z0-9\/_. -]+"(,\s*)?)+(\s*)?\])$/, | ||
@@ -33,12 +34,15 @@ workdir: /^~?[A-z0-9\/_.-]+$/ | ||
var paramValidators = { | ||
add: function (params) { | ||
if (params.indexOf('http') === 0) { | ||
// No need to normalize a url | ||
return true; | ||
} | ||
return isDirValid(params.split(' ')[0]); | ||
function addCopy (params) { | ||
if (params.indexOf('http') === 0) { | ||
// No need to normalize a url | ||
return true; | ||
} | ||
return isDirValid(params.split(' ')[0]); | ||
} | ||
var paramValidators = { | ||
add: addCopy, | ||
copy: addCopy | ||
}; | ||
function finish (errors) { | ||
@@ -45,0 +49,0 @@ if (!errors.length) { |
{ | ||
"name": "validate-dockerfile", | ||
"version": "1.4.9", | ||
"version": "1.5.0", | ||
"description": "Validates a Dockerfile", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -175,30 +175,39 @@ 'use strict'; | ||
describe('add', function () { | ||
it('Should take a standard filepath ADD', expectsSuccess( | ||
'ADD ./tie-fighter /hangar' | ||
addCopy('ADD'); | ||
}); | ||
describe('copy', function() { | ||
addCopy('COPY'); | ||
}); | ||
// ADD and COPY are annoyingly identical. | ||
function addCopy (cmd) { | ||
it('Should take a standard filepath ' +cmd, expectsSuccess( | ||
cmd + ' ./tie-fighter /hangar' | ||
)); | ||
it('Should take a standard url ADD', expectsSuccess( | ||
'ADD http://superlaser.com /Alderaan' | ||
it('Should take a standard url ' + cmd, expectsSuccess( | ||
cmd + ' http://superlaser.com /Alderaan' | ||
)); | ||
it('Allows ADD commands that reference homedir', expectsSuccess( | ||
'ADD ~/tie-fighter ~/hangar' | ||
it('Allows ' + cmd + ' commands that reference homedir', expectsSuccess( | ||
cmd + ' ~/tie-fighter ~/hangar' | ||
)); | ||
it('Rejects a malformed URL', expectsFailure( | ||
'ADD htp://superlaser.com /Alderaan' | ||
cmd + ' htp://superlaser.com /Alderaan' | ||
)); | ||
it('Rejects a ADD with one parameter', expectsFailure( | ||
'ADD ./tie-fighter' | ||
it('Rejects a ' + cmd + ' with one parameter', expectsFailure( | ||
cmd + ' ./tie-fighter' | ||
)); | ||
it('Rejects an ADD that goes above the current dir', expectsFailure( | ||
'ADD ../superior-firepower/superlaser /superlaser' | ||
it('Rejects an ' + cmd + ' that goes above the current dir', expectsFailure( | ||
cmd + ' ../superior-firepower/superlaser /superlaser' | ||
)); | ||
it('Rejects an ADD that goes above the current dir even when ../ is hidden', expectsFailure( | ||
'ADD ./grand-moff/../../superior-firepower/superlaser /superlaser' | ||
it('Rejects an ' + cmd + ' that goes above the current dir even when ../ is hidden', expectsFailure( | ||
cmd + ' ./grand-moff/../../superior-firepower/superlaser /superlaser' | ||
)); | ||
}); | ||
} | ||
@@ -205,0 +214,0 @@ describe('volume', function () { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32451
520