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§

source

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.

source

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.

source

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

source

fn run(&self) -> ResultWithLibError<()>

Run the sanitized command with no additional checks

Object Safety§

This trait is not object safe.

Implementors§