Skip to content

Commit 2fb0796

Browse files
committed
sources: update tough to 0.12
1 parent 6a01a19 commit 2fb0796

File tree

9 files changed

+87
-35
lines changed

9 files changed

+87
-35
lines changed

sources/Cargo.lock

Lines changed: 43 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sources/api/migration/migrator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ regex = "1.1"
2020
semver = "1.0"
2121
simplelog = "0.10"
2222
snafu = "0.6"
23-
tough = "0.11"
23+
tough = "0.12"
2424
update_metadata = { path = "../../../updater/update_metadata", version = "0.1.0" }
2525
url = "2.1.1"
2626

sources/api/migration/migrator/src/error.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ pub(crate) enum Error {
7070
#[snafu(display("Failed listing migration directory '{}': {}", dir.display(), source))]
7171
ListMigrations { dir: PathBuf, source: io::Error },
7272

73+
#[snafu(display("Invalid target name '{}': {}", target, source))]
74+
TargetName {
75+
target: String,
76+
source: tough::error::Error,
77+
},
78+
7379
#[snafu(display("Error loading migration '{}': {}", migration, source))]
7480
LoadMigration {
7581
migration: String,

sources/api/migration/migrator/src/main.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use semver::Version;
3232
use simplelog::{Config as LogConfig, SimpleLogger};
3333
use snafu::{ensure, OptionExt, ResultExt};
3434
use std::collections::HashSet;
35+
use std::convert::TryInto;
3536
use std::env;
3637
use std::fs::{self, File};
3738
use std::os::unix::fs::symlink;
@@ -243,14 +244,24 @@ where
243244

244245
for migration in migrations {
245246
let migration = migration.as_ref();
247+
let migration = migration
248+
.try_into()
249+
.context(error::TargetName { target: migration })?;
250+
246251
// get the migration from the repo
247252
let lz4_bytes = repository
248-
.read_target(migration)
249-
.context(error::LoadMigration { migration })?
250-
.context(error::MigrationNotFound { migration })?;
253+
.read_target(&migration)
254+
.context(error::LoadMigration {
255+
migration: migration.raw(),
256+
})?
257+
.context(error::MigrationNotFound {
258+
migration: migration.raw(),
259+
})?;
251260

252261
// Add an LZ4 decoder so the bytes will be deflated on read
253-
let mut reader = lz4::Decoder::new(lz4_bytes).context(error::Lz4Decode { migration })?;
262+
let mut reader = lz4::Decoder::new(lz4_bytes).context(error::Lz4Decode {
263+
migration: migration.raw(),
264+
})?;
254265

255266
// Create a sealed command with pentacle, so we can run the verified bytes from memory
256267
let mut command =
@@ -480,9 +491,10 @@ where
480491

481492
fn load_manifest(repository: &tough::Repository) -> Result<Manifest> {
482493
let target = "manifest.json";
494+
let target = target.try_into().context(error::TargetName { target })?;
483495
Manifest::from_json(
484496
repository
485-
.read_target(target)
497+
.read_target(&target)
486498
.context(error::ManifestLoad)?
487499
.context(error::ManifestNotFound)?,
488500
)

sources/api/migration/migrator/src/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ fn create_test_repo() -> TestRepo {
158158
let dir_entry = dir_entry_result.unwrap();
159159
editor
160160
.add_target(
161-
dir_entry.file_name().to_str().unwrap().into(),
161+
dir_entry.file_name().to_str().unwrap(),
162162
tough::schema::Target::from_path(dir_entry.path()).unwrap(),
163163
)
164164
.unwrap();

sources/deny.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ skip = [
5252
# older version used by hyper 0.14.2
5353
{ name = "socket2", version = "0.3.19" },
5454

55-
# older version used by tough 0.11.2
56-
{ name = "serde_plain", version = "0.3.0" },
55+
# older version used by webpki-roots 0.21.1
56+
{ name = "pem", version = "0.8.3" },
5757
]
5858

5959
skip-tree = [

sources/updater/updog/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ signpost = { path = "../signpost", version = "0.1.0" }
2323
simplelog = "0.10"
2424
snafu = "0.6.0"
2525
toml = "0.5.1"
26-
tough = { version = "0.11", features = ["http"] }
26+
tough = { version = "0.12", features = ["http"] }
2727
update_metadata = { path = "../update_metadata", version = "0.1.0" }
2828
structopt = "0.3"
2929
url = "2.1.0"

sources/updater/updog/src/error.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ pub(crate) enum Error {
6666
backtrace: Backtrace,
6767
},
6868

69+
#[snafu(display("Invalid target name '{}': {}", target, source))]
70+
TargetName {
71+
target: String,
72+
source: tough::error::Error,
73+
},
74+
6975
#[snafu(display("Manifest load error: {}", source))]
7076
ManifestLoad {
7177
source: tough::error::Error,

sources/updater/updog/src/main.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,18 @@ fn write_target_to_disk<P: AsRef<Path>>(
215215
target: &str,
216216
disk_path: P,
217217
) -> Result<()> {
218+
let target = target.try_into().context(error::TargetName { target })?;
218219
let reader = repository
219-
.read_target(target)
220+
.read_target(&target)
220221
.context(error::Metadata)?
221-
.context(error::TargetNotFound { target })?;
222+
.context(error::TargetNotFound {
223+
target: target.raw(),
224+
})?;
222225
// Note: the file extension for the compression type we're using should be removed in
223226
// retrieve_migrations below.
224-
let mut reader = lz4::Decoder::new(reader).context(error::Lz4Decode { target })?;
227+
let mut reader = lz4::Decoder::new(reader).context(error::Lz4Decode {
228+
target: target.raw(),
229+
})?;
225230
let mut f = OpenOptions::new()
226231
.write(true)
227232
.create(true)
@@ -584,9 +589,10 @@ fn main_inner() -> Result<()> {
584589

585590
fn load_manifest(repository: &tough::Repository) -> Result<Manifest> {
586591
let target = "manifest.json";
592+
let target = target.try_into().context(error::TargetName { target })?;
587593
Manifest::from_json(
588594
repository
589-
.read_target(target)
595+
.read_target(&target)
590596
.context(error::ManifestLoad)?
591597
.context(error::ManifestNotFound)?,
592598
)

0 commit comments

Comments
 (0)