/// Extracts the kernel commandline from the provided zbi_path and compares
/// it against the golden file.
Extracts the kernel commandline from the provided zbi_path and compares
it against the golden file.
Extracts the kernel commandline from the provided zbi_path and compares it against the golden file .
pub fn verify(&self) -> Result<()> {
        let config = Config::run_command_with_runtime(
            CommandBuilder::new("tool.zbi.extract.cmdline")
                .param("input", self.zbi_path.clone())
                .build(),
            RuntimeConfig {
                logging: LoggingConfig { silent_mode: true, ..LoggingConfig::minimal() },
                plugin: PluginConfig { plugins: vec!["ToolkitPlugin".to_string()] },
                ..RuntimeConfig::minimal()
            },
        );
        let scrutiny_output =
            launcher::launch_from_config(config).context("Failed to launch scrutiny")?;
        let kernel_cmdline: String = serde_json::from_str(&scrutiny_output)
            .context(format!("Failed to deserialize scrutiny output: {}", scrutiny_output))?;
        let mut sorted_cmdline =
            kernel_cmdline.split(' ').map(ToString::to_string).collect::<Vec<String>>();
        sorted_cmdline.sort();
        let golden_file =
            GoldenFile::open(self.golden_path.clone()).context("Failed to open golden file")?;
        match golden_file.compare(sorted_cmdline) {
            CompareResult::Matches => Ok(()),
            CompareResult::Mismatch { errors } => {
                println!("Kernel cmdline mismatch");
                println!("");
                for error in errors.iter() {
                    println!("{}", error);
                }
                println!("");
                println!("If you intended to change the kernel command line, please acknowledge it by updating {} with the added or removed lines.", self.golden_path);
                println!("{}", SOFT_TRANSITION_MSG);
                Err(anyhow!("kernel cmdline mismatch"))
            }
        }
    }
pub fn verify ( & self ) -> Result < ( ) > { let config = Config :: run_command_with_runtime ( CommandBuilder :: new ( " " ) . param ( " " , self . zbi_path . clone ( ) ) . build ( ) , RuntimeConfig { logging : LoggingConfig { silent_mode : true , .. LoggingConfig :: minimal ( ) } , plugin : PluginConfig { plugins : vec ! [ " " to_string ( ) ] } , .. RuntimeConfig :: minimal ( ) } , ) ; let scrutiny_output = launcher :: launch_from_config ( config ) . context ( " " ) ? ; let kernel_cmdline : String = serde_json :: from_str ( & scrutiny_output ) . context ( format ! ( " " scrutiny_output ) ) ? ; let mut sorted_cmdline = kernel_cmdline . split ( ' ' ) . map ( ToString :: to_string ) . collect :: < Vec < String > > ( ) ; sorted_cmdline . sort ( ) ; let golden_file = GoldenFile :: open ( self . golden_path . clone ( ) ) . context ( " " ) ? ; match golden_file . compare ( sorted_cmdline ) { CompareResult :: Matches => Ok ( ( ) ) , CompareResult :: Mismatch { errors } => { println ! ( " " ) ; println ! ( " " ) ; for error in errors . iter ( ) { println ! ( " " error ) ; } println ! ( " " ) ; println ! ( " " self golden_path ) ; println ! ( " " SOFT_TRANSITION_MSG ) ; Err ( anyhow ! ( " " ) ) } } }
Extracts the kernel commandline from the provided zbi_path and compares
it against the golden file.
Extracts the kernel commandline from the provided zbi_path and compares it against the golden file .
&self