Skip to content

Commit 6952829

Browse files
committed
fix: Redact PKCS#12 keystore password in operator logs
1 parent bc1dbae commit 6952829

4 files changed

Lines changed: 21 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ All notable changes to this project will be documented in this file.
1313

1414
- Document Helm deployed RBAC permissions and remove unnecessary permissions ([#693]).
1515

16+
### Fixed
17+
18+
- Redact the user-provided PKCS#12 keystore password in operator logs. ([#706]).
19+
1620
[#693]: https://github.com/stackabletech/secret-operator/pull/693
21+
[#706]: https://github.com/stackabletech/secret-operator/pull/706
1722

1823
## [26.3.0] - 2026-03-16
1924

rust/operator-binary/src/format/convert.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ pub fn convert(
2222
(WellKnownSecretData::TlsPem(pem), SecretFormat::TlsPkcs12) => {
2323
Ok(WellKnownSecretData::TlsPkcs12(convert_tls_to_pkcs12(
2424
pem,
25-
compat.tls_pkcs12_password.as_deref().unwrap_or_default(),
25+
compat
26+
.tls_pkcs12_password
27+
.as_deref()
28+
.map_or("", String::as_str),
2629
)?))
2730
}
2831

rust/operator-binary/src/format/well_known.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ use stackable_operator::schemars::{self, JsonSchema};
44
use strum::EnumDiscriminants;
55

66
use super::{ConvertError, SecretFiles, convert};
7-
use crate::{backend::ProvisionParts, utils::ResultExt};
7+
use crate::{
8+
backend::ProvisionParts,
9+
utils::{ResultExt, Unloggable},
10+
};
811

912
const FILE_PEM_CERT_CERT: &str = "tls.crt";
1013
const FILE_PEM_CERT_KEY: &str = "tls.key";
@@ -168,7 +171,7 @@ pub struct CompatibilityOptions {
168171
rename = "secrets.stackable.tech/format.compatibility.tls-pkcs12.password",
169172
default
170173
)]
171-
pub tls_pkcs12_password: Option<String>,
174+
pub tls_pkcs12_password: Option<Unloggable<String>>,
172175
}
173176

174177
/// Options to customize the well-known format file names.

rust/operator-binary/src/utils.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ pub fn asn1time_to_offsetdatetime(asn: &Asn1TimeRef) -> Result<OffsetDateTime, A
179179

180180
/// Wrapper for (mostly) secret values that should not be logged.
181181
// When/if migrating to Valuable, provide a dummy implementation of Value too
182+
#[derive(Default)]
182183
pub struct Unloggable<T>(pub T);
183184

184185
impl<T> Debug for Unloggable<T> {
@@ -201,6 +202,12 @@ impl<T> DerefMut for Unloggable<T> {
201202
}
202203
}
203204

205+
impl<'de, T: serde::Deserialize<'de>> serde::Deserialize<'de> for Unloggable<T> {
206+
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
207+
T::deserialize(deserializer).map(Unloggable)
208+
}
209+
}
210+
204211
/// Wrapper type for [`Iterator::collect`] that flattens the incoming [`Iterator`].
205212
///
206213
/// This isn't super useful for "regular" collects (just call [`Iterator::flatten`]!),

0 commit comments

Comments
 (0)