Skip to content

Commit e5b7479

Browse files
authored
fix: redact pkcs12 password in logs (#706)
* fix: Redact PKCS#12 keystore password in operator logs * review: Bounded Default impl + simplified call site
1 parent bc1dbae commit e5b7479

4 files changed

Lines changed: 26 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ 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.tls_pkcs12_password.unwrap_or_default(),
2626
)?))
2727
}
2828

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: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,15 @@ pub fn asn1time_to_offsetdatetime(asn: &Asn1TimeRef) -> Result<OffsetDateTime, A
181181
// When/if migrating to Valuable, provide a dummy implementation of Value too
182182
pub struct Unloggable<T>(pub T);
183183

184+
impl<T> Default for Unloggable<T>
185+
where
186+
T: Default,
187+
{
188+
fn default() -> Self {
189+
Self(T::default())
190+
}
191+
}
192+
184193
impl<T> Debug for Unloggable<T> {
185194
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
186195
f.write_str("<redacted>")
@@ -201,6 +210,12 @@ impl<T> DerefMut for Unloggable<T> {
201210
}
202211
}
203212

213+
impl<'de, T: serde::Deserialize<'de>> serde::Deserialize<'de> for Unloggable<T> {
214+
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
215+
T::deserialize(deserializer).map(Unloggable)
216+
}
217+
}
218+
204219
/// Wrapper type for [`Iterator::collect`] that flattens the incoming [`Iterator`].
205220
///
206221
/// This isn't super useful for "regular" collects (just call [`Iterator::flatten`]!),

0 commit comments

Comments
 (0)