bxctl audit verify: name the log-like files it did not check
A .jsonl file whose name is not a date is ignored by brokerd and by verify; it is now listed, so "ok" does not seem to cover it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -11,14 +11,22 @@ use proto::ChainVerifier;
|
||||
pub fn run(home: &Path, out: &mut dyn Write) -> std::io::Result<bool> {
|
||||
let audit_dir = home.join("audit");
|
||||
let mut names: Vec<String> = Vec::new();
|
||||
let mut skipped: Vec<String> = Vec::new();
|
||||
for entry in std::fs::read_dir(&audit_dir)? {
|
||||
let entry = entry?;
|
||||
let name = match entry.file_name().into_string() {
|
||||
Ok(name) => name,
|
||||
Err(_) => continue,
|
||||
Err(raw) => {
|
||||
skipped.push(raw.to_string_lossy().into_owned());
|
||||
continue;
|
||||
}
|
||||
};
|
||||
if proto::is_audit_log_name(&name) {
|
||||
names.push(name);
|
||||
} else if name.ends_with(".jsonl") {
|
||||
// Looks like a log file but is not named as one: brokerd ignores it too. Say so, so
|
||||
// that nobody takes "ok" to cover it.
|
||||
skipped.push(name);
|
||||
}
|
||||
}
|
||||
names.sort();
|
||||
@@ -33,6 +41,7 @@ pub fn run(home: &Path, out: &mut dyn Write) -> std::io::Result<bool> {
|
||||
if let Some(failure) = &report.failure {
|
||||
writeln!(out, "{}:{}: {}", failure.file, failure.line, failure.what)?;
|
||||
writeln!(out, "see docs/runbook.md#audit-chain-broken")?;
|
||||
write_skipped(out, &skipped)?;
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
@@ -63,5 +72,19 @@ pub fn run(home: &Path, out: &mut dyn Write) -> std::io::Result<bool> {
|
||||
torn.at.file, torn.at.line
|
||||
)?;
|
||||
}
|
||||
write_skipped(out, &skipped)?;
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
/// One line per file in `audit/` that looks like a log but is not named as one; neither `brokerd`
|
||||
/// nor this check reads it. Names are escaped: a file name can hold anything.
|
||||
fn write_skipped(out: &mut dyn Write, skipped: &[String]) -> std::io::Result<()> {
|
||||
for name in skipped {
|
||||
writeln!(
|
||||
out,
|
||||
"not an audit log file, not checked: {}",
|
||||
crate::escape::escape_json_text(name)
|
||||
)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user