feat(controller/utils): add bunch of zeroizers
This commit is contained in:
parent
a42cc2e7ac
commit
e357f87b43
2 changed files with 32 additions and 1 deletions
|
|
@ -1 +1 @@
|
||||||
|
pub mod zeroizers;
|
||||||
|
|
|
||||||
31
kuyaseg-controller/src/utils/zeroizers.rs
Normal file
31
kuyaseg-controller/src/utils/zeroizers.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
use zeroize::Zeroize;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn zeroize_bytestring(this: &mut k8s_openapi::ByteString) {
|
||||||
|
this.0.zeroize();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn zeroize_btree<K, T: Zeroize>(this: &mut std::collections::BTreeMap<K, T>) {
|
||||||
|
this.values_mut().for_each(|v| v.zeroize());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn zeroize_btree_of_bytestring<K>(this: &mut std::collections::BTreeMap<K, k8s_openapi::ByteString>) {
|
||||||
|
this.values_mut().for_each(zeroize_bytestring);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn zeroize_hashmap<K, T: Zeroize>(this: &mut std::collections::HashMap<K, T>) {
|
||||||
|
this.values_mut().for_each(|v| v.zeroize());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn zeroize_k8s_secret(this: &mut k8s_openapi::api::core::v1::Secret) {
|
||||||
|
if let Some(data) = this.data.as_mut() {
|
||||||
|
zeroize_btree_of_bytestring(data);
|
||||||
|
}
|
||||||
|
if let Some(data) = this.string_data.as_mut() {
|
||||||
|
zeroize_btree(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue