From ed0373b710ab49b2ddf67ab45928c2a8a69a81ab Mon Sep 17 00:00:00 2001 From: Brad Larsen Date: Mon, 27 Nov 2023 17:15:58 -0500 Subject: [PATCH] Add a `--quiet` option; send log messages to stderr Fixes #97. --- CHANGELOG.md | 3 ++ crates/noseyparker-cli/src/args.rs | 20 ++++++++++--- crates/noseyparker-cli/src/cmd_scan.rs | 2 +- crates/noseyparker-cli/src/main.rs | 30 +++++++++++++------ .../test_noseyparker__help__help-2.snap | 10 +++++-- ...t_noseyparker__help__help_datastore-2.snap | 10 +++++-- ...test_noseyparker__help__help_github-2.snap | 10 +++++-- ...oseyparker__help__help_github_repos-2.snap | 10 +++++-- ...rker__help__help_github_repos_short-2.snap | 3 +- ...oseyparker__help__help_github_short-2.snap | 1 + ...test_noseyparker__help__help_report-2.snap | 10 +++++-- ...oseyparker__help__help_report_short-2.snap | 1 + .../test_noseyparker__help__help_rules-2.snap | 10 +++++-- .../test_noseyparker__help__help_scan-2.snap | 10 +++++-- ..._noseyparker__help__help_scan_short-2.snap | 1 + .../test_noseyparker__help__help_short-2.snap | 3 +- ...t_noseyparker__help__help_summarize-2.snap | 10 +++++-- ...yparker__help__help_summarize_short-2.snap | 1 + .../test_noseyparker__help__no_args-3.snap | 3 +- .../noseyparker-cli/tests/scan/basic/mod.rs | 4 +-- .../noseyparker-cli/tests/scan/git_url/mod.rs | 6 ++-- 21 files changed, 120 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df6b17c6c..eb9814452 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - React App Username - React App Password +- A new global `--quiet` / `-q` option has been added, which suppresses non-error feedback messages and disables progress bars. + ### Fixes - Command-line parameters that can meaningfully accept negative numbers can now be specified without having to use `--PARAMETER=NEGATIVE_VALUE` syntax; a space can now separate the paraemter and the value. @@ -92,6 +94,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - `md5crypt Hash` (id `np.md5.1`) has been renamed to `Password Hash (md5crypt)` and re-identified as `np.pwhash.1`. - `bcrypt Hash` (id `np.bcrypt.1`) has been renamed to `Password Hash (bcrypt)` and re-identified as `np.pwhash.2`. +- Log messages are written to stderr instead of stdout. ## [v0.15.0](https://github.com/praetorian-inc/noseyparker/releases/v0.15.0) (2023-10-12) diff --git a/crates/noseyparker-cli/src/args.rs b/crates/noseyparker-cli/src/args.rs index c0e7e32a7..142a234d3 100644 --- a/crates/noseyparker-cli/src/args.rs +++ b/crates/noseyparker-cli/src/args.rs @@ -113,6 +113,11 @@ impl CommandLineArgs { args.global_args.color = Mode::Never } + // If `--quiet` is specified, disable progress bars + if args.global_args.quiet { + args.global_args.progress = Mode::Never; + } + args } } @@ -191,9 +196,16 @@ pub struct GlobalArgs { #[arg(global=true, long, short, action=ArgAction::Count)] pub verbose: u8, + /// Suppress non-error feedback messages + /// + /// This silences WARNING, INFO, DEBUG, and TRACE messages and disables progress bars. + /// This overrides any provided verbosity and progress reporting options. + #[arg(global=true, long, short)] + pub quiet: bool, + /// Enable or disable colored output /// - /// When this is "auto", colors are enabled when stdout is a tty. + /// When this is "auto", colors are enabled for stdout and stderr when they are terminals. /// /// If the `NO_COLOR` environment variable is set, it takes precedence and is equivalent to `--color=never`. #[arg(global=true, long, default_value_t=Mode::Auto, value_name="MODE")] @@ -201,7 +213,7 @@ pub struct GlobalArgs { /// Enable or disable progress bars /// - /// When this is "auto", progress bars are enabled when stderr is a tty. + /// When this is "auto", progress bars are enabled when stderr is a terminal. #[arg(global=true, long, default_value_t=Mode::Auto, value_name="MODE")] pub progress: Mode, @@ -243,11 +255,11 @@ pub struct AdvancedArgs { } impl GlobalArgs { - pub fn use_color(&self) -> bool { + pub fn use_color(&self, out: T) -> bool { match self.color { Mode::Never => false, Mode::Always => true, - Mode::Auto => std::io::stdout().is_terminal(), + Mode::Auto => out.is_terminal(), } } diff --git a/crates/noseyparker-cli/src/cmd_scan.rs b/crates/noseyparker-cli/src/cmd_scan.rs index 5c49e5bd8..3eef69495 100644 --- a/crates/noseyparker-cli/src/cmd_scan.rs +++ b/crates/noseyparker-cli/src/cmd_scan.rs @@ -624,7 +624,7 @@ pub fn run(global_args: &args::GlobalArgs, args: &args::ScanArgs) -> Result<()> let matches_summary = datastore.summarize()?; let matches_table = crate::cmd_summarize::summary_table(&matches_summary); println!(); - matches_table.print_tty(global_args.use_color())?; + matches_table.print_tty(global_args.use_color(std::io::stdout()))?; } println!("\nRun the `report` command next to show finding details."); diff --git a/crates/noseyparker-cli/src/main.rs b/crates/noseyparker-cli/src/main.rs index 80a971ba4..e8e5885a5 100644 --- a/crates/noseyparker-cli/src/main.rs +++ b/crates/noseyparker-cli/src/main.rs @@ -19,36 +19,47 @@ mod util; use args::GlobalArgs; +/// Set up the logging / tracing system for the application. fn configure_tracing(global_args: &GlobalArgs) -> Result<()> { use tracing_log::{AsLog, LogTracer}; use tracing_subscriber::{filter::LevelFilter, EnvFilter}; - let level_filter = match global_args.verbose { - 0 => LevelFilter::WARN, - 1 => LevelFilter::INFO, - 2 => LevelFilter::DEBUG, - _ => LevelFilter::TRACE, + // Set the tracing level according to the `-q`/`--quiet` and `-v`/`--verbose` options + let level_filter = if global_args.quiet { + LevelFilter::ERROR + } else { + match global_args.verbose { + 0 => LevelFilter::WARN, + 1 => LevelFilter::INFO, + 2 => LevelFilter::DEBUG, + _ => LevelFilter::TRACE, + } }; + // Configure the bridge from the `log` crate to the `tracing` crate LogTracer::builder() .with_max_level(level_filter.as_log()) .init()?; + // Configure logging filters according to the `NP_LOG` environment variable let env_filter = EnvFilter::builder() .with_default_directive(level_filter.into()) .with_env_var("NP_LOG") .from_env() .context("Failed to parse filters from NP_LOG environment variable")?; + // Install the global tracing subscriber let subscriber = tracing_subscriber::FmtSubscriber::builder() - .with_ansi(global_args.use_color()) + .with_ansi(global_args.use_color(std::io::stderr())) .with_env_filter(env_filter) + .with_writer(std::io::stderr) .finish(); tracing::subscriber::set_global_default(subscriber)?; Ok(()) } +/// Set the process rlimits according to the global arguments. fn configure_rlimits(global_args: &GlobalArgs) -> Result<()> { use rlimit::Resource; use std::cmp::max; @@ -62,12 +73,13 @@ fn configure_rlimits(global_args: &GlobalArgs) -> Result<()> { Ok(()) } +/// Enable or disable colored output according to the global arguments. fn configure_color(global_args: &GlobalArgs) { - let use_color = global_args.use_color(); - console::set_colors_enabled(use_color); - console::set_colors_enabled_stderr(use_color); + console::set_colors_enabled(global_args.use_color(std::io::stdout())); + console::set_colors_enabled_stderr(global_args.use_color(std::io::stderr())); } +/// Enable or disable backtraces for the process according to the global arguments. fn configure_backtraces(global_args: &GlobalArgs) { if global_args.advanced.enable_backtraces { // Print a stack trace in case of panic. diff --git a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help-2.snap b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help-2.snap index 4ee63571a..9ea9d6226 100644 --- a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help-2.snap +++ b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help-2.snap @@ -30,10 +30,16 @@ Global Options: This can be repeated up to 3 times to enable successively more output. + -q, --quiet + Suppress non-error feedback messages + + This silences WARNING, INFO, DEBUG, and TRACE messages and disables progress bars. This + overrides any provided verbosity and progress reporting options. + --color Enable or disable colored output - When this is "auto", colors are enabled when stdout is a tty. + When this is "auto", colors are enabled for stdout and stderr when they are terminals. If the `NO_COLOR` environment variable is set, it takes precedence and is equivalent to `--color=never`. @@ -44,7 +50,7 @@ Global Options: --progress Enable or disable progress bars - When this is "auto", progress bars are enabled when stderr is a tty. + When this is "auto", progress bars are enabled when stderr is a terminal. [default: auto] [possible values: auto, never, always] diff --git a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_datastore-2.snap b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_datastore-2.snap index 79545dc38..8c7052a6a 100644 --- a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_datastore-2.snap +++ b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_datastore-2.snap @@ -20,10 +20,16 @@ Global Options: This can be repeated up to 3 times to enable successively more output. + -q, --quiet + Suppress non-error feedback messages + + This silences WARNING, INFO, DEBUG, and TRACE messages and disables progress bars. This + overrides any provided verbosity and progress reporting options. + --color Enable or disable colored output - When this is "auto", colors are enabled when stdout is a tty. + When this is "auto", colors are enabled for stdout and stderr when they are terminals. If the `NO_COLOR` environment variable is set, it takes precedence and is equivalent to `--color=never`. @@ -34,7 +40,7 @@ Global Options: --progress Enable or disable progress bars - When this is "auto", progress bars are enabled when stderr is a tty. + When this is "auto", progress bars are enabled when stderr is a terminal. [default: auto] [possible values: auto, never, always] diff --git a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_github-2.snap b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_github-2.snap index c6045446c..263c3f46a 100644 --- a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_github-2.snap +++ b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_github-2.snap @@ -33,10 +33,16 @@ Global Options: This can be repeated up to 3 times to enable successively more output. + -q, --quiet + Suppress non-error feedback messages + + This silences WARNING, INFO, DEBUG, and TRACE messages and disables progress bars. This + overrides any provided verbosity and progress reporting options. + --color Enable or disable colored output - When this is "auto", colors are enabled when stdout is a tty. + When this is "auto", colors are enabled for stdout and stderr when they are terminals. If the `NO_COLOR` environment variable is set, it takes precedence and is equivalent to `--color=never`. @@ -47,7 +53,7 @@ Global Options: --progress Enable or disable progress bars - When this is "auto", progress bars are enabled when stderr is a tty. + When this is "auto", progress bars are enabled when stderr is a terminal. [default: auto] [possible values: auto, never, always] diff --git a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_github_repos-2.snap b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_github_repos-2.snap index 1c4c90958..5c0eb9025 100644 --- a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_github_repos-2.snap +++ b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_github_repos-2.snap @@ -20,10 +20,16 @@ Global Options: This can be repeated up to 3 times to enable successively more output. + -q, --quiet + Suppress non-error feedback messages + + This silences WARNING, INFO, DEBUG, and TRACE messages and disables progress bars. This + overrides any provided verbosity and progress reporting options. + --color Enable or disable colored output - When this is "auto", colors are enabled when stdout is a tty. + When this is "auto", colors are enabled for stdout and stderr when they are terminals. If the `NO_COLOR` environment variable is set, it takes precedence and is equivalent to `--color=never`. @@ -34,7 +40,7 @@ Global Options: --progress Enable or disable progress bars - When this is "auto", progress bars are enabled when stderr is a tty. + When this is "auto", progress bars are enabled when stderr is a terminal. [default: auto] [possible values: auto, never, always] diff --git a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_github_repos_short-2.snap b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_github_repos_short-2.snap index fda06e14d..fbbcc9340 100644 --- a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_github_repos_short-2.snap +++ b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_github_repos_short-2.snap @@ -1,5 +1,5 @@ --- -source: tests/test_noseyparker_help.rs +source: crates/noseyparker-cli/tests/help/mod.rs expression: stdout --- Interact with GitHub repositories @@ -15,6 +15,7 @@ Options: Global Options: -v, --verbose... Enable verbose output + -q, --quiet Suppress non-error feedback messages --color Enable or disable colored output [default: auto] [possible values: auto, never, always] --progress Enable or disable progress bars [default: auto] [possible values: auto, diff --git a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_github_short-2.snap b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_github_short-2.snap index b12373992..ec37fa678 100644 --- a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_github_short-2.snap +++ b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_github_short-2.snap @@ -17,6 +17,7 @@ Options: Global Options: -v, --verbose... Enable verbose output + -q, --quiet Suppress non-error feedback messages --color Enable or disable colored output [default: auto] [possible values: auto, never, always] --progress Enable or disable progress bars [default: auto] [possible values: auto, diff --git a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_report-2.snap b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_report-2.snap index e270db9cd..1ba96d875 100644 --- a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_report-2.snap +++ b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_report-2.snap @@ -46,10 +46,16 @@ Global Options: This can be repeated up to 3 times to enable successively more output. + -q, --quiet + Suppress non-error feedback messages + + This silences WARNING, INFO, DEBUG, and TRACE messages and disables progress bars. This + overrides any provided verbosity and progress reporting options. + --color Enable or disable colored output - When this is "auto", colors are enabled when stdout is a tty. + When this is "auto", colors are enabled for stdout and stderr when they are terminals. If the `NO_COLOR` environment variable is set, it takes precedence and is equivalent to `--color=never`. @@ -60,7 +66,7 @@ Global Options: --progress Enable or disable progress bars - When this is "auto", progress bars are enabled when stderr is a tty. + When this is "auto", progress bars are enabled when stderr is a terminal. [default: auto] [possible values: auto, never, always] diff --git a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_report_short-2.snap b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_report_short-2.snap index 9afe08b84..2b012598a 100644 --- a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_report_short-2.snap +++ b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_report_short-2.snap @@ -18,6 +18,7 @@ Output Options: Global Options: -v, --verbose... Enable verbose output + -q, --quiet Suppress non-error feedback messages --color Enable or disable colored output [default: auto] [possible values: auto, never, always] --progress Enable or disable progress bars [default: auto] [possible values: auto, diff --git a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_rules-2.snap b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_rules-2.snap index 2426d35a8..39bed5234 100644 --- a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_rules-2.snap +++ b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_rules-2.snap @@ -21,10 +21,16 @@ Global Options: This can be repeated up to 3 times to enable successively more output. + -q, --quiet + Suppress non-error feedback messages + + This silences WARNING, INFO, DEBUG, and TRACE messages and disables progress bars. This + overrides any provided verbosity and progress reporting options. + --color Enable or disable colored output - When this is "auto", colors are enabled when stdout is a tty. + When this is "auto", colors are enabled for stdout and stderr when they are terminals. If the `NO_COLOR` environment variable is set, it takes precedence and is equivalent to `--color=never`. @@ -35,7 +41,7 @@ Global Options: --progress Enable or disable progress bars - When this is "auto", progress bars are enabled when stderr is a tty. + When this is "auto", progress bars are enabled when stderr is a terminal. [default: auto] [possible values: auto, never, always] diff --git a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_scan-2.snap b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_scan-2.snap index 65ef181e2..62a9e4cd4 100644 --- a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_scan-2.snap +++ b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_scan-2.snap @@ -210,10 +210,16 @@ Global Options: This can be repeated up to 3 times to enable successively more output. + -q, --quiet + Suppress non-error feedback messages + + This silences WARNING, INFO, DEBUG, and TRACE messages and disables progress bars. This + overrides any provided verbosity and progress reporting options. + --color Enable or disable colored output - When this is "auto", colors are enabled when stdout is a tty. + When this is "auto", colors are enabled for stdout and stderr when they are terminals. If the `NO_COLOR` environment variable is set, it takes precedence and is equivalent to `--color=never`. @@ -224,7 +230,7 @@ Global Options: --progress Enable or disable progress bars - When this is "auto", progress bars are enabled when stderr is a tty. + When this is "auto", progress bars are enabled when stderr is a terminal. [default: auto] [possible values: auto, never, always] diff --git a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_scan_short-2.snap b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_scan_short-2.snap index 34c66172e..780f06e1f 100644 --- a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_scan_short-2.snap +++ b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_scan_short-2.snap @@ -50,6 +50,7 @@ Data Collection Options: Global Options: -v, --verbose... Enable verbose output + -q, --quiet Suppress non-error feedback messages --color Enable or disable colored output [default: auto] [possible values: auto, never, always] --progress Enable or disable progress bars [default: auto] [possible values: auto, diff --git a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_short-2.snap b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_short-2.snap index d317652a7..c1ad012df 100644 --- a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_short-2.snap +++ b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_short-2.snap @@ -1,5 +1,5 @@ --- -source: tests/test_noseyparker_help.rs +source: crates/noseyparker-cli/tests/help/mod.rs expression: stdout --- Nosey Parker is a command-line program that finds secrets and sensitive information in textual data @@ -23,6 +23,7 @@ Options: Global Options: -v, --verbose... Enable verbose output + -q, --quiet Suppress non-error feedback messages --color Enable or disable colored output [default: auto] [possible values: auto, never, always] --progress Enable or disable progress bars [default: auto] [possible values: auto, diff --git a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_summarize-2.snap b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_summarize-2.snap index 14c36cb92..9960bcb9e 100644 --- a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_summarize-2.snap +++ b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_summarize-2.snap @@ -38,10 +38,16 @@ Global Options: This can be repeated up to 3 times to enable successively more output. + -q, --quiet + Suppress non-error feedback messages + + This silences WARNING, INFO, DEBUG, and TRACE messages and disables progress bars. This + overrides any provided verbosity and progress reporting options. + --color Enable or disable colored output - When this is "auto", colors are enabled when stdout is a tty. + When this is "auto", colors are enabled for stdout and stderr when they are terminals. If the `NO_COLOR` environment variable is set, it takes precedence and is equivalent to `--color=never`. @@ -52,7 +58,7 @@ Global Options: --progress Enable or disable progress bars - When this is "auto", progress bars are enabled when stderr is a tty. + When this is "auto", progress bars are enabled when stderr is a terminal. [default: auto] [possible values: auto, never, always] diff --git a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_summarize_short-2.snap b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_summarize_short-2.snap index 8b1593012..3f26f9e6d 100644 --- a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_summarize_short-2.snap +++ b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__help_summarize_short-2.snap @@ -17,6 +17,7 @@ Output Options: Global Options: -v, --verbose... Enable verbose output + -q, --quiet Suppress non-error feedback messages --color Enable or disable colored output [default: auto] [possible values: auto, never, always] --progress Enable or disable progress bars [default: auto] [possible values: auto, diff --git a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__no_args-3.snap b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__no_args-3.snap index 8b05a6110..acc65992a 100644 --- a/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__no_args-3.snap +++ b/crates/noseyparker-cli/tests/help/snapshots/test_noseyparker__help__no_args-3.snap @@ -1,5 +1,5 @@ --- -source: tests/test_noseyparker_help.rs +source: crates/noseyparker-cli/tests/help/mod.rs expression: stderr --- Nosey Parker is a command-line program that finds secrets and sensitive information in textual data @@ -23,6 +23,7 @@ Options: Global Options: -v, --verbose... Enable verbose output + -q, --quiet Suppress non-error feedback messages --color Enable or disable colored output [default: auto] [possible values: auto, never, always] --progress Enable or disable progress bars [default: auto] [possible values: auto, diff --git a/crates/noseyparker-cli/tests/scan/basic/mod.rs b/crates/noseyparker-cli/tests/scan/basic/mod.rs index 3447c2670..5c699a9df 100644 --- a/crates/noseyparker-cli/tests/scan/basic/mod.rs +++ b/crates/noseyparker-cli/tests/scan/basic/mod.rs @@ -110,7 +110,7 @@ fn scan_unreadable_file() { assert!(std::fs::read_to_string(input.path()).is_err()); noseyparker_success!("scan", "-d", scan_env.dspath(), input.path()) - .stdout(is_match("ERROR.*: Failed to load blob from .*: Permission denied")) + .stderr(is_match("ERROR.*: Failed to load blob from .*: Permission denied")) .stdout(match_nothing_scanned()); } @@ -226,7 +226,6 @@ fn report_nonexistent_default_datastore() { ds.assert(predicates::path::missing()); } -#[test] /// Test that the `report` command's `--max-matches` can be given a negative value (which means "no /// limit" for the option) without requiring an equals sign for the value. That is, instead of /// _requiring_ that the option be written `--max-matches=-1`, it should work fine to write @@ -234,6 +233,7 @@ fn report_nonexistent_default_datastore() { /// /// N.B., Suppoorting that argument parsing requires passing the `allow_negative_numbers=true` in /// the correct spot in the `clap` code. +#[test] fn report_unlimited_matches() { let scan_env = ScanEnv::new(); let input = scan_env.input_file_with_secret("input.txt"); diff --git a/crates/noseyparker-cli/tests/scan/git_url/mod.rs b/crates/noseyparker-cli/tests/scan/git_url/mod.rs index af130bc42..f3b9afe5c 100644 --- a/crates/noseyparker-cli/tests/scan/git_url/mod.rs +++ b/crates/noseyparker-cli/tests/scan/git_url/mod.rs @@ -6,8 +6,8 @@ fn https_nonexistent() { let path = "https://example.com/nothere.git"; noseyparker_failure!("scan", "-d", scan_env.dspath(), "--git-url", path) - .stdout(is_match(r"(?m)^Cloning into bare repository .*$")) - .stdout(is_match(r"(?m)^fatal: repository .* not found$")) + .stderr(is_match(r"(?m)^Cloning into bare repository .*$")) + .stderr(is_match(r"(?m)^fatal: repository .* not found$")) .stderr(is_match(r"(?m)^Error: No inputs to scan$")); } @@ -21,7 +21,7 @@ fn git_binary_missing() { .env("PATH", "/dev/null") .assert() .failure() - .stdout(is_match(r"Failed to clone .*: git execution failed:")) + .stderr(is_match(r"Failed to clone .*: git execution failed:")) .stderr(is_match(r"(?m)^Error: No inputs to scan$")); }