-
Notifications
You must be signed in to change notification settings - Fork 476
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
Fix plugin config parsing code #3939
Merged
Merged
Conversation
This file contains 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
Recent changes to the plugin config parsing to retain plugin order failed to account for the more verbose HCL or JSON forms. This PR fixes the code to handle these forms as well as prevents duplicate declarations, which was accidentally allowed as part of the previous change. Fixes: spiffe#3938 Signed-off-by: Andrew Harding <azdagron@gmail.com>
azdagron
requested review from
evan2645,
amartinezfayo,
MarcosDY and
rturner3
as code owners
March 2, 2023 16:13
guilhermocc
reviewed
Mar 2, 2023
|
||
_, ok = configs.Find("WHATEVER", "NAME1") | ||
require.False(t, ok) | ||
t.Run("Plugin declared more than once", func(t *testing.T) { |
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.
Hey @azdagron what do you think about having an extra test case for an invalid number of keys here?
t.Run("Invalid number of keys", func(t *testing.T) {
config := `
plugins {
KEY1 "KEY2" KEY3 {
plugin_data = "DATA3"
enabled = false
}
}
`
root := struct {
Plugins ast.Node
}{}
err := hcl.Decode(&root, config)
require.NoError(t, err)
_, err = PluginConfigsFromHCLNode(root.Plugins)
require.EqualError(t, err, "expected one or two keys on the plugin item but got 3")
})
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.
Sure thing. Added.
Thank you for this @azdagron |
Signed-off-by: Andrew Harding <azdagron@gmail.com>
MarcosDY
approved these changes
Mar 2, 2023
stevend-uber
pushed a commit
to stevend-uber/spire
that referenced
this pull request
Oct 16, 2023
* Fix plugin config parsing code Recent changes to the plugin config parsing to retain plugin order failed to account for the more verbose HCL or JSON forms. This PR fixes the code to handle these forms as well as prevents duplicate declarations, which was accidentally allowed as part of the previous change. Fixes: spiffe#3938 Signed-off-by: Andrew Harding <azdagron@gmail.com> * Add another test case Signed-off-by: Andrew Harding <azdagron@gmail.com> --------- Signed-off-by: Andrew Harding <azdagron@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Recent changes to the plugin config parsing to retain plugin order failed to account for the more verbose HCL or JSON forms.
This PR fixes the code to handle these forms as well as prevents duplicate declarations, which was accidentally allowed as part of the previous change.
Fixes: #3938