pub trait ShellCommandLimitedDoubleQuotesSanitizerTrait {
// Required methods
fn new(template: &str) -> ResultWithLibError<Self>
where Self: Sized;
fn arg(
&mut self,
placeholder: &str,
value: &str
) -> ResultWithLibError<&mut Self>;
fn arg_secret(
&mut self,
placeholder: &str,
value: &SecretString
) -> ResultWithLibError<&mut Self>;
fn run(&self) -> ResultWithLibError<()>;
}
Expand description
Trait with methods for ShellCommandLimitedDoubleQuotesSanitizer
Required Methods§
fn new(template: &str) -> ResultWithLibError<Self>
where Self: Sized,
Template for the shell command with placeholders
The limited sanitization will panic if the value contains double quotes. Placeholders are delimited with curly brackets. The developer must be super careful to write the template correctly. The placeholders must be inside a block delimited with double quotes. In a way that only an injection of a double quote can cause problems. There is no software check of the correctness of the template.
fn arg( &mut self, placeholder: &str, value: &str ) -> ResultWithLibError<&mut Self>
Replace placeholders with the value
The limited sanitization will panic if the value contains double quotes. Enter the placeholder parameter delimited with curly brackets. It would be very complicated to check if “escaped double quotes” are or not correct in the context of the template. So I don’t allow them at all. This covers the vast majority of simple use cases.
fn arg_secret( &mut self, placeholder: &str, value: &SecretString ) -> ResultWithLibError<&mut Self>
Just like arg(), but for secrets that must be not echoed on the screen
fn run(&self) -> ResultWithLibError<()>
Run the sanitized command with no additional checks