Skip to main content

verify_reader

Function verify_reader 

Source
pub fn verify_reader(
    reader: ArchiveReader<'_>,
    config: &SecurityConfig,
    options: &VerificationOptions,
) -> Result<VerificationReport>
Expand description

Verifies an archive read from a reader, optionally checking payload integrity.

The reader counterpart of verify_archive_with_options; nothing is written and no filesystem path is needed.

§Errors

Same as verify_archive_with_options.

§Examples

use exarch_core::ArchiveReader;
use exarch_core::SecurityConfig;
use exarch_core::VerificationOptions;
use exarch_core::VerificationStatus;
use exarch_core::verify_reader;

let mut builder = tar::Builder::new(Vec::new());
let mut header = tar::Header::new_gnu();
header.set_size(2);
header.set_mode(0o644);
builder.append_data(&mut header, "a.txt", &b"hi"[..])?;
let bytes = builder.into_inner()?;

let reader = ArchiveReader::tar(std::io::Cursor::new(bytes), None);
let report = verify_reader(
    reader,
    &SecurityConfig::default(),
    &VerificationOptions::default(),
)?;
assert_eq!(report.status(), VerificationStatus::Pass);