Skip to content

Commit

Permalink
check for unknown or bogous instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
rnagy committed Jan 3, 2018
1 parent b7addd1 commit 016185a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/checks.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ exports.all = [
'onbuild_disallowed',
'label_no_empty_value',
'variable_use',
'no_trailing_spaces'
'no_trailing_spaces',
'unknown_instruction'
]

# Match $VAR, ${VAR}, and ${VAR:-default}
Expand Down Expand Up @@ -382,3 +383,18 @@ exports.no_trailing_spaces = (rules) ->
utils.log 'ERROR', 'Lines cannot have trailing spaces'
return 'failed'
return 'ok'

# Unknown instructions are not supported by dockerlint
# Reports: ERROR
exports.unknown_instruction = (rules) ->
allowed_instructions = [ 'ADD', 'ARG', 'CMD', 'COPY', 'ENTRYPOINT', 'ENV', 'EXPOSE', 'FROM',
'HEALTHCHECK', 'LABEL', 'MAINTAINER', 'ONBUILD', 'RUN', 'SHELL',
'STOPSIGNAL', 'USER', 'VAR', 'VOLUME', 'WORKDIR' ]
for rule in rules
if rule.instruction not in allowed_instructions
if utils.notEmpty rule.instruction
utils.log 'ERROR', "#{rule.instruction} is invalid on line #{rule.line}"
else
utils.log 'ERROR', "Empty / bogus instruction is invalid on line #{rule.line}"
return 'failed'
return 'ok'

0 comments on commit 016185a

Please sign in to comment.