dockerfilelint
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -139,2 +139,3 @@ | ||
var p = args.match(/\S+/g); | ||
// if there is not a = in the first element, we shoud assume it's the second format above | ||
@@ -141,0 +142,0 @@ if (!p[0].includes('=')) { |
174
lib/index.js
@@ -106,95 +106,95 @@ 'use strict'; | ||
}.bind(this)); | ||
} | ||
// Vaildate each command individually | ||
switch (cmd) { | ||
case 'from': | ||
checks.base_image_tag(args).forEach(function(message) { | ||
messages.push({line: parseInt(idx)+1, name: message.name, message: message.message}); | ||
}); | ||
break; | ||
case 'maintainer': | ||
checks.valid_maintainer(args).forEach(function(message) { | ||
messages.push({line: parseInt(idx)+1, name: message.name, message: message.message}); | ||
}); | ||
break; | ||
case 'run': | ||
var subcommands = []; | ||
run_checks.aptget_commands(args).forEach(function(aptget_command) { | ||
var subcommand = run_checks.aptget_subcommand(aptget_command); | ||
subcommands.push(subcommand); | ||
if (["install", "remove", "upgrade"].indexOf(subcommand) > -1) { | ||
if (!run_checks.aptget_hasyes(aptget_command)) { | ||
messages.push({line: parseInt(idx)+1, name: 'apt-get_missing_param', message: 'apt-get commands should include a -y flag'}); | ||
// Vaildate each command individually | ||
switch (cmd) { | ||
case 'from': | ||
checks.base_image_tag(args).forEach(function(message) { | ||
messages.push({line: parseInt(idx)+1, name: message.name, message: message.message}); | ||
}); | ||
break; | ||
case 'maintainer': | ||
checks.valid_maintainer(args).forEach(function(message) { | ||
messages.push({line: parseInt(idx)+1, name: message.name, message: message.message}); | ||
}); | ||
break; | ||
case 'run': | ||
var subcommands = []; | ||
run_checks.aptget_commands(args).forEach(function(aptget_command) { | ||
var subcommand = run_checks.aptget_subcommand(aptget_command); | ||
subcommands.push(subcommand); | ||
if (["install", "remove", "upgrade"].indexOf(subcommand) > -1) { | ||
if (!run_checks.aptget_hasyes(aptget_command)) { | ||
messages.push({line: parseInt(idx)+1, name: 'apt-get_missing_param', message: 'apt-get commands should include a -y flag'}); | ||
} | ||
} | ||
} | ||
if (subcommand === 'install') { | ||
if (!run_checks.aptget_hasnorecommends(aptget_command)) { | ||
messages.push({line: parseInt(idx)+1, name: 'apt-get_recommends', message: 'apt-get install commands should include a --no-install-recommends flag'}); | ||
if (subcommand === 'install') { | ||
if (!run_checks.aptget_hasnorecommends(aptget_command)) { | ||
messages.push({line: parseInt(idx)+1, name: 'apt-get_recommends', message: 'apt-get install commands should include a --no-install-recommends flag'}); | ||
} | ||
} else if (subcommand === 'upgrade') { | ||
messages.push({line: parseInt(idx)+1, name: 'apt-get-upgrade', message: 'apt-get upgrade is not allowed'}); | ||
} else if (subcommand === 'dist-upgrade') { | ||
messages.push({line: parseInt(idx)+1, name: 'apt-get-dist-upgrade', message: 'apt-get dist-upgrade is not allowed'}); | ||
} | ||
} else if (subcommand === 'upgrade') { | ||
messages.push({line: parseInt(idx)+1, name: 'apt-get-upgrade', message: 'apt-get upgrade is not allowed'}); | ||
} else if (subcommand === 'dist-upgrade') { | ||
messages.push({line: parseInt(idx)+1, name: 'apt-get-dist-upgrade', message: 'apt-get dist-upgrade is not allowed'}); | ||
}); | ||
if ((subcommands.indexOf('update') > -1) && (subcommands.indexOf('install') === -1)) { | ||
messages.push({line: parseInt(idx)+1, name: 'apt-get-update_require_install', message: 'apt-get update commands must be paired with apt-get install commands'}); | ||
} | ||
}); | ||
if ((subcommands.indexOf('update') > -1) && (subcommands.indexOf('install') === -1)) { | ||
messages.push({line: parseInt(idx)+1, name: 'apt-get-update_require_install', message: 'apt-get update commands must be paired with apt-get install commands'}); | ||
} | ||
break; | ||
case 'cmd': | ||
break; | ||
case 'label': | ||
checks.label_format(args).forEach(function(message) { | ||
messages.push({line: parseInt(idx)+1, name: message.name, message: message.message}); | ||
}); | ||
break; | ||
case 'expose': | ||
checks.expose_container_port_only(args).forEach(function(message) { | ||
messages.push({line: parseInt(idx)+1, name: message.name, message: message.message}); | ||
}); | ||
args.match(/\S+/g).forEach(function(port) { | ||
if (!checks.expose_port_valid(port)) { | ||
if (!port.includes(':')) { // Just eliminate a double message here | ||
messages.push({line: parseInt(idx)+1, name: 'invalid_port', message: 'EXPOSE should be a valid port number'}); | ||
break; | ||
case 'cmd': | ||
break; | ||
case 'label': | ||
checks.label_format(args).forEach(function(message) { | ||
messages.push({line: parseInt(idx)+1, name: message.name, message: message.message}); | ||
}); | ||
break; | ||
case 'expose': | ||
checks.expose_container_port_only(args).forEach(function(message) { | ||
messages.push({line: parseInt(idx)+1, name: message.name, message: message.message}); | ||
}); | ||
args.match(/\S+/g).forEach(function(port) { | ||
if (!checks.expose_port_valid(port)) { | ||
if (!port.includes(':')) { // Just eliminate a double message here | ||
messages.push({line: parseInt(idx)+1, name: 'invalid_port', message: 'EXPOSE should be a valid port number'}); | ||
} | ||
} | ||
} | ||
}); | ||
break; | ||
case 'env': | ||
checks.is_valid_env(args).forEach(function(message) { | ||
messages.push({line: parseInt(idx)+1, name: message.name, message: message.message}); | ||
}); | ||
break; | ||
case 'add': | ||
checks.is_valid_add(args).forEach(function(message) { | ||
messages.push({line: parseInt(idx)+1, name: message.name, message: message.message}); | ||
}); | ||
break; | ||
case 'copy': | ||
break; | ||
case 'entrypoint': | ||
break; | ||
case 'volume': | ||
break; | ||
case 'user': | ||
checks.valid_user(args).forEach(function(message) { | ||
messages.push({line: parseInt(idx)+1, name: message.name, message: message.message}); | ||
}); | ||
break; | ||
case 'workdir': | ||
checks.is_valid_workdir(args).forEach(function(message) { | ||
messages.push({line: parseInt(idx)+1, name: message.name, message: message.message}); | ||
}); | ||
break; | ||
case 'arg': | ||
break; | ||
case 'onbuild': | ||
break; | ||
case 'stopsignal': | ||
break; | ||
default: | ||
messages.push({line: parseInt(idx)+1, name: 'invalid_command', message: 'Only supported Dockerfile commands are allowed'}); | ||
break; | ||
}); | ||
break; | ||
case 'env': | ||
checks.is_valid_env(args).forEach(function(message) { | ||
messages.push({line: parseInt(idx)+1, name: message.name, message: message.message}); | ||
}); | ||
break; | ||
case 'add': | ||
checks.is_valid_add(args).forEach(function(message) { | ||
messages.push({line: parseInt(idx)+1, name: message.name, message: message.message}); | ||
}); | ||
break; | ||
case 'copy': | ||
break; | ||
case 'entrypoint': | ||
break; | ||
case 'volume': | ||
break; | ||
case 'user': | ||
checks.valid_user(args).forEach(function(message) { | ||
messages.push({line: parseInt(idx)+1, name: message.name, message: message.message}); | ||
}); | ||
break; | ||
case 'workdir': | ||
checks.is_valid_workdir(args).forEach(function(message) { | ||
messages.push({line: parseInt(idx)+1, name: message.name, message: message.message}); | ||
}); | ||
break; | ||
case 'arg': | ||
break; | ||
case 'onbuild': | ||
break; | ||
case 'stopsignal': | ||
break; | ||
default: | ||
messages.push({line: parseInt(idx)+1, name: 'invalid_command', message: 'Only supported Dockerfile commands are allowed'}); | ||
break; | ||
} | ||
} | ||
@@ -201,0 +201,0 @@ |
{ | ||
"name": "dockerfilelint", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "A linter for Dockerfiles to find bugs and encourage best practices", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
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
33430