-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
consul-template
: revert function_denylist
logic
#12071
Conversation
5398ef5
to
59902d2
Compare
59902d2
to
cc72d17
Compare
5909792
to
a28dcfc
Compare
consul-template
: maintain backwards compatibility during agent config parsingconsul-template
: replace function_denylist
instead of append
consul-template
: replace function_denylist
instead of appendconsul-template
: replace function_denylist
instead of append during config parsing
"test-resources/client_with_function_denylist_empty_string.hcl", | ||
&client.ClientTemplateConfig{ | ||
DisableSandbox: true, | ||
FunctionDenylist: []string{""}, |
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.
This feels like a bug to me: when would we ever want this to be the result after a merged configuration? Are we validating it elsewhere?
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, it probably is, and I think you commented on the issue about that. Unfortunately, I pulled old code and confirmed that this currently does not fail validation. I added that comment to the issue thread as well.
My two thoughts other than continuing to allow this are either:
- Remove this check and open an issue to validate empty strings (or remove them?)
- Update this PR to validate empty strings (or remove them?)
Thoughts?
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'd say let's fix this issue once and for all here instead of trying to do it in another issue and having to touch this code again. There are two issues in #11923, but we're really only discussing one of them.
This is the JSON client configuration block from #11923 (comment):
"template": {
"function_denylist": [
""
]
}
This is an operator error: we should either correct it silently or return an error on startup. It's not clear to me at any point in the discussion in #11923 whether this configuration actually worked prior to 1.2.4. Generally speaking we don't silently correct things in the configuration, so my take is that this should blow up so the operator can fix their configuration. Especially because this is a security-related configuration.
The second issue is whether the configuration is being merged correctly with the defaults when we're done. It's not clear to me that the merging bug is a problem at all if the configuration were:
"template": {
"function_denylist": []
}
Because in that scenario the configuration is an empty slice and there's nothing to iterate over during the merge.
// Maintain backward compatibility for older clients | ||
if len(b.FunctionBlacklist) > 0 { | ||
for _, fn := range b.FunctionBlacklist { | ||
if !helper.SliceStringContains(result.FunctionBlacklist, fn) { | ||
result.FunctionBlacklist = append(result.FunctionBlacklist, fn) | ||
} | ||
} |
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.
Do we only ever call Merge
when merging onto the default configuration? If not, we're potentially dropping the merged-onto result by doing this, and it doesn't seem to be protecting us from the [""]
case (see the test below).
6574bd0
to
1ab6236
Compare
consul-template
: replace function_denylist
instead of append during config parsingconsul-template
: revert function_denylist
logic
consul-template
: revert function_denylist
logicconsul-template
: revert function_denylist
logic
43fa0d1
to
5abbf9c
Compare
consul-template
: revert function_denylist
logicconsul-template
: revert function_denylist
logic
@DerekStrickland just double checking I understand - are these all true?
|
Exactly that! |
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.
LGTM
Co-authored-by: Seth Hoenig <seth.a.hoenig@gmail.com>
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
Closes #11923
This PR fixes a regression that was introduced in 1.2.4 around the Consul Client Template configuration. The changes in that release erroneously merged user configuration with the default configuration for Consul Template. This resulted in a situation where the user could never override the default function deny list. The default
FunctionDenylist
values should only be applied if the user does not specify that field in their config.