Skip to content

Commit

Permalink
Merge pull request #43 from cyberark/fix-space-escapes
Browse files Browse the repository at this point in the history
Fix escaping of variable spaces
  • Loading branch information
izgeri authored Feb 1, 2019
2 parents bb43c2b + 70e997c commit 6de86fd
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

# [0.5.1]

* Fix path generation of variables with spaces
* Modify configuration loading to skip options that check home dirs if there is
an error retrieving the home dir

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.0
0.5.1
3 changes: 2 additions & 1 deletion _setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ if ! oss_only; then
exec_on cuke-master conjur host create --as-group security_admin bob
exec_on cuke-master conjur variable create existent-variable-with-undefined-value


vars=(
'existent-variable-with-defined-value'
'a/ b/c'
'myapp-01'
'alice@devops'
'prod/aws/db-password'
Expand All @@ -61,6 +61,7 @@ if ! oss_only; then

secrets=(
'existent-variable-defined-value'
'a/ b/c'
'these'
'are'
'all'
Expand Down
2 changes: 1 addition & 1 deletion conjurapi/router_v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (r RouterV4) variableURL(variableID string) (string, error) {
if err != nil {
return "", err
}
return fmt.Sprintf("%s/variables/%s/value", r.Config.ApplianceURL, url.QueryEscape(id)), nil
return fmt.Sprintf("%s/variables/%s/value", r.Config.ApplianceURL, url.PathEscape(id)), nil
}

func (r RouterV4) batchVariableURL(variableIDs []string) string {
Expand Down
2 changes: 1 addition & 1 deletion conjurapi/router_v5.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (r RouterV5) variableURL(variableID string) (string, error) {
if err != nil {
return "", err
}
return makeRouterURL(r.secretsURL(account), kind, url.QueryEscape(id)).String(), nil
return makeRouterURL(r.secretsURL(account), kind, url.PathEscape(id)).String(), nil
}

func (r RouterV5) batchVariableURL(variableIDs []string) string {
Expand Down
14 changes: 14 additions & 0 deletions conjurapi/variable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func TestClient_RetrieveSecret(t *testing.T) {
"research+development": "secret",
"sales&marketing": "strings!",
"onemore": "{\"json\": \"object\"}",
"a/ b /c": "somevalue",
}

policy := ""
Expand Down Expand Up @@ -251,6 +252,19 @@ func TestClient_RetrieveSecret(t *testing.T) {
So(string(obtainedSecretValue), ShouldEqual, secretValue)
})

Convey("Returns space-pathed existent variable's defined value", func() {
variableIdentifier := "a/ b/c"
secretValue := "a/ b/c"

conjur, err := NewClientFromKey(*config, authn.LoginPair{login, apiKey})
So(err, ShouldBeNil)

obtainedSecretValue, err := conjur.RetrieveSecret(variableIdentifier)
So(err, ShouldBeNil)

So(string(obtainedSecretValue), ShouldEqual, secretValue)
})

Convey("Returns 404 on existent variable with undefined value", func() {
variableIdentifier := "existent-variable-with-undefined-value"

Expand Down

0 comments on commit 6de86fd

Please sign in to comment.