mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 11:08:10 +00:00
UI: better calculation for advanced secret in KV v2 (#24513)
* Add util for determining whether secret data is advanced * Add test coverage for bug * use non-dumb logic for detecting advanced object * Add changelog * Add header * Move util to core * Add escaped newline to test coverage * headers again *eyeroll*
This commit is contained in:
20
ui/lib/core/addon/utils/advanced-secret.js
Normal file
20
ui/lib/core/addon/utils/advanced-secret.js
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Method to check whether the secret value is a nested object (returns true)
|
||||
* All other values return false
|
||||
* @param value string or stringified JSON
|
||||
* @returns boolean
|
||||
*/
|
||||
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');
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user