Expand description
provider-neutral mandatory cleanup and optional secret storage for cloud-sdk.
Provider crates, explicit API domains, security-first release gates, and transport-free core types.
§cloud-sdk-sanitization
Provider-neutral cleanup and secret-handling boundary for the main
cloud-sdk workspace and
cloud-sdk crate.
This crate provides the mandatory volatile cleanup primitive used by the
default no_std SDK plus reusable caller-owned guards. It delegates clearing to the
independently reviewed sanitization
crate with default features disabled.
§Install
[dependencies]
cloud-sdk = "0.49.0"
cloud-sdk-sanitization = "0.17.0"§Example
use cloud_sdk_sanitization::SecretBuffer;
let mut output = [0_u8; 128];
{
let mut guarded = SecretBuffer::new(&mut output);
guarded.as_mut_slice()[..6].copy_from_slice(b"secret");
assert_eq!(&guarded.as_slice()[..6], b"secret");
}
assert_eq!(output, [0_u8; 128]);With the optional alloc feature, the reviewed
sanitization::SecretString is re-exported. It consumes an owned String
without copying its plaintext bytes, restricts access to checked closures, and
volatile-clears the full allocation capacity on drop:
extern crate alloc;
use alloc::string::String;
use cloud_sdk_sanitization::SecretString;
let secret = SecretString::from_string(String::from("temporary secret"));
assert_eq!(
secret.try_with_secret(|value| value == "temporary secret"),
Ok(true)
);
assert!(!alloc::format!("{secret:?}").contains("temporary secret"));try_append_secret_string grows protected text with fallible allocation and
a caller-supplied public byte ceiling. Growth prepares replacement storage,
then clears the old allocation before replacing it:
use cloud_sdk_sanitization::{SecretString, try_append_secret_string};
let mut secret = SecretString::empty();
try_append_secret_string(&mut secret, "bounded", 32)?;
assert_eq!(secret.try_with_secret(|text| text == "bounded"), Ok(true));§Features
| Feature | Default | Effect |
|---|---|---|
default | yes | Empty; keeps the boundary no_std. |
alloc | no | Adds owned volatile-clearing UTF-8 secret storage. |
std | no | Enables alloc and standard-library integration in cloud-sdk; clearing behavior is unchanged. |
Docs.rs builds with all features. The underlying sanitization dependency
keeps its default features disabled in every configuration.
§Security Notes
SecretBuffer volatile-clears its entire borrowed slice on drop, including
after early returns and unwind where unwind exists. SecretString clears its
full owned allocation capacity on drop. try_append_secret_string reports
bounded growth failure and clears old storage before replacement.
sanitize_bytes provides the reviewed byte primitive used by core;
sanitize_value applies the same boundary to scalar lifecycle state.
These helpers do not clear immutable source strings or copies made by transports, operating systems, crash handlers, swap, remote services, or other processes. They also do not replace review of token ownership, logging, environment variables, paging, compiler behavior, or process boundaries.
Structs§
- Secret
Buffer - Caller-owned byte buffer that is volatile-cleared when dropped.
- Secret
String - Heap-allocated secret UTF-8 text with clear-on-drop behavior.
Enums§
- Secret
String Append Error - Failure while fallibly appending to protected UTF-8 storage.
Functions§
- sanitize_
bytes - Volatile-clears an ordinary caller-owned byte buffer.
- sanitize_
string - Volatile-clears an owned UTF-8 allocation’s complete capacity.
- sanitize_
value - Volatile-clears one value through its reviewed field-wise sanitizer.
- try_
append_ secret_ string - Fallibly appends text to protected storage within a public byte bound.