Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6e5c77c
Add Junit output. Minor bug fixes
lphiri Jul 30, 2020
819035d
chore: upd package-lock.json to v3
chaimleib Apr 16, 2026
ff785aa
refactor: remove devDeps mocha and should
chaimleib Apr 16, 2026
4ddd8c9
refactor(lodash): avoid deprecated _.contains -> includes
chaimleib Apr 16, 2026
823529a
chore: bump lodash@2.4.2 -> 3.10.1
chaimleib Apr 16, 2026
2267855
style: tidy up lib/extendify.js
chaimleib Apr 16, 2026
addc8a6
refactor(lodash): lodash 4 will remove the isDeep arg from clone
chaimleib Apr 16, 2026
c2bbd70
refactor(lodash): use Object.keys where _.keys is unnecessary
chaimleib Apr 17, 2026
c779492
style: bin/dockerfile_lint
chaimleib Apr 17, 2026
f7d79f9
refactor(lodash): use [...ary].map instead of _.map
chaimleib Apr 17, 2026
eaa1289
fix(security): replace unmaintained pre-commit with husky
chaimleib Apr 17, 2026
994159e
style: lib/rulefile-loader.js
chaimleib Apr 17, 2026
11e7499
fix(security): bump js-yaml@3.13.1 -> 4.1.1
chaimleib Apr 17, 2026
ee8f352
fix(security): bump fast-xml-parser@3.17.4 -> 5.6.0
chaimleib Apr 17, 2026
f4ce3f4
fix(security): bump dockerode@2.2.9 -> 4.0.10
chaimleib Apr 17, 2026
83a8bd2
chore(lodash): bump junit-report-builder@2.1.0 -> 5.1.2, uses latest …
chaimleib Apr 17, 2026
fb060b2
fix(security): use Object.hasOwn(obj, key) instead of obj.hasOwnPrope…
chaimleib Apr 17, 2026
eb6dc3d
fix(lodash): lodash 4 _.merge will stop replacing arrays with objects…
chaimleib Apr 17, 2026
d027d15
fix(security): bump lodash@3.10.1 -> 4.18.1
chaimleib Apr 17, 2026
da6a745
chore(npm): rebuild package-lock.json without Amex proxies
chaimleib Apr 17, 2026
5ebd815
fix(security): bump dockerode 4.0.10->5.0.0
chaimleib Apr 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm test
19 changes: 9 additions & 10 deletions bin/dockerfile_lint
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
'use strict';

var fs = require('fs'),
_ = require('lodash'),
yamlParser = require('js-yaml'),
commandline = require('commander'),
logger = require("../lib/logger"),
Expand All @@ -23,8 +22,8 @@ var fs = require('fs'),
imageid = null;

function collectArgs(arg, args) {
args.push(arg);
return args;
args.push(arg);
return args;
}

commandline
Expand All @@ -38,7 +37,7 @@ commandline

commandline.command('image <imageid>')
.description("Lint a local docker image matching <imageid>.\n The --dockerfile option is ignored when this command is used.")
.action(function (id) {
.action(function(id) {
lintImage = true;
imageid = id;
});
Expand Down Expand Up @@ -79,13 +78,13 @@ if (commandline.dockerfile.length === 0 && !lintImage) {


function lintDockerFiles() {
var lintPromises = _.map(commandline.dockerfile, function (dockerfileLocation) {
const lintPromises = [...commandline.dockerfile].map(function(dockerfileLocation) {
if (!commandline.json && !commandline.junit) {
console.info('\n# Analyzing ' + dockerfileLocation + '\n');
}
return lintDockerFile(dockerfileLocation);
});
Promise.all(lintPromises).then(function (results) {
Promise.all(lintPromises).then(function(results) {
if (commandline.json) {
printJsonResults(results.length === 1 ? results[0] : results);
} else if (commandline.junit) {
Expand All @@ -97,14 +96,14 @@ function lintDockerFiles() {
return total + result.error.count + (strictMode ? result.warn.count : 0);
}, 0);
process.exit(errorCodesSum);
}).catch(function (error) {
}).catch(function(error) {
console.error(error);
process.exit(-1);
});
}

function lintDockerFile(dockerfileLocation) {
return new Promise(function (resolve, reject) {
return new Promise(function(resolve, reject) {
try {
var dockerfile = fs.readFileSync(dockerfileLocation, 'UTF-8');
} catch (e) {
Expand All @@ -122,7 +121,7 @@ function lintDockerFile(dockerfileLocation) {
}

if (remoteFile) {
getContent(dockerfileLocation).then(function (dockerfileContent) {
getContent(dockerfileLocation).then(function(dockerfileContent) {
lint(dockerfileContent, rulefileLocation)
});
} else {
Expand Down Expand Up @@ -153,7 +152,7 @@ function lintImageFromInspect() {
}
}

image.inspect(function (err, data) {
image.inspect(function(err, data) {
if (err) {
logger.error("Unable to inspect image : " + imageid);
process.exit(1);
Expand Down
25 changes: 12 additions & 13 deletions bin/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
*/
'use strict';
var builder = require('junit-report-builder');
var util = require('util');

function getRefUrl(url) {
var ref_url = "";
if (util.isArray(url)) {
if (Array.isArray(url)) {
var base_url = url ? url[0] : "";
ref_url = url && url[1] ? base_url +
url[1] : base_url;
url[1] : base_url;
} else {
ref_url = (url) ? url : "None";
}
Expand All @@ -37,18 +36,18 @@ function isRedirect(statusCode) {
}

function getContent(url) {
return new Promise(function (resolve, reject) {
return new Promise(function(resolve, reject) {
var lib = url.startsWith('https') ? require('https') : require('http');
var request = lib.get(url, function (response) {
var request = lib.get(url, function(response) {
if (isRedirect(response.statusCode) && response.headers.location) {
getContent(res.headers.location).then(resolve).catch(reject);
}
if (response.statusCode < 200 || response.statusCode > 299) {
reject(new Error('Failed to load page, status code: ' + response.statusCode));
}
var body = [];
response.on('data', function (chunk) { body.push(chunk); });
response.on('end', function () { resolve(body.join('')); });
response.on('data', function(chunk) { body.push(chunk); });
response.on('end', function() { resolve(body.join('')); });
});
request.on('error', reject);
})
Expand All @@ -60,19 +59,19 @@ function printResults(results) {
var info = results.info;
if (errors && errors.data && errors.data.length > 0) {
console.log("\n--------ERRORS---------\n");
errors.data.forEach(function (entry) {
errors.data.forEach(function(entry) {
printEntry(entry, "ERROR");
});
}
if (warn && warn.data && warn.data.length > 0) {
console.log("\n-------WARNINGS--------\n");
warn.data.forEach(function (entry) {
warn.data.forEach(function(entry) {
printEntry(entry, "WARNING");
});
}
if (info && info.data && info.data.length > 0) {
console.log("\n--------INFO---------\n");
info.data.forEach(function (entry) {
info.data.forEach(function(entry) {
printEntry(entry, "INFO");
});
}
Expand Down Expand Up @@ -116,17 +115,17 @@ function printJunitResults(results) {

// Convert test results to JUnit test cases
if (errors && errors.data && errors.data.length > 0) {
errors.data.forEach(function (entry) {
errors.data.forEach(function(entry) {
makeJunitTestCase(suite, "ERROR", entry);
});
}
if (warn && warn.data && warn.data.length > 0) {
warn.data.forEach(function (entry) {
warn.data.forEach(function(entry) {
makeJunitTestCase(suite, "INFO", entry);
});
}
if (info && info.data && info.data.length > 0) {
info.data.forEach(function (entry) {
info.data.forEach(function(entry) {
makeJunitTestCase(suite, "WARNING", entry);
});
}
Expand Down
44 changes: 22 additions & 22 deletions lib/extendify.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,41 @@ const AND = 'and';
const UNION = 'union'

var recoginize = {
arrays : _.isArray,
booleans : _.isBoolean,
numbers : _.isNumber,
arrays: _.isArray,
booleans: _.isBoolean,
numbers: _.isNumber,
strings: _.isString
};

function getFuncByBehaviour(behaviour){
function getFuncByBehaviour(behaviour) {
switch (behaviour) {
case REPLACE:
return function(x,y) {
return function(x, y) {
return y;
};
case CONCAT:
return function(x,y) {
x = (_.isArray(x) || _.isString(x))? x : (_.isUndefined(x) ? [] : [x]);
y = (_.isArray(y) || _.isString(y))? y : (_.isUndefined(y) ? [] : [y]);
return function(x, y) {
x = (_.isArray(x) || _.isString(x)) ? x : (_.isUndefined(x) ? [] : [x]);
y = (_.isArray(y) || _.isString(y)) ? y : (_.isUndefined(y) ? [] : [y]);
return x.concat(y);
};
case UNION:
return function(x,y) {
return function(x, y) {
if (!_.isArray(x) && !_.isArray(y)) {
return undefined;
}
x = (_.isArray(x) || _.isString(x))? x : (_.isUndefined(x) ? [] : [x]);
y = (_.isArray(y) || _.isString(y))? y : (_.isUndefined(y) ? [] : [y]);
x = (_.isArray(x) || _.isString(x)) ? x : (_.isUndefined(x) ? [] : [x]);
y = (_.isArray(y) || _.isString(y)) ? y : (_.isUndefined(y) ? [] : [y]);
return _.union(x, y);
};
case MERGE:
return undefined;
case OR:
return function(x,y) {
return function(x, y) {
return x || y;
};
case AND:
return function(x,y) {
return function(x, y) {
return x && y;
};
}
Expand All @@ -54,21 +54,21 @@ function getFuncByBehaviour(behaviour){
function customizeExtend(options) {
options = options || {};

var inPlace = _.isUndefined(options.inPlace)? true : options.inPlace;
var inPlace = _.isUndefined(options.inPlace) ? true : options.inPlace;
delete options.inPlace;

var isDeep = _.isUndefined(options.isDeep)? true : options.isDeep;
var isDeep = _.isUndefined(options.isDeep) ? true : options.isDeep;
delete options.isDeep;

function customizeByOptions(x,y) {
if(!isDeep &&_.isPlainObject(y)){
function customizeByOptions(x, y) {
if (!isDeep && _.isPlainObject(y)) {
return y;
}

for(var type in options) {
for (var type in options) {
if (recoginize[type](y)) {
var customFunc = getFuncByBehaviour(options[type]);
if (_.isFunction(customFunc)){
if (_.isFunction(customFunc)) {
return customFunc(x, y);
}
break;
Expand All @@ -81,12 +81,12 @@ function customizeExtend(options) {
return function() {
var newArguments = Array.prototype.slice.call(arguments);

if (!inPlace){
newArguments[0] = _.clone(arguments[0], isDeep);
if (!inPlace) {
newArguments[0] = (isDeep ? _.cloneDeep : _.clone)(arguments[0]);
}

newArguments.push(customizeByOptions);
return _.merge.apply(this, newArguments);
return _.mergeWith.apply(this, newArguments);
}
}

Expand Down
Loading