This repository was archived by the owner on Jul 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 176
[WIP] Hardening the interpolation of parameters containing special characters #587
Draft
jcsirot
wants to merge
1
commit into
docker-archive-public:master
Choose a base branch
from
jcsirot:fix-var-substitution-regex
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
version: "3.0" | ||
services: | ||
test: | ||
command: | ||
- echo | ||
- brave | ||
- gnu | ||
- world | ||
image: alpine:latest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
version: 0.1.0 | ||
name: myapp | ||
maintainers: | ||
- name: dev | ||
email: [email protected] | ||
--- | ||
version: "3.0" | ||
services: | ||
test: | ||
image: alpine:latest | ||
command: echo ${texts.first} ${texts.second-1} ${texts.second-2} | ||
--- | ||
texts: | ||
first: "brave" | ||
second-1: "gnu" | ||
second-2: "world" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,6 @@ services: | |
image: image1 | ||
ports: | ||
- ${ports.service1:-9001} | ||
|
||
service2: | ||
image: image2 | ||
ports: | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shoud we add the
.
here? The cli doesn't have it, I'm not sure we really need itThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a true question. I added the
.
to make this test pass https://github.com/docker/app/blob/8d52f6d458163e8d5cac6147f6cb4c54092168af/internal/packager/init_test.go#L47But I'm not sure if the tested usecase is legit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the test is bogus since env variables can only be alphanumeric and
_
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dots are necessary for the indentation levels in the parameters
yaml
file.As in: https://github.com/docker/app/blob/8d52f6d458163e8d5cac6147f6cb4c54092168af/internal/packager/init_test.go#L75-L78
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah but here we are talking about variable substitution that the cli does, it can substitute an environment variable inside a compose file (using
${VARIABLE:-default_value}
notation. And an environment variable can only have[a-zA-Z_]+
. No dots.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test here is verifying the conversion of the valid compose file into a dockerapp file. But the compose file syntax does not support the dot notation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So one could say that it’s not a valid compose file :)