Skip to content
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

Character '@' not correctly handled when at start of key #2996

Closed
zannen opened this issue Jul 12, 2017 · 2 comments
Closed

Character '@' not correctly handled when at start of key #2996

zannen opened this issue Jul 12, 2017 · 2 comments

Comments

@zannen
Copy link

zannen commented Jul 12, 2017

I'm trying to add key-value pairs to Vault where the key is a twitter handle (beginning with an @ character), using vault-0.7.3. I haven't got it to work yet...

From the documentation, values starting @ are described, but not keys:

Data is sent via additional arguments in "key=value" pairs. If value begins
with an "@", then it is loaded from a file. Write expects data in the file to
be in JSON format. If you want to start the value with a literal "@", then
prefix the "@" with a slash: "\@".
  • no @: working as expected:

    $ vault write secret/test 'a=b'
    Success! Data written to: secret/test
    
  • @ in value: working as expected:

    $ vault write secret/test 'a=@/dev/null'
    Success! Data written to: secret/test
    $ vault write secret/test a=@nonexistantfile
    Error loading data: Invalid key/value pair 'a=@nonexistantfile': error reading file: open nonexistantfile: no such file or directory
    
  • @ in key: not working as expected:

    • without escaping the at character with a backslash

      $ vault write secret/test @a=b
      Error loading data: Invalid key/value pair '@a=b': open a=b: no such file or directory
      

      I would have expected a key of @a and a password of b to be written. I'm not expecting Vault to look for a file called a=b.

    • with escaping the at character with a backslash:

      $ vault write secret/test '\@a=b'
      Success! Data written to: secret/test
      $ vault read secret/test
      Key             	Value
      ---             	-----
      refresh_interval	768h0m0s
      \@a               	b
      

      The \ has erroneously made its way into the key name.

@zannen
Copy link
Author

zannen commented Jul 14, 2017

Thanks for the speedy fix.

@shsjshentao
Copy link

vault write secret/test a=@b
Failed to parse K=V data: Invalid key/value pair 'a=@b': error reading file: open b: no such file or directory

vault write secret/test a=\@b
Success! Data written to: secret/test

According to the document showed this issue, is it right?
If you want to start the value with a literal "@", then
prefix the "@" with a slash: "@"

I think vault write secret/test a=@b should be stored ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants