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

web-cli quote parsing #6755

Merged
merged 6 commits into from
May 22, 2019
Merged

web-cli quote parsing #6755

merged 6 commits into from
May 22, 2019

Conversation

meirish
Copy link
Contributor

@meirish meirish commented May 17, 2019

Previously if there was a space in a quoted value, the web cli would parse that incorrectly and break on the space, causing a whole set of wrong values to be written as this would also change any values after it. Additionally, there was an issue when quoting items in the web cli - the quotes would get written as part of the value.

This PR should fix both of these issues.

NOTE: this removes support for using " in paths in the web-cli, while this was nice, I think the use case of quoting attributes will be more common. Creating secrets from the GUI does still support " and ' in paths if that is needed.

// we'll have arg=something or arg="lol I need spaces", so need to split on the first =
.split(/=(.+)/)
// remove " at the beginning and end of each item
.map(item => item.replace(/^"|"$/gi, ''))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 maybe we should strip single quotes here too...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated this so it 1) also strips single quotes, and 2) will only do so if the quotes are matching

@@ -9,7 +9,7 @@ const consoleComponent = create(consoleClass);

const tokenWithPolicy = async function(name, policy) {
await consoleComponent.runCommands([
`write sys/policies/acl/${name} policy=${policy}`,
`write sys/policies/acl/${name} policy=${btoa(policy)}`,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of the changes in string handling, interpolation with multiple nested quotes didn't work properly any more for writing policies in tests. The work-around for this was to base64 encode the string prior to interpolation since vault's api supports writing policy in this way ✨

command: `vault write \
auth/ldap/config \
url=ldap://ldap.example.com:3268 \
binddn="CN=ServiceViewDev,OU=Service Accounts,DC=example,DC=com" \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The space in Service Accounts was what didn't work previously.

@meirish meirish requested review from a team May 20, 2019 17:05
andaley
andaley previously approved these changes May 20, 2019
@meirish meirish force-pushed the ui-cli-quote-parse branch from 51a1bad to c945dd0 Compare May 21, 2019 19:04
@meirish meirish added this to the 1.1.3 milestone May 22, 2019
@meirish meirish merged commit eba703b into master May 22, 2019
@meirish meirish deleted the ui-cli-quote-parse branch May 22, 2019 21:07
meirish added a commit that referenced this pull request Jun 4, 2019
* upgrade yargs-parser for better quote handling

* remove encoding pre&post parse, and remove wrapping quotes when pushing to data array

* add test for spaces and strings

* base64 encode policy strings in tests where we're using them with string interpolation

* improve regex to only remove wrapping single and double quotes

* don't support quotes in paths in the web cli
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

Successfully merging this pull request may close these issues.

2 participants