Skip to content

Commit

Permalink
Fix local registry (#668)
Browse files Browse the repository at this point in the history
Resolves: #667
  • Loading branch information
Jake-Shadle authored Jun 18, 2024
1 parent eaadf29 commit 8cbed34
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 61 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ strum = { version = "0.26", features = ["derive"] }
# Index retrieval and querying
tame-index = { version = "0.12", default-features = false, features = [
"git",
"local",
"sparse",
] }
# Timestamp emission
Expand Down
44 changes: 7 additions & 37 deletions examples/06_advisories/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions examples/06_advisories/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ dirs = "4.0"
# Failure has an unsound advisory (and is unmaintained)
failure = "=0.1.8"

# libusb is unmaintained
# https://github.com/RustSec/advisory-db/blob/5b35b71cf74eed58696aeeb5a764a9f0a66fe7ba/crates/libusb/RUSTSEC-2016-0004.toml
libusb = "0.3.0"
# const-cstr is unmaintained
# https://github.com/rustsec/advisory-db/blob/463e8405f85bb74eef17149f7e704b07723ce46e/crates/const-cstr/RUSTSEC-2023-0020.md
const-cstr = "0.3"

# The advisory applies to 0.10.0-alpha.1 >= && < 0.10.0-alpha.4
# https://github.com/RustSec/advisory-db/blob/c71cfec8c3fe313c9445a9ab0ae9b7faedda850a/crates/lettre/RUSTSEC-2020-0069.md
Expand Down
28 changes: 12 additions & 16 deletions src/advisories/helpers/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ impl<'k> Indices<'k> {
let cache = set
.into_par_iter()
.map(|(name, src)| {
let read_entry = || -> Result<YankMap, String> {
match indices
let read_entry = || -> Result<Entry, String> {
let res = match indices
.iter()
.find_map(|(url, index)| (src == *url).then_some(index))
.ok_or_else(|| "unable to locate index".to_owned())?
Expand All @@ -90,25 +90,21 @@ impl<'k> Indices<'k> {
) {
Ok(Some(ik)) => {
let yank_map = Self::load_index_krate(ik);
Ok(yank_map)
Entry::Map(yank_map)
}
Ok(None) => {
Err("unable to locate index entry for crate".to_owned())
}
Err(err) => Err(format!("{err:#}")),
Ok(None) => Entry::Error(
"unable to locate index entry for crate".to_owned(),
),
Err(err) => Entry::Error(format!("{err:#}")),
}
}
Err(err) => Err(format!("{err:#}")),
}
Err(err) => Entry::Error(format!("{err:#}")),
};

Ok(res)
};

(
(name, src),
match read_entry() {
Ok(ym) => Entry::Map(ym),
Err(err) => Entry::Error(err),
},
)
((name, src), read_entry().unwrap_or_else(Entry::Error))
})
.collect();

Expand Down
6 changes: 3 additions & 3 deletions src/bans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ impl TreeSkipper {
krate_id: krates::NodeId,
krates: &Krates,
) -> SkipRoot {
let (max_depth, reason) = ts.inner.map_or((std::usize::MAX, None), |inn| {
(inn.depth.unwrap_or(std::usize::MAX), inn.reason)
let (max_depth, reason) = ts.inner.map_or((usize::MAX, None), |inn| {
(inn.depth.unwrap_or(usize::MAX), inn.reason)
});

let mut skip_crates = Vec::with_capacity(10);
Expand Down Expand Up @@ -396,7 +396,7 @@ pub fn check(
LintLevel::Allow => return,
};

let mut all_start = std::usize::MAX;
let mut all_start = usize::MAX;
let mut all_end = 0;

struct Dupe {
Expand Down
1 change: 1 addition & 0 deletions src/cargo-deny/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub struct KrateContext {
pub offline: bool,
/// If true, allows using the crates.io git index, otherwise the sparse index
/// is assumed to be the only index
#[allow(dead_code)]
pub allow_git_index: bool,
pub exclude_dev: bool,
}
Expand Down
4 changes: 2 additions & 2 deletions tests/test_data/non-crates-io/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ version = "0.1.0"
edition = "2021"

[dependencies]
from-git = { package = "crate-one", registry = "embark-deny-git" }
from-sparse = { package = "crate-two", registry = "embark-deny-sparse" }
from-git = { version = "*", package = "crate-one", registry = "embark-deny-git" }
from-sparse = { version = "*", package = "crate-two", registry = "embark-deny-sparse" }

0 comments on commit 8cbed34

Please sign in to comment.