-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
web-cli quote parsing #6755
Conversation
ui/app/lib/console-helpers.js
Outdated
// 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, '')) |
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.
🤔 maybe we should strip single quotes here too...
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.
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)}`, |
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.
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" \ |
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.
The space in Service Accounts
was what didn't work previously.
…ing interpolation
fbdeb6a
to
b02978d
Compare
51a1bad
to
c945dd0
Compare
* 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
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.