-
Notifications
You must be signed in to change notification settings - Fork 0
apps cli smoke harness
Active contributors: Douwe de Vries
The CLI smoke harness is a small Rust command-line runtime for the shared anonymization core. It is useful for quick inspection, direct CSV transformation from a terminal, and release smoke checks that verify the Rust binary can remove known sensitive fixture values.
| Path | Role |
|---|---|
crates/csv-anonymizer-app/src/main.rs |
Process entry point, error exit handling, help and version dispatch |
crates/csv-anonymizer-app/src/cli.rs |
Argument parser and command execution against AnonymizerService
|
crates/csv-anonymizer-core/src/service.rs |
Shared analyze, preview, and anonymize behavior used by the CLI |
scripts/rust-smoke.mjs |
Node smoke runner that builds or reuses the binary and validates anonymized fixture output |
tests/fixtures/sample.csv |
Fixture used by the smoke script |
| Abstraction | Source | Notes |
|---|---|---|
CliAction |
crates/csv-anonymizer-app/src/cli.rs |
Parsed command enum for help, version, analyze, anonymize, and smoke anonymize. |
AnonymizerService |
crates/csv-anonymizer-core/src/service.rs |
Shared core service used by the CLI and desktop app. |
| Auto selection | should_auto_select_column |
Selects detector-risk columns for smoke anonymization. |
| Smoke fixture validation | scripts/rust-smoke.mjs |
Confirms output is created and source email values are absent. |
flowchart TD
Args[CLI args] --> Parse[parse_cli_args]
Parse --> Action{CliAction}
Action -->|analyze| Analyze[service.analyze_csv]
Action -->|anonymize| Anonymize[service.anonymize_csv]
Action -->|--smoke-anonymize| Smoke[analyze, auto-select, preview, anonymize]
Analyze --> Stdout[Column metadata on stdout]
Anonymize --> File[Output CSV]
Smoke --> File
main.rs calls parse_cli_args, prints help or version for those actions, and delegates executable actions to run_cli. Errors are printed to stderr and exit with code 1.
analyze <input.csv> loads the CSV through AnonymizerService::analyze_csv, prints the inspected row count and file path, then prints one tab-separated line per column with index, name, detected type, and PII risk.
anonymize --input <input.csv> --output <output.csv> --columns <0,1> [--force] writes transformed output through AnonymizerService::anonymize_csv. The command requires explicit column indices and uses the core default strategies unless controls are added in code later.
--smoke-anonymize <input.csv> <output.csv> is the release-oriented path. It analyzes the input, auto-selects columns using should_auto_select_column, generates a two-row preview, and runs anonymization with force: true. It fails if no auto-selectable columns are found or if preview samples are empty.
scripts/rust-smoke.mjs finds a binary from CSV_ANONYMIZER_BINARY or builds csv-anonymizer-app, runs --smoke-anonymize against tests/fixtures/sample.csv, verifies the output file exists, and checks that fixture source emails no longer appear in the output.
- Apps describes where this runtime sits beside the Desktop app.
- CSV file workflow shares the same core CSV analyze and anonymize service paths.
-
Privacy reporting describes the report data returned from
anonymize_csv. - Root scripts expose the smoke path through
npm run smoke:rustandnpm run smoke:packaged.
- Add or change CLI commands in
crates/csv-anonymizer-app/src/cli.rs. - Keep command parsing tests near the parser in
crates/csv-anonymizer-app/src/cli.rs. - Keep core behavior changes in
crates/csv-anonymizer-core/src/service.rsso the CLI and desktop app stay aligned. - Update
scripts/rust-smoke.mjsonly when the smoke contract, binary location, or fixture expectations change. - Avoid adding desktop-only concepts, such as path grants or Tauri dialogs, to the CLI harness.
| File | Why it matters |
|---|---|
crates/csv-anonymizer-app/src/cli.rs |
Defines analyze, anonymize, and --smoke-anonymize behavior. |
crates/csv-anonymizer-app/src/main.rs |
Wires parsed actions to process exit behavior. |
crates/csv-anonymizer-core/src/service.rs |
Provides the shared Rust core API called by the CLI. |
scripts/rust-smoke.mjs |
Builds or locates the CLI binary and verifies fixture anonymization. |