Skip to content

Commit

Permalink
Merge pull request #502 from semgrep/nmote/healthcheck
Browse files Browse the repository at this point in the history
fix(dockerfile): Allow Semgrep ellipsis in healthcheck instruction
  • Loading branch information
nmote authored Aug 1, 2024
2 parents d34acba + a13431e commit fbbf4a3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lang/semgrep-grammars/src/semgrep-dockerfile/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,11 @@ module.exports = grammar(base_grammar, {
alias(/[hH][eE][aA][lL][tT][hH][cC][hH][eE][cC][kK]/, "HEALTHCHECK"),
choice(
$.semgrep_metavariable,
// To support `HEALTHCHECK ...`
$.semgrep_ellipsis,
"NONE",
seq(repeat($.param), $.cmd_instruction)
// semgrep ellipsis here to support `HEALTHCHECK ... CMD echo bar`
seq(repeat(choice($.semgrep_ellipsis, $.param)), $.cmd_instruction)
)
),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,10 @@ HEALTHCHECK
HEALTHCHECK NONE
HEALTHCHECK --timeout=30s CMD echo hello
HEALTHCHECK $X
HEALTHCHECK ... CMD echo hello
HEALTHCHECK --timeout=30s CMD ...
HEALTHCHECK ... CMD ...
HEALTHCHECK ...

---

Expand All @@ -476,7 +480,25 @@ HEALTHCHECK $X
(shell_command
(shell_fragment))))
(healthcheck_instruction
(semgrep_metavariable)))
(semgrep_metavariable))
(healthcheck_instruction
(semgrep_ellipsis)
(cmd_instruction
(shell_command
(shell_fragment))))
(healthcheck_instruction
(param)
(cmd_instruction
(shell_command
(semgrep_ellipsis))))
(healthcheck_instruction
(semgrep_ellipsis)
(cmd_instruction
(shell_command
(semgrep_ellipsis))))
(healthcheck_instruction
(semgrep_ellipsis)))


=============================================
Various string literals
Expand Down

0 comments on commit fbbf4a3

Please sign in to comment.