dockerlint
Advanced tools
Comparing version 0.1.1 to 0.1.2
// Generated by CoffeeScript 1.9.0 | ||
(function() { | ||
var getAll, getAllExcept, path, utils; | ||
var path, utils; | ||
@@ -9,3 +9,3 @@ path = require('path'); | ||
exports.all = ['from_first', 'no_empty_tag', 'json_array_format', 'json_array_even_quotes', 'add', 'multiple_entries', 'sudo', 'absolute_workdir', 'onbuild_copyadd', 'onbuild_disallowed']; | ||
exports.all = ['from_first', 'no_empty_tag', 'no_empty_digest', 'json_array_format', 'json_array_even_quotes', 'add', 'multiple_entries', 'sudo', 'absolute_workdir', 'onbuild_copyadd', 'onbuild_disallowed', 'label_no_empty_value']; | ||
@@ -24,3 +24,3 @@ Array.prototype.filter = function(func) { | ||
getAll = function(instruction, rules) { | ||
exports.getAll = function(instruction, rules) { | ||
return rules.filter(function(r) { | ||
@@ -31,3 +31,3 @@ return r.instruction === instruction; | ||
getAllExcept = function(instruction, rules) { | ||
exports.getAllExcept = function(instruction, rules) { | ||
return rules.filter(function(r) { | ||
@@ -40,3 +40,3 @@ return r.instruction !== instruction; | ||
var first, non_comments; | ||
non_comments = getAllExcept('comment', rules); | ||
non_comments = this.getAllExcept('comment', rules); | ||
first = non_comments[0]; | ||
@@ -47,2 +47,3 @@ if (first.instruction !== 'FROM') { | ||
} | ||
return 'ok'; | ||
}; | ||
@@ -52,3 +53,3 @@ | ||
var from, image, rule, tag, _i, _len, _ref; | ||
from = getAll('FROM', rules); | ||
from = this.getAll('FROM', rules); | ||
for (_i = 0, _len = from.length; _i < _len; _i++) { | ||
@@ -64,4 +65,21 @@ rule = from[_i]; | ||
} | ||
return 'ok'; | ||
}; | ||
exports.no_empty_digest = function(rules) { | ||
var digest, from, image, rule, _i, _len, _ref; | ||
from = this.getAll('FROM', rules); | ||
for (_i = 0, _len = from.length; _i < _len; _i++) { | ||
rule = from[_i]; | ||
if (rule["arguments"][0].match(/@/)) { | ||
_ref = rule["arguments"][0].split('@'), image = _ref[0], digest = _ref[1]; | ||
if (!utils.notEmpty(digest)) { | ||
utils.log('ERROR', "Digest must not be empty for \"" + image + "\" on line " + rule.line); | ||
return 'failed'; | ||
} | ||
} | ||
} | ||
return 'ok'; | ||
}; | ||
exports.json_array_format = function(rules) { | ||
@@ -72,3 +90,3 @@ var argument, i, r, rule, _i, _j, _k, _len, _len1, _len2, _ref, _ref1; | ||
i = _ref[_i]; | ||
rule = getAll(i, rules); | ||
rule = this.getAll(i, rules); | ||
for (_j = 0, _len1 = rule.length; _j < _len1; _j++) { | ||
@@ -86,2 +104,3 @@ r = rule[_j]; | ||
} | ||
return 'ok'; | ||
}; | ||
@@ -94,3 +113,3 @@ | ||
i = _ref[_i]; | ||
rule = getAll(i, rules); | ||
rule = this.getAll(i, rules); | ||
for (_j = 0, _len1 = rule.length; _j < _len1; _j++) { | ||
@@ -105,2 +124,3 @@ r = rule[_j]; | ||
} | ||
return 'ok'; | ||
}; | ||
@@ -110,3 +130,3 @@ | ||
var add, lines, rule, _i, _len; | ||
add = getAll('ADD', rules); | ||
add = this.getAll('ADD', rules); | ||
if (add.length > 0) { | ||
@@ -125,2 +145,3 @@ lines = []; | ||
} | ||
return 'ok'; | ||
}; | ||
@@ -133,3 +154,3 @@ | ||
e = _ref[_i]; | ||
rule = getAll(e, rules); | ||
rule = this.getAll(e, rules); | ||
if (rule.length > 1) { | ||
@@ -140,2 +161,3 @@ utils.log('ERROR', "Multiple " + e + " instructions found, only line " + rule[rule.length - 1].line + " will take effect"); | ||
} | ||
return 'ok'; | ||
}; | ||
@@ -145,3 +167,3 @@ | ||
var argument, rule, run, _i, _j, _len, _len1, _ref; | ||
run = getAll('RUN', rules); | ||
run = this.getAll('RUN', rules); | ||
for (_i = 0, _len = run.length; _i < _len; _i++) { | ||
@@ -158,2 +180,3 @@ rule = run[_i]; | ||
} | ||
return 'ok'; | ||
}; | ||
@@ -163,3 +186,3 @@ | ||
var rule, workdir, _i, _len; | ||
workdir = getAll('WORKDIR', rules); | ||
workdir = this.getAll('WORKDIR', rules); | ||
for (_i = 0, _len = workdir.length; _i < _len; _i++) { | ||
@@ -172,2 +195,3 @@ rule = workdir[_i]; | ||
} | ||
return 'ok'; | ||
}; | ||
@@ -177,3 +201,3 @@ | ||
var argument, onbuild, rule, _i, _j, _len, _len1, _ref; | ||
onbuild = getAll('ONBUILD', rules); | ||
onbuild = this.getAll('ONBUILD', rules); | ||
for (_i = 0, _len = onbuild.length; _i < _len; _i++) { | ||
@@ -190,2 +214,3 @@ rule = onbuild[_i]; | ||
} | ||
return 'ok'; | ||
}; | ||
@@ -195,3 +220,3 @@ | ||
var argument, chained_instruction, onbuild, rule, _i, _j, _len, _len1, _ref; | ||
onbuild = getAll('ONBUILD', rules); | ||
onbuild = this.getAll('ONBUILD', rules); | ||
for (_i = 0, _len = onbuild.length; _i < _len; _i++) { | ||
@@ -209,4 +234,26 @@ rule = onbuild[_i]; | ||
} | ||
return 'ok'; | ||
}; | ||
exports.label_no_empty_value = function(rules) { | ||
var argument, label, pair, rule, _i, _j, _k, _len, _len1, _len2, _ref, _ref1; | ||
label = this.getAll('LABEL', rules); | ||
for (_i = 0, _len = label.length; _i < _len; _i++) { | ||
rule = label[_i]; | ||
_ref = rule["arguments"]; | ||
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { | ||
argument = _ref[_j]; | ||
_ref1 = argument.split(' '); | ||
for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) { | ||
pair = _ref1[_k]; | ||
if (pair.slice(-1) === '=') { | ||
utils.log('ERROR', "LABEL requires value for line " + rule.line); | ||
return 'failed'; | ||
} | ||
} | ||
} | ||
} | ||
return 'ok'; | ||
}; | ||
}).call(this); |
@@ -16,3 +16,3 @@ // Generated by CoffeeScript 1.9.0 | ||
usage = function() { | ||
console.log("Dockerlint " + meta["version"] + "\n\n \tusage: dockerlint [-h] [-dp] -f Dockerfile"); | ||
console.log("Dockerlint " + meta["version"] + "\n\n \tusage: dockerlint [-h] [-dp] [-f Dockerfile]"); | ||
return process.exit(0); | ||
@@ -36,7 +36,3 @@ }; | ||
} | ||
if (args.file == null) { | ||
utils.log('FATAL', 'No Dockerfile specified with -f'); | ||
} else { | ||
dockerfile = args.file; | ||
} | ||
dockerfile = args.file || args._[0] || 'Dockerfile'; | ||
if (!fs.existsSync(dockerfile)) { | ||
@@ -43,0 +39,0 @@ utils.log("FATAL", "Cannot open " + dockerfile + "."); |
@@ -20,3 +20,3 @@ // Generated by CoffeeScript 1.9.0 | ||
var instruction; | ||
instruction = s.split(' ')[0]; | ||
instruction = s.split(/[ \t]/)[0]; | ||
if (instruction === '#') { | ||
@@ -23,0 +23,0 @@ return 'comment'; |
{ | ||
"name": "dockerlint", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Linting for Dockerfiles", | ||
@@ -5,0 +5,0 @@ "main": "bin/dockerlint", |
@@ -0,5 +1,7 @@ | ||
[![Build Status](https://travis-ci.org/RedCoolBeans/dockerlint.svg?branch=master)](https://travis-ci.org/RedCoolBeans/dockerlint) | ||
# Dockerlint | ||
Linting tool for Dockerfiles based on recommendations from | ||
[Dockerfile Reference](https://docs.docker.com/reference/builder/) and [Best practices for writing Dockerfiles](https://docs.docker.com/articles/dockerfile_best-practices/) as of Docker 1.5. | ||
[Dockerfile Reference](https://docs.docker.com/reference/builder/) and [Best practices for writing Dockerfiles](https://docs.docker.com/articles/dockerfile_best-practices/) as of Docker 1.6. | ||
@@ -16,3 +18,3 @@ ## Install | ||
dockerlint -f Dockerfile | ||
dockerlint Dockerfile | ||
@@ -19,0 +21,0 @@ Which will parse the file and notify you about any actual errors (such an |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
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
32574
18
410
49
1