Invalid JSON in `CMD` is rewritten to exec form
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
Research direction
Start by locating the CMD handling and JSON argument parsing in the Go source, then read the tests for CMD formatting. Reproduce the case with CMD ["a",] and check that formatting leaves it unchanged when the arguments are not a valid JSON array. Add a regression test and confirm it passes with the project’s test suite.
Written by the indexing model from the issue text.
Description
CMD with an argument list that is not valid JSON gets wrapped into exec form. Docker treats such a line as shell form, so the rewrite changes the command the container runs.
Reproduce
FROM scratch
CMD ["a",]
dockerfmt Dockerfile
Actual
FROM scratch
CMD ["[\"a\",]"]
BuildKit's parser (v0.33.0) reads the original as shell form (/bin/sh -c '["a",]'). The output is exec form that runs a binary literally named ["a",].
Expected
Leave arguments that do not parse as a JSON array unchanged, as Docker does.
Reproduced with v0.5.4 and with main at a5868c2.
- Dominant language
- Go
- Stars
- 626
- Forks
- 23
- Avg merge
- 6d 23h
- Merged PRs (30d)
- 3
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from reteps/dockerfmt
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
`MAINTAINER` to `LABEL` conversion does not escape embedded quotesPossibly taken @RyoKusnadi claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Legacy `ENV key value` with a multi-word value becomes an invalid `key=value`Possibly taken @RyoKusnadi claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
All issues in reteps/dockerfmt
Similar issues
-
agent-butler-finding bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
jordansmall/spindrift#6414 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Icinga/icinga-kubernetes#294 ·
Maintainers usually reply within 4 days
-
Cluster details: the Control Plane version field has a different border color than its icon boxOpenkind/design sig/ui
Difficulty 1/5 Under an hour Newbie friendliness 92/100
kubermatic/dashboard#8449 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
filecoin-project/curio#1632 ·
Maintainers usually reply within 1 day