pub struct OsvClient { /* private fields */ }Expand description
Batches dependency versions against OSV.dev and resolves matching
advisories, with its own semantic cache layered on top of
HttpCache’s transport (post_json/get_cached).
One instance is shared server-lifetime on ServerState in deps-lsp, so
every open document’s scan benefits from the same query/record cache.
Implementations§
Source§impl OsvClient
impl OsvClient
Sourcepub fn new(cache: Arc<HttpCache>) -> Self
pub fn new(cache: Arc<HttpCache>) -> Self
Creates a client that reuses cache’s HTTP transport (Client,
HTTPS enforcement, size cap, timeout) for both the batch POST and the
per-advisory GET.
Sourcepub async fn scan(
&self,
ecosystem: EcosystemId,
deps: &[ScanTarget],
timeout: Duration,
) -> VulnerabilityMap
pub async fn scan( &self, ecosystem: EcosystemId, deps: &[ScanTarget], timeout: Duration, ) -> VulnerabilityMap
Phase A: scans deps and returns the map consumed by the rendering
helpers.
timeout bounds the entire scan (all chunks and any truncation
recovery), not any single request — the underlying reqwest client
already caps each individual request at 30s. The deadline is checked
between chunks/recovery items, not mid-request, so already-completed
work is never discarded on timeout: only whatever had not yet started
degrades to SkipReason::QueryFailed/SkipReason::Truncated
(critique S5).
Never returns an error: every failure degrades to a
ScanOutcome::Skipped entry, never an absent one. Logs a
per-scan summary at info (§8 invariant 0).
Sourcepub async fn check_candidates(
&self,
ecosystem: EcosystemId,
candidates: &[ScanTarget],
timeout: Duration,
) -> LatestStatusMap
pub async fn check_candidates( &self, ecosystem: EcosystemId, candidates: &[ScanTarget], timeout: Duration, ) -> LatestStatusMap
Phase B: checks whether the versions about to be recommended (e.g. “latest” from the registry) are themselves affected.
Callers may build candidates from any subset of dependencies with a registry-cached
candidate to check — issue #1517 removed the earlier restriction to only dependencies
phase A already flagged ScanOutcome::Vulnerable, since a cleanly-pinned dependency’s
“latest” must be checked too (a phase-A-only gate silently let a malicious/vulnerable
“latest” through for every dependency that was clean at its pinned version). timeout
has the same meaning as in Self::scan.
Every candidates entry gets exactly one result back (never silently dropped): a
ScanOutcome::Skipped outcome, or a target this call never resolved a result for at
all, becomes UpgradeStatus::CandidateUnverified rather than an absent map entry — a
caller must fail closed on that, never treat “absent” as “safe” (issue #1517 AC4).