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

validate-dockerfile

Package Overview
Dependencies
Maintainers
1
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.3.0 to 1.4.0

test/instructions.js

39

index.js

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

var hasFrom = false;
var fromCheck = false;
var hasCmd = false;

@@ -51,6 +51,3 @@ var currentLine = 0;

var linesArr = dockerfile.split('\n').filter(function (line) {
var tLine = line.trim();
return tLine && tLine[0] !== '#';
});
var linesArr = dockerfile.split('\n');

@@ -60,3 +57,17 @@ function validateLine(line) {

line = line.trim();
if (!line || line[0] === '#') {
return;
}
// First instruction must be FROM
if (!fromCheck) {
fromCheck = true;
if (line.toUpperCase().indexOf('FROM') !== 0) {
errors.push({
message: 'Missing or misplaced FROM',
line: currentLine
});
}
}
var instruction = instructionsRegex.exec(line);

@@ -86,15 +97,9 @@ if (!instruction) {

return true;
};
if (!linesArr.length) {
errors.push({
message: 'Empty dockerfile'
});
return finish(errors);
}
// First line should be FROM instruction
if (linesArr[0].toUpperCase().indexOf('FROM') !== 0) {
linesArr.forEach(validateLine);
if (!fromCheck) {
errors.push({
message: 'Missing FROM',
message: 'Missing or misplaced FROM',
line: 1

@@ -104,4 +109,2 @@ });

linesArr.forEach(validateLine);
if (!hasCmd) {

@@ -114,4 +117,4 @@ errors.push({

return finish(errors);
};
}
module.exports = validate;
{
"name": "validate-dockerfile",
"version": "1.3.0",
"version": "1.4.0",
"description": "Validates a Dockerfile",

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

@@ -41,3 +41,3 @@ #validate-dockerfile

- i.e. `FROM Incom/Z-95 Headhunter`
- `Missing FROM`
- `Missing or misplaced FROM`
- `FROM` is not the first instruction in the dockerfile.

@@ -48,5 +48,2 @@ - For more: https://docs.docker.com/reference/builder/#from

- For more: https://docs.docker.com/reference/builder/#cmd
- `Empty dockerfile`
- The dockerfile does not contain any instructions
- More than likely, you're passing the wrong parameter
- `Invalid type`

@@ -53,0 +50,0 @@ - You gave us something other than a string

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

stderr.should.eql(['VALIDATION FAILED',
'Missing FROM',
'Missing or misplaced FROM',
'at line 1',

@@ -38,0 +38,0 @@ 'Invalid instruction',

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