pub struct AuditRun { /* private fields */ }Expand description
Configuration for an audit run.
§Example
use dev_security::{AuditRun, AuditScope};
use dev_report::Severity;
let run = AuditRun::new("my-crate", "0.1.0")
.scope(AuditScope::All)
.allow("RUSTSEC-2024-9999")
.severity_threshold(Severity::Warning);
let _result = run.execute().unwrap();Implementations§
Source§impl AuditRun
impl AuditRun
Sourcepub fn new(name: impl Into<String>, version: impl Into<String>) -> Self
pub fn new(name: impl Into<String>, version: impl Into<String>) -> Self
Begin a new audit run for the given subject name and version.
name and version are descriptive — they identify the subject
in the produced Report.
Sourcepub fn scope(self, scope: AuditScope) -> Self
pub fn scope(self, scope: AuditScope) -> Self
Pick which checks to run. Defaults to AuditScope::All.
Sourcepub fn audit_scope(&self) -> AuditScope
pub fn audit_scope(&self) -> AuditScope
Selected scope.
Sourcepub fn in_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn in_dir(self, dir: impl Into<PathBuf>) -> Self
Run the subprocesses from dir instead of the current directory.
Sourcepub fn deny_config(self, path: impl Into<PathBuf>) -> Self
pub fn deny_config(self, path: impl Into<PathBuf>) -> Self
Pass --config <path> to cargo deny so callers can point at a
non-default deny.toml location.
Sourcepub fn allow(self, id: impl Into<String>) -> Self
pub fn allow(self, id: impl Into<String>) -> Self
Suppress a single advisory ID. Matches advisories from
cargo-audit and rule names / advisory IDs from cargo-deny.
May be called repeatedly to add more entries.
Sourcepub fn severity_threshold(self, threshold: Severity) -> Self
pub fn severity_threshold(self, threshold: Severity) -> Self
Discard findings whose severity is below threshold. Findings
at or above the threshold are kept.
Order: Info < Warning < Error < Critical.
Sourcepub fn subject_version(&self) -> &str
pub fn subject_version(&self) -> &str
Subject version passed in via new.
Sourcepub fn execute(&self) -> Result<AuditResult, AuditError>
pub fn execute(&self) -> Result<AuditResult, AuditError>
Execute the audit.
Each enabled tool is invoked as a subprocess. Findings are
merged, deduplicated by (id, affected_crate), filtered through
the allow-list and severity threshold, then sorted by id for
determinism.