Fixes #408
Adds a new optional source
field to the advisory metadata: a URL which identifies the source of the package, e.g. the registry where a vulnerable package is published. These map to the source
field of Cargo.lock.
The default is crates.io:
registry+https://github.com/rust-lang/crates.io-index
The db::Query
type now considers Package::source
, checking if it's a registry and if so, checking if the advisory's source
URL matches the source
of the package. This fixes #408: it ignores packages in Cargo.lock which don't come from a registry (e.g. git, local), and if they do come from a registry, makes sure it's the expected one.
It also enables filing advisories for 3rd party crate registries, which would mainly be useful if someone spun up an internal RustSec DB, or potentially in a future where there are noteworthy public 3rd party registries in use other than crates.io.
This commit also removes the previous db::scope::{Registry, Package}
originally added in 6f56bfc/0f0a777 for a few reasons:
- The new implementation "just works" without any additional configuration on the part of the user and accomplishes the same functionality. Convention over configuration!
- The legacy
db::scope
system, despite its complexity, was mostly dead code and not actually ever considered in the Query
(in fact clippy
just recently started failing due to that). The only functionality it actually provided was allowing a user to configure that they only want to consider packages in their Cargo.lock whose source is crates.io
- In addition to that, the
db::scope
system duplicated functionality already available in the SourceId
type, resulting in needless complexity