Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Rust dependencies #1623

Merged
merged 8 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
543 changes: 276 additions & 267 deletions sources/Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions sources/api/apiserver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ http = "0.2.1"
libc = "0.2"
log = "0.4"
models = { path = "../../models" }
nix = "0.20.0"
nix = "0.21"
num = "0.4"
percent-encoding = "2.1"
semver = "0.11"
semver = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
simplelog = "0.10"
Expand Down
10 changes: 10 additions & 0 deletions sources/api/apiserver/src/server/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use actix_web::{HttpResponseBuilder, ResponseError};
use datastore::{self, deserialization, serialization};
use nix::unistd::Gid;
use snafu::Snafu;
Expand Down Expand Up @@ -175,3 +176,12 @@ pub enum Error {
}

pub type Result<T> = std::result::Result<T, Error>;

impl From<Error> for actix_web::HttpResponse {
fn from(e: Error) -> Self {
// Include the error message in the response. The Bottlerocket API is only
// exposed locally, and only on the host filesystem and to authorized containers,
// so we're not worried about exposing error details.
HttpResponseBuilder::new(e.status_code()).body(format!("{}", e))
}
}
99 changes: 48 additions & 51 deletions sources/api/apiserver/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ mod error;
pub use error::Error;

use actix_web::{
error::ResponseError, web, App, FromRequest, HttpRequest, HttpResponse, HttpServer, Responder,
body::Body, error::ResponseError, web, App, BaseHttpResponse, FromRequest, HttpRequest,
HttpResponse, HttpServer, Responder,
};
use bottlerocket_release::BottlerocketRelease;
use datastore::{Committed, FilesystemDataStore, Key, Value};
Expand Down Expand Up @@ -75,9 +76,7 @@ where
// 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| {
HttpResponse::BadRequest().body(err.to_string()).into()
})
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.
Expand Down Expand Up @@ -444,64 +443,62 @@ fn transaction_name(query: &web::Query<HashMap<String, String>>) -> &str {
// Can also override `render_response` if we want to change headers, content type, etc.
impl ResponseError for error::Error {
/// Maps our error types to the HTTP error code they should return.
fn error_response(&self) -> HttpResponse {
fn error_response(&self) -> BaseHttpResponse<Body> {
use error::Error::*;
match self {
let status_code = match self {
// 400 Bad Request
MissingInput { .. } => HttpResponse::BadRequest(),
EmptyInput { .. } => HttpResponse::BadRequest(),
NewKey { .. } => HttpResponse::BadRequest(),
MissingInput { .. } => StatusCode::BAD_REQUEST,
EmptyInput { .. } => StatusCode::BAD_REQUEST,
NewKey { .. } => StatusCode::BAD_REQUEST,

// 404 Not Found
MissingData { .. } => HttpResponse::NotFound(),
ListKeys { .. } => HttpResponse::NotFound(),
UpdateDoesNotExist { .. } => HttpResponse::NotFound(),
NoStagedImage { .. } => HttpResponse::NotFound(),
UninitializedUpdateStatus { .. } => HttpResponse::NotFound(),
MissingData { .. } => StatusCode::NOT_FOUND,
ListKeys { .. } => StatusCode::NOT_FOUND,
UpdateDoesNotExist { .. } => StatusCode::NOT_FOUND,
NoStagedImage { .. } => StatusCode::NOT_FOUND,
UninitializedUpdateStatus { .. } => StatusCode::NOT_FOUND,

// 422 Unprocessable Entity
CommitWithNoPending => HttpResponse::UnprocessableEntity(),
CommitWithNoPending => StatusCode::UNPROCESSABLE_ENTITY,

// 423 Locked
UpdateShareLock { .. } => HttpResponse::build(StatusCode::LOCKED),
UpdateLockHeld { .. } => HttpResponse::build(StatusCode::LOCKED),
UpdateShareLock { .. } => StatusCode::LOCKED,
UpdateLockHeld { .. } => StatusCode::LOCKED,

// 409 Conflict
DisallowCommand { .. } => HttpResponse::Conflict(),
DisallowCommand { .. } => StatusCode::CONFLICT,

// 500 Internal Server Error
DataStoreLock => HttpResponse::InternalServerError(),
ResponseSerialization { .. } => HttpResponse::InternalServerError(),
BindSocket { .. } => HttpResponse::InternalServerError(),
ServerStart { .. } => HttpResponse::InternalServerError(),
ListedKeyNotPresent { .. } => HttpResponse::InternalServerError(),
DataStore { .. } => HttpResponse::InternalServerError(),
Deserialization { .. } => HttpResponse::InternalServerError(),
DataStoreSerialization { .. } => HttpResponse::InternalServerError(),
CommandSerialization { .. } => HttpResponse::InternalServerError(),
InvalidMetadata { .. } => HttpResponse::InternalServerError(),
ConfigApplierFork { .. } => HttpResponse::InternalServerError(),
ConfigApplierStart { .. } => HttpResponse::InternalServerError(),
ConfigApplierStdin {} => HttpResponse::InternalServerError(),
ConfigApplierWait { .. } => HttpResponse::InternalServerError(),
ConfigApplierWrite { .. } => HttpResponse::InternalServerError(),
SystemdNotify { .. } => HttpResponse::InternalServerError(),
SystemdNotifyStatus {} => HttpResponse::InternalServerError(),
SetPermissions { .. } => HttpResponse::InternalServerError(),
SetGroup { .. } => HttpResponse::InternalServerError(),
ReleaseData { .. } => HttpResponse::InternalServerError(),
Shutdown { .. } => HttpResponse::InternalServerError(),
Reboot { .. } => HttpResponse::InternalServerError(),
UpdateDispatcher { .. } => HttpResponse::InternalServerError(),
UpdateError { .. } => HttpResponse::InternalServerError(),
UpdateStatusParse { .. } => HttpResponse::InternalServerError(),
UpdateInfoParse { .. } => HttpResponse::InternalServerError(),
UpdateLockOpen { .. } => HttpResponse::InternalServerError(),
}
// Include the error message in the response, and for all error types. The Bottlerocket
// API is only exposed locally, and only on the host filesystem and to authorized
// containers, so we're not worried about exposing error details.
.body(self.to_string())
DataStoreLock => StatusCode::INTERNAL_SERVER_ERROR,
ResponseSerialization { .. } => StatusCode::INTERNAL_SERVER_ERROR,
BindSocket { .. } => StatusCode::INTERNAL_SERVER_ERROR,
ServerStart { .. } => StatusCode::INTERNAL_SERVER_ERROR,
ListedKeyNotPresent { .. } => StatusCode::INTERNAL_SERVER_ERROR,
DataStore { .. } => StatusCode::INTERNAL_SERVER_ERROR,
Deserialization { .. } => StatusCode::INTERNAL_SERVER_ERROR,
DataStoreSerialization { .. } => StatusCode::INTERNAL_SERVER_ERROR,
CommandSerialization { .. } => StatusCode::INTERNAL_SERVER_ERROR,
InvalidMetadata { .. } => StatusCode::INTERNAL_SERVER_ERROR,
ConfigApplierFork { .. } => StatusCode::INTERNAL_SERVER_ERROR,
ConfigApplierStart { .. } => StatusCode::INTERNAL_SERVER_ERROR,
ConfigApplierStdin {} => StatusCode::INTERNAL_SERVER_ERROR,
ConfigApplierWait { .. } => StatusCode::INTERNAL_SERVER_ERROR,
ConfigApplierWrite { .. } => StatusCode::INTERNAL_SERVER_ERROR,
SystemdNotify { .. } => StatusCode::INTERNAL_SERVER_ERROR,
SystemdNotifyStatus {} => StatusCode::INTERNAL_SERVER_ERROR,
SetPermissions { .. } => StatusCode::INTERNAL_SERVER_ERROR,
SetGroup { .. } => StatusCode::INTERNAL_SERVER_ERROR,
ReleaseData { .. } => StatusCode::INTERNAL_SERVER_ERROR,
Shutdown { .. } => StatusCode::INTERNAL_SERVER_ERROR,
Reboot { .. } => StatusCode::INTERNAL_SERVER_ERROR,
UpdateDispatcher { .. } => StatusCode::INTERNAL_SERVER_ERROR,
UpdateError { .. } => StatusCode::INTERNAL_SERVER_ERROR,
UpdateStatusParse { .. } => StatusCode::INTERNAL_SERVER_ERROR,
UpdateInfoParse { .. } => StatusCode::INTERNAL_SERVER_ERROR,
UpdateLockOpen { .. } => StatusCode::INTERNAL_SERVER_ERROR,
};

BaseHttpResponse::new(status_code)
}
}

Expand All @@ -520,7 +517,7 @@ macro_rules! impl_responder_for {
fn respond_to($self, _req: &HttpRequest) -> HttpResponse {
let body = match serde_json::to_string(&$serialize_expr) {
Ok(s) => s,
Err(e) => return Error::ResponseSerialization { source: e }.error_response(),
Err(e) => return Error::ResponseSerialization { source: e }.into(),
};
HttpResponse::Ok()
.content_type("application/json")
Expand Down
1 change: 0 additions & 1 deletion sources/api/ecs-settings-applier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ exclude = ["README.md"]
[dependencies]
serde = {version = "1.0", features = ["derive"]}
serde_json = "1"
models = { path = "../../models" }
schnauzer = { path = "../schnauzer" }
log = "0.4"
snafu = "0.6"
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,11 +13,11 @@ exclude = ["README.md"]
bottlerocket-release = { path = "../../../bottlerocket-release" }
log = "0.4"
lz4 = "1.23.1"
nix = "0.20.0"
nix = "0.21"
pentacle = "1.0.0"
rand = { version = "0.8", default-features = false, features = ["std", "std_rng"] }
regex = "1.1"
semver = "0.11"
semver = "1.0"
simplelog = "0.10"
snafu = "0.6"
tough = "0.11"
Expand Down
4 changes: 2 additions & 2 deletions sources/api/migration/migrator/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ pub(crate) enum Error {
#[snafu(display("Data store path '{}' contains invalid version: {}", path.display(), source))]
InvalidDataStoreVersion {
path: PathBuf,
source: semver::SemVerError,
source: semver::Error,
},

#[snafu(display("Migration '{}' contains invalid version: {}", path.display(), source))]
InvalidMigrationVersion {
path: PathBuf,
source: semver::SemVerError,
source: semver::Error,
},

#[snafu(display("Data store for new version {} already exists at {}", version, path.display()))]
Expand Down
2 changes: 1 addition & 1 deletion sources/api/storewolf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ datastore = { path = "../datastore" }
log = "0.4"
models = { path = "../../models" }
rand = { version = "0.8", default-features = false, features = ["std", "std_rng"] }
semver = "0.11"
semver = "1.0"
simplelog = "0.10"
snafu = "0.6"
toml = "0.5"
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 @@ -16,7 +16,7 @@ http = "0.2"
itertools = "0.10"
log = "0.4"
models = { path = "../../models" }
nix = "0.20.0"
nix = "0.21"
schnauzer = { path = "../schnauzer" }
serde_json = "1"
simplelog = "0.10"
Expand Down
4 changes: 2 additions & 2 deletions sources/api/thar-be-updates/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ fs2 = "0.4.3"
http = "0.2.1"
log = "0.4.8"
models = { path = "../../models" }
nix = "0.20.0"
nix = "0.21"
num-derive = "0.3.0"
num-traits = "0.2.12"
semver = { version = "0.11", features = [ "serde" ] }
semver = { version = "1.0", features = [ "serde" ] }
serde = { version = "1.0.111", features = [ "derive" ] }
serde_json = "1.0.53"
serde_plain = "0.3.0"
Expand Down
2 changes: 1 addition & 1 deletion sources/api/thar-be-updates/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pub enum Error {
#[snafu(display("Failed to parse version string '{}' into semver version", version))]
SemVer {
version: String,
source: semver::SemVerError,
source: semver::Error,
},

#[snafu(display("Invalid state transition from {:?} to {:?}", from, to))]
Expand Down
2 changes: 1 addition & 1 deletion sources/bottlerocket-release/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ exclude = ["README.md"]
[dependencies]
envy = "0.4"
log = "0.4"
semver = { version = "0.11", features = ["serde"] }
semver = { version = "1.0", features = ["serde"] }
serde = { version = "1.0", features = ["derive"] }
snafu = "0.6"

Expand Down
22 changes: 18 additions & 4 deletions sources/clarify.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
[clarify.actix-macros]
expression = "MIT OR Apache-2.0"
license-files = [
{ path = "LICENSE-APACHE", hash = 0x671c8ae7 },
{ path = "LICENSE-MIT", hash = 0xda536e85 },
{ path = "LICENSE-APACHE", hash = 0x31de3fcd },
{ path = "LICENSE-MIT", hash = 0xfeb1e4a7 },
]

[clarify.actix-codec]
expression = "MIT OR Apache-2.0"
license-files = [
{ path = "LICENSE-APACHE", hash = 0x31de3fcd },
{ path = "LICENSE-MIT", hash = 0xfeb1e4a7 },
]

[clarify.actix-http]
expression = "MIT OR Apache-2.0"
license-files = [
{ path = "LICENSE-APACHE", hash = 0x31de3fcd },
{ path = "LICENSE-MIT", hash = 0xfeb1e4a7 },
]

[clarify.backtrace-sys]
Expand Down Expand Up @@ -36,7 +50,7 @@ expression = "(MIT OR Apache-2.0) AND BSD-2-Clause-FreeBSD"
license-files = [
{ path = "LICENSE-APACHE", hash = 0x24b54f4b },
{ path = "LICENSE-MIT", hash = 0xbc436f08 },
{ path = "LICENSE-THIRD-PARTY", hash = 0xc6242648 },
{ path = "LICENSE-THIRD-PARTY", hash = 0x847bf39 },
]

[clarify.lz4-sys]
Expand Down Expand Up @@ -113,7 +127,7 @@ license-files = [
[clarify.tokio-macros]
expression = "MIT"
license-files = [
{ path = "LICENSE", hash = 0x288c17e1 },
{ path = "LICENSE", hash = 0x28d2b8db },
]

[clarify.vmw_backdoor]
Expand Down
1 change: 0 additions & 1 deletion sources/imdsclient/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ http = "0.2"
log = "0.4"
reqwest = { version = "0.11.1", default-features = false }
serde_json = "1"
simplelog = "0.10"
snafu = "0.6"
tokio = { version = "1", default-features = false, features = ["macros", "rt-multi-thread", "time"] }
url = "2.1.1"
Expand Down
2 changes: 1 addition & 1 deletion sources/models/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ bottlerocket-release = { path = "../bottlerocket-release" }
lazy_static = "1.2"
model-derive = { path = "model-derive" }
regex = "1.1"
semver = "0.11.0"
semver = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_plain = "0.3.0"
snafu = "0.6"
Expand Down
2 changes: 1 addition & 1 deletion sources/models/model-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ path = "src/lib.rs"
proc-macro = true

[dependencies]
darling = "0.12"
darling = "0.13"
proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "1.0", default-features = false, features = ["full", "parsing", "printing", "proc-macro", "visit-mut"] }
Expand Down
20 changes: 14 additions & 6 deletions sources/models/src/modeled_types/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ impl TryFrom<&str> for FriendlyVersion {
}

impl TryFrom<FriendlyVersion> for semver::Version {
type Error = semver::SemVerError;
type Error = semver::Error;

fn try_from(input: FriendlyVersion) -> Result<semver::Version, Self::Error> {
// If the string begins with a 'v', skip it before conversion
Expand All @@ -313,7 +313,7 @@ string_impls_for!(FriendlyVersion, "FriendlyVersion");
#[cfg(test)]
mod test_version {
use super::FriendlyVersion;
use semver::{SemVerError, Version};
use semver::Version;
use std::convert::TryFrom;
use std::convert::TryInto;

Expand All @@ -326,8 +326,6 @@ mod test_version {
"v1.0.1-alpha",
"1.0.2-alpha+1.0",
"v1.0.2-alpha+1.0",
"1.0.3-beta.1.01",
"v1.0.3-beta.1.01",
webern marked this conversation as resolved.
Show resolved Hide resolved
"1.1.0-rc.1.1",
"v1.1.0-rc.1.1",
"latest",
Expand All @@ -346,9 +344,19 @@ mod test_version {

#[test]
fn bad_version_string() {
for err in &["hi", "1.0", "1", "v", "v1", "v1.0", "vv1.1.0"] {
for err in &[
"hi",
"1.0",
"1",
"v",
"v1",
"v1.0",
"vv1.1.0",
"1.0.3-beta.1.01",
"v1.0.3-beta.1.01",
] {
FriendlyVersion::try_from(*err).unwrap_err();
let res: Result<Version, SemVerError> = Version::try_from(FriendlyVersion {
let res: Result<Version, semver::Error> = Version::try_from(FriendlyVersion {
inner: err.to_string(),
});
res.unwrap_err();
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.20.0"
nix = "0.21"
signpost = { path = "../updater/signpost" }
simplelog = "0.10"
snafu = "0.6"
Expand Down
2 changes: 1 addition & 1 deletion sources/updater/update_metadata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exclude = ["README.md"]
chrono = { version = "0.4.9", features = ["serde"] }
parse-datetime = { path = "../../parse-datetime" }
regex = "1.1"
semver = { version = "0.11.0", features = ["serde"] }
semver = { version = "1.0", features = ["serde"] }
serde = { version = "1.0.100", features = ["derive"] }
serde_json = "1.0.40"
serde_plain = "0.3.0"
Expand Down
Loading