keychain-forensic 0.1.0

macOS Keychain forensic toolkit built on keychain-core — the kc4n6 CLI audits a login.keychain-db offline: recover generic-password secrets and the Chromium 'Safe Storage' key given the login password, or report the store as present-but-locked
Documentation
//! `kc4n6` binary — a thin shell over the `keychain_forensic` library (Humble
//! Object): parse args, run the audit, print (text or JSON), set the exit code.
//! All decisions live in the library so they are unit-tested; this file is the
//! irreducible I/O + transport shell.

use std::process::ExitCode;

use clap::Parser;
use keychain_forensic::{render_text, Cli};

fn main() -> ExitCode {
    let cli = Cli::parse();
    match cli.run() {
        Ok(report) => {
            if cli.json {
                match serde_json::to_string_pretty(&report) {
                    Ok(s) => println!("{s}"),
                    Err(e) => {
                        eprintln!("error serializing report: {e}");
                        return ExitCode::FAILURE;
                    }
                }
            } else {
                print!("{}", render_text(&report));
            }
            ExitCode::SUCCESS
        }
        Err(e) => {
            eprintln!("kc4n6: {e}");
            ExitCode::FAILURE
        }
    }
}