pub struct Database { /* private fields */ }Expand description
The ruby-advisory-db database.
Implementations§
Source§impl Database
impl Database
Sourcepub fn open(path: &Path) -> Result<Self, DatabaseError>
pub fn open(path: &Path) -> Result<Self, DatabaseError>
Open an existing advisory database at the given path.
Sourcepub fn default_path() -> PathBuf
pub fn default_path() -> PathBuf
The default database path: ~/.local/share/ruby-advisory-db.
Can be overridden by GEM_AUDIT_DB environment variable.
Sourcepub fn download(path: &Path, _quiet: bool) -> Result<Self, DatabaseError>
pub fn download(path: &Path, _quiet: bool) -> Result<Self, DatabaseError>
Download the ruby-advisory-db to the given path.
Sourcepub fn update(&self) -> Result<bool, DatabaseError>
pub fn update(&self) -> Result<bool, DatabaseError>
Update the database by fetching from origin and fast-forwarding.
If the git fetch fails (e.g. due to ref-update issues in containerised environments), falls back to a fresh clone so the update always succeeds.
Sourcepub fn commit_id(&self) -> Option<String>
pub fn commit_id(&self) -> Option<String>
The last commit ID (HEAD) of the database repository.
Sourcepub fn last_updated_at(&self) -> Option<i64>
pub fn last_updated_at(&self) -> Option<i64>
The timestamp of the last commit.
Sourcepub fn advisories(&self) -> Vec<Advisory>
pub fn advisories(&self) -> Vec<Advisory>
Enumerate all advisories in the database.
Sourcepub fn advisories_for(&self, gem_name: &str) -> Vec<Advisory>
pub fn advisories_for(&self, gem_name: &str) -> Vec<Advisory>
Get advisories for a specific gem.
Sourcepub fn check_gem(
&self,
gem_name: &str,
version: &Version,
) -> (Vec<Advisory>, usize)
pub fn check_gem( &self, gem_name: &str, version: &Version, ) -> (Vec<Advisory>, usize)
Check a gem (name + version) against the database.
Returns all advisories that the gem version is vulnerable to, along with the count of advisory files that failed to load.
Sourcepub fn advisories_for_ruby(&self, engine: &str) -> Vec<Advisory>
pub fn advisories_for_ruby(&self, engine: &str) -> Vec<Advisory>
Get advisories for a specific Ruby engine (e.g., “ruby”, “jruby”).
Sourcepub fn check_ruby(
&self,
engine: &str,
version: &Version,
) -> (Vec<Advisory>, usize)
pub fn check_ruby( &self, engine: &str, version: &Version, ) -> (Vec<Advisory>, usize)
Check a Ruby engine+version against the database.
Returns all advisories that the Ruby version is vulnerable to, along with the count of advisory files that failed to load.
Sourcepub fn rubies_size(&self) -> usize
pub fn rubies_size(&self) -> usize
Total number of Ruby interpreter advisories in the database.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Database
impl RefUnwindSafe for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl UnsafeUnpin for Database
impl UnwindSafe for Database
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.