Allow parsing boolean in lists#741
Open
cipherboy wants to merge 1 commit intohashicorp:1.0.x-vaultfrom
Open
Conversation
cipherboy
added a commit
to cipherboy/openbao
that referenced
this pull request
Mar 20, 2025
Uncommenting the JSON test fails presently:
--- FAIL: TestPolicy_Parse (0.00s)
--- FAIL: TestPolicy_Parse/JSON (0.00s)
policy_test.go:247: value: &vault.PathRules{Path:"test/types", Policy:"", Permissions:(*vault.ACLPermissions)(0xc000467570), IsPrefix:false, HasSegmentWildcards:false, Capabilities:[]string{"create", "sudo"}, MinWrappingTTLHCL:interface {}(nil), MaxWrappingTTLHCL:interface {}(nil), AllowedParametersHCL:map[string][]interface {}{"int":[]interface {}{1, 2}, "map":[]interface {}{map[string]interface {}{"good":"one"}}}, DeniedParametersHCL:map[string][]interface {}{"bool":[]interface {}{}, "string":[]interface {}{"test"}}, RequiredParametersHCL:[]string(nil), MFAMethodsHCL:[]string(nil), PaginationLimitHCL:0}
policy_test.go:494: [slice[8].Permissions.DeniedParameters.map[bool].slice[0]: <no value> != false slice[8].DeniedParametersHCL.map[bool].slice[0]: <no value> != false]
FAIL
FAIL github.com/openbao/openbao/vault 0.021s
FAIL
See also: hashicorp/hcl#740
See also: hashicorp/hcl#741
Signed-off-by: Alexander Scheel <ascheel@gitlab.com>
This is tested in Vault's vault.TestPolicy_Parse:
path "test/types" {
capabilities = ["create", "sudo"]
allowed_parameters = {
"map" = [{"good" = "one"}]
"int" = [1, 2]
}
denied_parameters = {
"string" = ["test"]
"bool" = [false]
}
}
Creating the equivalent in JSON fails because HCLv1 silently fails to
parse this value:
"test/types": {
"capabilities": ["create", "sudo"],
"allowed_parameters": {
"map": [{"good": "one"}],
"int": [1, 2]
},
"denied_parameters": {
"string": ["test"],
"bool": [false]
}
}
Resolves: hashicorp#740
Signed-off-by: Alexander Scheel <alexander.m.scheel@gmail.com>
6fd4c90 to
ae3cb7f
Compare
cipherboy
added a commit
to openbao/openbao
that referenced
this pull request
Mar 20, 2025
* Validate policies can contain comments, be JSON
Uncommenting the JSON test fails presently:
--- FAIL: TestPolicy_Parse (0.00s)
--- FAIL: TestPolicy_Parse/JSON (0.00s)
policy_test.go:247: value: &vault.PathRules{Path:"test/types", Policy:"", Permissions:(*vault.ACLPermissions)(0xc000467570), IsPrefix:false, HasSegmentWildcards:false, Capabilities:[]string{"create", "sudo"}, MinWrappingTTLHCL:interface {}(nil), MaxWrappingTTLHCL:interface {}(nil), AllowedParametersHCL:map[string][]interface {}{"int":[]interface {}{1, 2}, "map":[]interface {}{map[string]interface {}{"good":"one"}}}, DeniedParametersHCL:map[string][]interface {}{"bool":[]interface {}{}, "string":[]interface {}{"test"}}, RequiredParametersHCL:[]string(nil), MFAMethodsHCL:[]string(nil), PaginationLimitHCL:0}
policy_test.go:494: [slice[8].Permissions.DeniedParameters.map[bool].slice[0]: <no value> != false slice[8].DeniedParametersHCL.map[bool].slice[0]: <no value> != false]
FAIL
FAIL github.com/openbao/openbao/vault 0.021s
FAIL
See also: hashicorp/hcl#740
See also: hashicorp/hcl#741
Signed-off-by: Alexander Scheel <ascheel@gitlab.com>
* Add comment and JSON form to policy docs
Signed-off-by: Alexander Scheel <ascheel@gitlab.com>
---------
Signed-off-by: Alexander Scheel <ascheel@gitlab.com>
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
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.
This is tested in Vault's vault.TestPolicy_Parse:
Creating the equivalent in JSON fails because HCLv1 silently fails to parse this value:
Resolves: #740