use std::path::Path;
const FORBIDDEN: &[&str] = &[
"pub fn secret_texts",
"pub fn secret_bytes",
"pub fn secret_literals",
"pub fn secret_values",
];
#[test]
fn the_crate_exposes_no_plaintext_secret_accessor() {
let root = Path::new(env!("CARGO_MANIFEST_DIR"));
let sources = [
"src/interop.rs",
"src/canonical.rs",
"src/ir.rs",
"src/lib.rs",
"src/protobuf.rs",
"src/view.rs",
];
let mut offenders = Vec::new();
for relative in sources {
let path = root.join(relative);
let text = std::fs::read_to_string(&path).expect("source file");
for (index, line) in text.lines().enumerate() {
let trimmed = line.trim();
if FORBIDDEN
.iter()
.any(|forbidden| trimmed.starts_with(forbidden))
{
offenders.push(format!("{}:{}: {}", relative, index + 1, trimmed));
}
if trimmed.starts_with("pub use") {
for forbidden in FORBIDDEN {
let name = forbidden.trim_start_matches("pub fn ");
if trimmed.contains(name) {
offenders.push(format!("{}:{}: {}", relative, index + 1, trimmed));
}
}
}
}
}
assert!(
offenders.is_empty(),
"the crate must not expose secret plaintext; found:\n{}",
offenders.join("\n")
);
}
#[test]
fn the_redaction_marker_is_the_only_public_secret_constant() {
assert_eq!(active_infinity::interop::SECRET_MARKER, "***SECRET***");
}