Skip to content

Commit

Permalink
Merge pull request #1810 from cbgbt/rust-deps
Browse files Browse the repository at this point in the history
Update Rust dependencies
  • Loading branch information
cbgbt authored Nov 10, 2021
2 parents 8d9d34c + 24bf573 commit 95260b7
Show file tree
Hide file tree
Showing 20 changed files with 410 additions and 480 deletions.
525 changes: 205 additions & 320 deletions sources/Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion sources/api/apiclient/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ hyper-unix-connector = "0.2"
libc = "0.2"
log = "0.4"
models = { path = "../../models", version = "0.1.0" }
nix = "0.22"
nix = "0.23"
rand = "0.8"
reqwest = { version = "0.11.1", default-features = false, features = ["rustls-tls"] }
retry-read = { path = "../../retry-read", version = "0.1.0" }
Expand Down
2 changes: 1 addition & 1 deletion sources/api/apiserver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ http = "0.2.1"
libc = "0.2"
log = "0.4"
models = { path = "../../models", version = "0.1.0" }
nix = "0.22"
nix = "0.23"
num = "0.4"
percent-encoding = "2.1"
rand = "0.8"
Expand Down
13 changes: 2 additions & 11 deletions sources/api/apiserver/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ mod exec;
pub use error::Error;

use actix_web::{
body::Body, error::ResponseError, web, App, FromRequest, HttpRequest, HttpResponse, HttpServer,
Responder,
body::Body, error::ResponseError, web, App, HttpRequest, HttpResponse, HttpServer, Responder,
};
use bottlerocket_release::BottlerocketRelease;
use datastore::{Committed, FilesystemDataStore, Key, Value};
Expand Down Expand Up @@ -78,14 +77,6 @@ where

let http_server = HttpServer::new(move || {
App::new()
// In our implementation of ResponseError on our own error type below, we include the
// error message in the response for debugging purposes. If actix rejects a request
// early because it doesn't fit our model, though, it doesn't even get to the
// ResponseError implementation. This configuration of the Json extractor allows us to
// add the error message into the response.
.app_data(web::Json::<Settings>::configure(|cfg| {
cfg.error_handler(|err, _req| actix_web::Error::from(err))
}))
// This makes the data store available to API methods merely by having a Data
// parameter.
.app_data(shared_data.clone())
Expand Down Expand Up @@ -507,7 +498,7 @@ impl ResponseError for error::Error {
UpdateLockOpen { .. } => StatusCode::INTERNAL_SERVER_ERROR,
};

HttpResponse::new(status_code)
HttpResponse::build(status_code).body(self.to_string())
}
}

Expand Down
4 changes: 2 additions & 2 deletions sources/api/migration/migrator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ exclude = ["README.md"]
bottlerocket-release = { path = "../../../bottlerocket-release", version = "0.1.0" }
log = "0.4"
lz4 = "1.23.1"
nix = "0.22"
nix = "0.23"
pentacle = "1.0.0"
rand = { version = "0.8", default-features = false, features = ["std", "std_rng"] }
regex = "1.1"
semver = "1.0"
simplelog = "0.10"
snafu = "0.6"
tough = "0.11"
tough = "0.12"
update_metadata = { path = "../../../updater/update_metadata", version = "0.1.0" }
url = "2.1.1"

Expand Down
6 changes: 6 additions & 0 deletions sources/api/migration/migrator/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ pub(crate) enum Error {
#[snafu(display("Failed listing migration directory '{}': {}", dir.display(), source))]
ListMigrations { dir: PathBuf, source: io::Error },

#[snafu(display("Invalid target name '{}': {}", target, source))]
TargetName {
target: String,
source: tough::error::Error,
},

#[snafu(display("Error loading migration '{}': {}", migration, source))]
LoadMigration {
migration: String,
Expand Down
22 changes: 17 additions & 5 deletions sources/api/migration/migrator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use semver::Version;
use simplelog::{Config as LogConfig, SimpleLogger};
use snafu::{ensure, OptionExt, ResultExt};
use std::collections::HashSet;
use std::convert::TryInto;
use std::env;
use std::fs::{self, File};
use std::os::unix::fs::symlink;
Expand Down Expand Up @@ -243,14 +244,24 @@ where

for migration in migrations {
let migration = migration.as_ref();
let migration = migration
.try_into()
.context(error::TargetName { target: migration })?;

// get the migration from the repo
let lz4_bytes = repository
.read_target(migration)
.context(error::LoadMigration { migration })?
.context(error::MigrationNotFound { migration })?;
.read_target(&migration)
.context(error::LoadMigration {
migration: migration.raw(),
})?
.context(error::MigrationNotFound {
migration: migration.raw(),
})?;

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

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

fn load_manifest(repository: &tough::Repository) -> Result<Manifest> {
let target = "manifest.json";
let target = target.try_into().context(error::TargetName { target })?;
Manifest::from_json(
repository
.read_target(target)
.read_target(&target)
.context(error::ManifestLoad)?
.context(error::ManifestNotFound)?,
)
Expand Down
2 changes: 1 addition & 1 deletion sources/api/migration/migrator/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ fn create_test_repo() -> TestRepo {
let dir_entry = dir_entry_result.unwrap();
editor
.add_target(
dir_entry.file_name().to_str().unwrap().into(),
dir_entry.file_name().to_str().unwrap(),
tough::schema::Target::from_path(dir_entry.path()).unwrap(),
)
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion sources/api/thar-be-settings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ http = "0.2"
itertools = "0.10"
log = "0.4"
models = { path = "../../models", version = "0.1.0" }
nix = "0.22"
nix = "0.23"
schnauzer = { path = "../schnauzer", version = "0.1.0" }
serde_json = "1"
simplelog = "0.10"
Expand Down
2 changes: 1 addition & 1 deletion sources/api/thar-be-updates/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fs2 = "0.4.3"
http = "0.2.1"
log = "0.4.8"
models = { path = "../../models", version = "0.1.0" }
nix = "0.22"
nix = "0.23"
num-derive = "0.3.0"
num-traits = "0.2.12"
semver = { version = "1.0", features = [ "serde" ] }
Expand Down
7 changes: 5 additions & 2 deletions sources/deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ skip = [
# older version used by hyper 0.14.2
{ name = "socket2", version = "0.3.19" },

# older version used by tough 0.11.2
{ name = "serde_plain", version = "0.3.0" },
# older version used by webpki-roots 0.21.1
{ name = "pem", version = "0.8.3" },

# older version used by chrono 0.4.19
{ name = "time", version = "0.1.43" },
]

skip-tree = [
Expand Down
2 changes: 1 addition & 1 deletion sources/prairiedog/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ exclude = ["README.md"]
[dependencies]
argh = "0.1.3"
log = "0.4"
nix = "0.22"
nix = "0.23"
signpost = { path = "../updater/signpost", version = "0.1.0" }
simplelog = "0.10"
snafu = "0.6"
Expand Down
2 changes: 1 addition & 1 deletion sources/updater/updog/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ signpost = { path = "../signpost", version = "0.1.0" }
simplelog = "0.10"
snafu = "0.6.0"
toml = "0.5.1"
tough = { version = "0.11", features = ["http"] }
tough = { version = "0.12", features = ["http"] }
update_metadata = { path = "../update_metadata", version = "0.1.0" }
structopt = "0.3"
url = "2.1.0"
Expand Down
6 changes: 6 additions & 0 deletions sources/updater/updog/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ pub(crate) enum Error {
backtrace: Backtrace,
},

#[snafu(display("Invalid target name '{}': {}", target, source))]
TargetName {
target: String,
source: tough::error::Error,
},

#[snafu(display("Manifest load error: {}", source))]
ManifestLoad {
source: tough::error::Error,
Expand Down
14 changes: 10 additions & 4 deletions sources/updater/updog/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,18 @@ fn write_target_to_disk<P: AsRef<Path>>(
target: &str,
disk_path: P,
) -> Result<()> {
let target = target.try_into().context(error::TargetName { target })?;
let reader = repository
.read_target(target)
.read_target(&target)
.context(error::Metadata)?
.context(error::TargetNotFound { target })?;
.context(error::TargetNotFound {
target: target.raw(),
})?;
// Note: the file extension for the compression type we're using should be removed in
// retrieve_migrations below.
let mut reader = lz4::Decoder::new(reader).context(error::Lz4Decode { target })?;
let mut reader = lz4::Decoder::new(reader).context(error::Lz4Decode {
target: target.raw(),
})?;
let mut f = OpenOptions::new()
.write(true)
.create(true)
Expand Down Expand Up @@ -584,9 +589,10 @@ fn main_inner() -> Result<()> {

fn load_manifest(repository: &tough::Repository) -> Result<Manifest> {
let target = "manifest.json";
let target = target.try_into().context(error::TargetName { target })?;
Manifest::from_json(
repository
.read_target(target)
.read_target(&target)
.context(error::ManifestLoad)?
.context(error::ManifestNotFound)?,
)
Expand Down
Loading

0 comments on commit 95260b7

Please sign in to comment.