Skip to content

Commit 420ba5c

Browse files
author
Alexander Weber
committed
+ shell trust utlimate enforcement for helper functions
1 parent b4d6082 commit 420ba5c

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/args/mod.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ pub struct CallArgs {
88
impl CallArgs {
99
#[allow(clippy::single_match)]
1010
pub async fn validate(&self) -> Result<(), Box<dyn std::error::Error>> {
11+
match &self.command {
12+
Command::Render(args) => {
13+
if args.helpers && args.shell_trust != ShellTrust::Ultimate {
14+
return Err(Box::new(crate::error::NoShellTrust::new(
15+
"need ultimate shell trust for helper functions",
16+
)));
17+
}
18+
}
19+
_ => {}
20+
}
21+
1122
match self.privileges {
1223
Privilege::Normal => match &self.command {
1324
Command::Render(args) => {
@@ -61,6 +72,7 @@ pub struct RenderArguments {
6172
pub backend: Backend,
6273
}
6374

75+
#[derive(Debug, Eq, PartialEq)]
6476
pub enum ShellTrust {
6577
None,
6678
Prompt,
@@ -89,7 +101,7 @@ impl ClapArgumentLoader {
89101
let command = clap::App::new("complate")
90102
.version(env!("CARGO_PKG_VERSION"))
91103
.about("A rusty text templating application for CLIs.")
92-
.author("Weber, Alexander <aw@voidpointergroup.com>")
104+
.author("replicadse <aw@voidpointergroup.com>")
93105
.arg(clap::Arg::with_name("experimental")
94106
.short("e")
95107
.long("experimental")

0 commit comments

Comments
 (0)