Skip to content

Commit cc92548

Browse files
authored
bugfix(cli): forbid some empty values for options (#1013)
1 parent 6d6a421 commit cc92548

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

crates/zizmor/src/main.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use std::{
99
use annotate_snippets::{Level, Renderer};
1010
use anstream::{eprintln, println, stream::IsTerminal};
1111
use anyhow::{Context, Result, anyhow};
12-
use camino::{Utf8Path, Utf8PathBuf};
13-
use clap::{Args, CommandFactory, Parser, ValueEnum};
12+
use camino::Utf8Path;
13+
use clap::{Args, CommandFactory, Parser, ValueEnum, builder::NonEmptyStringValueParser};
1414
use clap_complete::Generator;
1515
use clap_verbosity_flag::InfoLevel;
1616
use config::Config;
@@ -69,7 +69,7 @@ struct App {
6969
offline: bool,
7070

7171
/// The GitHub API token to use.
72-
#[arg(long, env)]
72+
#[arg(long, env, value_parser = NonEmptyStringValueParser::new())]
7373
gh_token: Option<String>,
7474

7575
/// The GitHub Server Hostname. Defaults to github.com
@@ -101,8 +101,14 @@ struct App {
101101

102102
/// The configuration file to load. By default, any config will be
103103
/// discovered relative to $CWD.
104-
#[arg(short, long, env = "ZIZMOR_CONFIG", group = "conf")]
105-
config: Option<Utf8PathBuf>,
104+
#[arg(
105+
short,
106+
long,
107+
env = "ZIZMOR_CONFIG",
108+
group = "conf",
109+
value_parser = NonEmptyStringValueParser::new()
110+
)]
111+
config: Option<String>,
106112

107113
/// Disable all configuration loading.
108114
#[arg(long, group = "conf")]
@@ -123,7 +129,7 @@ struct App {
123129
/// The directory to use for HTTP caching. By default, a
124130
/// host-appropriate user-caching directory will be used.
125131
#[arg(long)]
126-
cache_dir: Option<Utf8PathBuf>,
132+
cache_dir: Option<String>,
127133

128134
/// Control which kinds of inputs are collected for auditing.
129135
///

crates/zizmor/src/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub(crate) struct AuditState<'a> {
2222
impl<'a> AuditState<'a> {
2323
pub(crate) fn new(app: &App, config: &'a Config) -> Self {
2424
let cache_dir = match &app.cache_dir {
25-
Some(cache_dir) => cache_dir.as_std_path().to_path_buf(),
25+
Some(cache_dir) => PathBuf::from(cache_dir),
2626
None => choose_app_strategy(AppStrategyArgs {
2727
top_level_domain: "io.github".into(),
2828
author: "woodruffw".into(),

0 commit comments

Comments
 (0)