Skip to content

Commit

Permalink
Fix: multiple verbose entries in nasl-cli (#1582)
Browse files Browse the repository at this point in the history
Verbose is set on the overall clap command although it should be set on
the subcommand itself. This leads to
```
debug_asserts.rs:86:13:
Command nasl-cli: Argument names must be unique, but 'verbose' is in use by more than one argument or group
```
when it is not build with --release.

This commit changes this behaviour by calling it on the newly build
subcommand rather than the given root command.
  • Loading branch information
nichtsfrei authored Mar 5, 2024
1 parent 90ecc3a commit ca7bb8b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 34 deletions.
28 changes: 13 additions & 15 deletions rust/nasl-cli/src/execute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,19 @@ pub fn run(root: &clap::ArgMatches) -> Option<Result<(), CliError>> {
))
}
pub fn extend_args(cmd: Command) -> Command {
crate::add_verbose(
cmd.subcommand(
Command::new("execute")
.about(
"Executes a nasl-script.
cmd.subcommand(crate::add_verbose(
Command::new("execute")
.about(
"Executes a nasl-script.
A script can either be a file to be executed or an ID.
When ID is used than a valid feed path must be given within the path parameter.",
)
.arg(
arg!(-p --path <FILE> "Path to the feed.")
.required(false)
.value_parser(value_parser!(PathBuf)),
)
.arg(Arg::new("script").required(true))
.arg(arg!(-t --target <HOST> "Target to scan").required(false)),
),
)
)
.arg(
arg!(-p --path <FILE> "Path to the feed.")
.required(false)
.value_parser(value_parser!(PathBuf)),
)
.arg(Arg::new("script").required(true))
.arg(arg!(-t --target <HOST> "Target to scan").required(false)),
))
}
2 changes: 1 addition & 1 deletion rust/nasl-cli/src/feed/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use storage::StorageError;
use crate::{get_path_from_openvas, notusupdate, read_openvas_config, CliError, CliErrorKind};

pub fn extend_args(cmd: Command) -> Command {
crate::add_verbose(
cmd.subcommand(
crate::add_verbose(
Command::new("feed")
.about("Handles feed related tasks")
.subcommand_required(true)
Expand Down
3 changes: 1 addition & 2 deletions rust/nasl-cli/src/scanconfig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ use std::collections::HashMap;
use std::io::BufRead;

pub fn extend_args(cmd: Command) -> Command {
crate::add_verbose(
cmd.subcommand(
cmd.subcommand( crate::add_verbose(
Command::new("scan-config")
.about("Transforms a scan-config xml to a scan json for openvasd.
When piping a scan json it is enriched with the scan-config xml and may the portlist otherwise it will print a scan json without target or credentials.")
Expand Down
30 changes: 14 additions & 16 deletions rust/nasl-cli/src/syntax/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,18 @@ pub fn run(root: &clap::ArgMatches) -> Option<Result<(), CliError>> {
}

pub fn extend_args(cmd: Command) -> Command {
add_verbose(
cmd.subcommand(
Command::new("syntax")
.about("Verifies syntax of NASL files in given dir or file.")
.arg(
Arg::new("path")
.required(true)
.value_parser(value_parser!(PathBuf)),
)
.arg(
arg!(-q --quiet "Prints only error output and no progress.")
.required(false)
.action(ArgAction::SetTrue),
),
),
)
cmd.subcommand(add_verbose(
Command::new("syntax")
.about("Verifies syntax of NASL files in given dir or file.")
.arg(
Arg::new("path")
.required(true)
.value_parser(value_parser!(PathBuf)),
)
.arg(
arg!(-q --quiet "Prints only error output and no progress.")
.required(false)
.action(ArgAction::SetTrue),
),
))
}

0 comments on commit ca7bb8b

Please sign in to comment.