-
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
Backport UI: KV version 2 advanced secret updates to 1.15.x (#25235) #25238
Changes from all commits
08eaac1
617e34e
43fac41
09d6578
826a501
a5d0561
c287088
8e42819
cda13d7
6af2419
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
ui: Do not disable JSON display toggle for KV version 2 secrets | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
ui: Fix copy button not working on masked input when value is not a string | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,19 @@ | |
<Icon @name="reload" /> | ||
</button> | ||
{{/if}} | ||
{{#if (and @allowObscure @readOnly)}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From precursor work |
||
{{! For safety we only use obscured values in readonly mode }} | ||
<div> | ||
<Toggle | ||
@name="revealValues" | ||
@checked={{this.revealValues}} | ||
@size="small" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original doesn't have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, in 1.15 |
||
@onChange={{fn (mut this.revealValues)}} | ||
> | ||
<span class="has-text-grey">Reveal values</span> | ||
</Toggle> | ||
</div> | ||
{{/if}} | ||
<div class="toolbar-separator"></div> | ||
<CopyButton | ||
class="button is-transparent" | ||
|
@@ -42,7 +55,7 @@ | |
{{/if}} | ||
<div | ||
{{code-mirror | ||
content=(or @value @example) | ||
content=(if this.showObfuscatedData this.obfuscatedData (or @value @example)) | ||
extraKeys=@extraKeys | ||
gutters=@gutters | ||
lineNumbers=(if @readOnly false true) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ | |
{{/if}} | ||
{{#if @allowCopy}} | ||
<CopyButton | ||
@clipboardText={{@value}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW I don't think this needs to be updated for It doesn't hurt to format 🤔 - mostly an FYI! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I checked before I made this backport that it was still failing for objects. Otherwise I'd love to not need this backport 😂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch! |
||
@clipboardText={{this.copyValue}} | ||
@success={{action (set-flash-message "Data copied!")}} | ||
@error={{action (set-flash-message "Error copying data" "danger")}} | ||
class="copy-button button {{if @displayOnly 'is-compact'}}" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,10 +11,30 @@ | |
*/ | ||
export function isAdvancedSecret(value) { | ||
try { | ||
const json = JSON.parse(value); | ||
if (Array.isArray(json)) return false; | ||
return Object.values(json).some((value) => typeof value !== 'string'); | ||
const obj = typeof value === 'string' ? JSON.parse(value) : value; | ||
if (Array.isArray(obj)) return false; | ||
return Object.values(obj).any((value) => typeof value !== 'string'); | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
|
||
/** | ||
* Method to obfuscate all values in a map, including nested values and arrays | ||
* @param obj object | ||
* @returns object | ||
*/ | ||
export function obfuscateData(obj) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From precursor work |
||
if (typeof obj !== 'object' || Array.isArray(obj)) return obj; | ||
const newObj = {}; | ||
for (const key of Object.keys(obj)) { | ||
if (Array.isArray(obj[key])) { | ||
newObj[key] = obj[key].map(() => '********'); | ||
} else if (typeof obj[key] === 'object') { | ||
newObj[key] = obfuscateData(obj[key]); | ||
} else { | ||
newObj[key] = '********'; | ||
} | ||
} | ||
return newObj; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,4 +100,25 @@ module('Integration | Component | json-editor', function (hooks) { | |
assert.dom('.CodeMirror-code').hasText(`1${this.example}`, 'Example is restored'); | ||
assert.strictEqual(this.value, null, 'Value is cleared on restore example'); | ||
}); | ||
|
||
test('obscure option works correctly', async function (assert) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From precursor work |
||
this.set('readOnly', true); | ||
await render(hbs`<JsonEditor | ||
@value={{this.json_blob}} | ||
@allowObscure={{true}} | ||
@readOnly={{this.readOnly}} | ||
@valueUpdated={{this.valueUpdated}} | ||
@onFocusOut={{this.onFocusOut}} | ||
/>`); | ||
assert.dom('.CodeMirror-code').hasText(`{ "test": "********"}`, 'shows data with obscured values'); | ||
assert.dom('[data-test-toggle-input="revealValues"]').isNotChecked('reveal values toggle is unchecked'); | ||
await click('[data-test-toggle-input="revealValues"]'); | ||
assert.dom('.CodeMirror-code').hasText(JSON_BLOB, 'shows data with real values'); | ||
assert.dom('[data-test-toggle-input="revealValues"]').isChecked('reveal values toggle is checked'); | ||
// turn obscure back on to ensure readonly overrides reveal setting | ||
await click('[data-test-toggle-input="revealValues"]'); | ||
this.set('readOnly', false); | ||
assert.dom('[data-test-toggle-input="revealValues"]').doesNotExist('reveal values toggle is hidden'); | ||
assert.dom('.CodeMirror-code').hasText(JSON_BLOB, 'shows data with real values on edit mode'); | ||
}); | ||
}); |
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.
#25269 was reliant on changes made in #25235, so I just lumped them in together here so I wouldn't forget to open the backport for this after the JSON update backport was merged