pub struct CveDatabase { /* private fields */ }Expand description
CVE database for querying known vulnerabilities
Implementations§
Source§impl CveDatabase
impl CveDatabase
Sourcepub fn builtin() -> Result<Self, CveDbError>
pub fn builtin() -> Result<Self, CveDbError>
Load the built-in CVE database
Sourcepub fn from_file(path: &Path) -> Result<Self, CveDbError>
pub fn from_file(path: &Path) -> Result<Self, CveDbError>
Load CVE database from a JSON file
Sourcepub fn from_json(json: &str) -> Result<Self, CveDbError>
pub fn from_json(json: &str) -> Result<Self, CveDbError>
Load CVE database from a JSON string
Sourcepub fn updated_at(&self) -> &str
pub fn updated_at(&self) -> &str
Get last update timestamp
Sourcepub fn check_product(
&self,
vendor: &str,
product: &str,
version: &str,
) -> Vec<&CveEntry>
pub fn check_product( &self, vendor: &str, product: &str, version: &str, ) -> Vec<&CveEntry>
Check if a product/version combination is affected by any CVE Returns matching CVE entries
Sourcepub fn check_product_by_name(
&self,
product: &str,
version: &str,
) -> Vec<&CveEntry>
pub fn check_product_by_name( &self, product: &str, version: &str, ) -> Vec<&CveEntry>
Check a product/version against all CVEs, ignoring vendor.
An npm package name uniquely identifies a product, but the same package
can be recorded under different vendor strings across databases (the
shipped DB uses modelcontextprotocol; a custom DB may use anthropic
or geelen). Matching on product name avoids brittle vendor coupling
that silently produced zero findings (issue #149).
Sourcepub fn create_findings(
&self,
vendor: &str,
product: &str,
version: &str,
file_path: &str,
line: usize,
) -> Vec<Finding>
pub fn create_findings( &self, vendor: &str, product: &str, version: &str, file_path: &str, line: usize, ) -> Vec<Finding>
Create findings for matching CVEs (vendor + product).
Sourcepub fn create_findings_by_product(
&self,
product: &str,
version: &str,
file_path: &str,
line: usize,
) -> Vec<Finding>
pub fn create_findings_by_product( &self, product: &str, version: &str, file_path: &str, line: usize, ) -> Vec<Finding>
Create findings for matching CVEs by product name, ignoring vendor.
Preferred for npm packages, where the package name is the reliable key and the recorded vendor string varies between databases (issue #149).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CveDatabase
impl RefUnwindSafe for CveDatabase
impl Send for CveDatabase
impl Sync for CveDatabase
impl Unpin for CveDatabase
impl UnsafeUnpin for CveDatabase
impl UnwindSafe for CveDatabase
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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