UI: Disallow kv2 with too large 'max versions' value (#9242)

This commit is contained in:
Chelsea Shaw 2020-06-17 15:24:10 -05:00 committed by GitHub
parent a5ae18d285
commit 4ea3a0f4ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -262,7 +262,7 @@ export default Component.extend(FocusOnInsertMixin, WithNavToNearestAncestor, {
this.flashMessages.success('Secret Successfully Wrapped!'); this.flashMessages.success('Secret Successfully Wrapped!');
}) })
.catch(() => { .catch(() => {
this.flashMessages.error('Could Not Wrap Secret'); this.flashMessages.danger('Could Not Wrap Secret');
}) })
.finally(() => { .finally(() => {
this.set('isWrapping', false); this.set('isWrapping', false);
@ -276,7 +276,7 @@ export default Component.extend(FocusOnInsertMixin, WithNavToNearestAncestor, {
this.flashMessages.success('Secret Successfully Wrapped!'); this.flashMessages.success('Secret Successfully Wrapped!');
}) })
.catch(() => { .catch(() => {
this.flashMessages.error('Could Not Wrap Secret'); this.flashMessages.danger('Could Not Wrap Secret');
}) })
.finally(() => { .finally(() => {
this.set('isWrapping', false); this.set('isWrapping', false);
@ -294,16 +294,23 @@ export default Component.extend(FocusOnInsertMixin, WithNavToNearestAncestor, {
}, },
handleCopyError() { handleCopyError() {
this.flashMessages.error('Could Not Copy Wrapped Data'); this.flashMessages.danger('Could Not Copy Wrapped Data');
this.send('clearWrappedData'); this.send('clearWrappedData');
}, },
createOrUpdateKey(type, event) { createOrUpdateKey(type, event) {
event.preventDefault(); event.preventDefault();
const MAXIMUM_VERSIONS = 9999999999999999;
let model = this.modelForData; let model = this.modelForData;
let secret = this.model;
// prevent from submitting if there's no key // prevent from submitting if there's no key
// maybe do something fancier later
if (type === 'create' && isBlank(model.path || model.id)) { if (type === 'create' && isBlank(model.path || model.id)) {
this.flashMessages.danger('Please provide a path for the secret');
return;
}
const maxVersions = secret.get('maxVersions');
if (MAXIMUM_VERSIONS < maxVersions) {
this.flashMessages.danger('Max versions is too large');
return; return;
} }