pub enum Occurrence {
InRepo {
repo: RepoId,
package: String,
installed: Version,
patched: Vec<VersionReq>,
dependency_kind: DependencyKind,
dependency_path: Vec<String>,
active: Option<bool>,
source: DepSource,
},
Toolchain {
channel: String,
installed: Option<Version>,
patched: Vec<VersionReq>,
},
}Expand description
A single location/version where an advisory applies.
The advisory groups occurrences, but the verdict is per-occurrence: the
same crate at different versions across repos may differ (one patched, one
not). A toolchain advisory (rustsec::Collection::Rust) has no repo to pin,
so it is a distinct variant rather than a sentinel repo.
Serializes internally-tagged on kind ("in_repo" / "toolchain"), with
the variant’s fields inlined alongside.
Variants§
InRepo
Fields
patched: Vec<VersionReq>Versions that fix the advisory; empty means “no fix available”.
dependency_kind: DependencyKinddependency_path: Vec<String>A shortest chain of package names from a root crate down to this
package (["my-app", "jiff", "defmt", …]) — the answer to “who pulls
this in”. There may be other paths; this is one representative. Empty
when the dependency graph could not be computed. Additive field —
omitted from JSON when empty, so schema_version: 1 is unaffected.
Toolchain
Implementations§
Source§impl Occurrence
impl Occurrence
Sourcepub fn is_vulnerable(&self) -> bool
pub fn is_vulnerable(&self) -> bool
The per-occurrence verdict: is the installed version actually vulnerable? An occurrence is vulnerable when its installed version is covered by none of the advisory’s patched requirements. This is computed per occurrence precisely because the same advisory can apply to different versions across the fleet — one already patched, one not.
Fail-closed: an empty patched set (no fix published) or an unknown installed version counts as vulnerable.
use fleetreach_core::{DependencyKind, Occurrence, RepoId};
use fleetreach_core::semver::{Version, VersionReq};
let at = |major, minor, patch| Occurrence::InRepo {
repo: RepoId("app".into()),
package: "foo".into(),
installed: Version::new(major, minor, patch),
patched: vec![VersionReq::parse(">=1.2.0").unwrap()],
dependency_kind: DependencyKind::Transitive,
dependency_path: vec![],
active: None,
source: Default::default(),
};
assert!(at(1, 1, 9).is_vulnerable()); // below the fix
assert!(!at(1, 2, 0).is_vulnerable()); // at the fixTrait Implementations§
Source§impl Clone for Occurrence
impl Clone for Occurrence
Source§fn clone(&self) -> Occurrence
fn clone(&self) -> Occurrence
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Occurrence
impl Debug for Occurrence
Source§impl<'de> Deserialize<'de> for Occurrence
impl<'de> Deserialize<'de> for Occurrence
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for Occurrence
impl PartialEq for Occurrence
Source§fn eq(&self, other: &Occurrence) -> bool
fn eq(&self, other: &Occurrence) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for Occurrence
impl Serialize for Occurrence
impl StructuralPartialEq for Occurrence
Auto Trait Implementations§
impl Freeze for Occurrence
impl RefUnwindSafe for Occurrence
impl Send for Occurrence
impl Sync for Occurrence
impl Unpin for Occurrence
impl UnsafeUnpin for Occurrence
impl UnwindSafe for Occurrence
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more