Skip to content

Commit

Permalink
s3 0.29.0 (#253)
Browse files Browse the repository at this point in the history
* cargo: Move `tokio-stream` create behind the `with-tokio` feature (#248)

`tokio-stream` has a dependency on `tokio` and is only used within the
`request` module, which depends on the `with-tokio` feature.  As such,
in order to completely prevent `tokio` from appearing in the crate
graph, this crate must be marked optional and enabled when `with-tokio`
is requested, omitted otherwise.

Also includes two drive-by typo-fixes in the features section of the
readme.

* Fixup #248

* Migrate from `chrono` to `time` to solve RUSTSEC-2020-0159 (#250)

`chrono` still hasn't found a solution to [RUSTSEC-2020-0159] whereas
`time` already solved its vulnerability to [RUSTSEC-2020-0071] by hiding
the affected functionality behind a cfg flag (not to be confused with a
`feature`, such `cfg`s can only be enabled through `RUSTFLAGS`).  At the
same time `chrono` is a superset of `time` even though this crate hardly
uses any functionality of it: only UTC time is needed which does not
suffer from aforementioned local time vulnerabilities.

[RUSTSEC-2020-0071]: https://rustsec.org/advisories/RUSTSEC-2020-0071
[RUSTSEC-2020-0159]: https://rustsec.org/advisories/RUSTSEC-2020-0159

Co-authored-by: Drazen Urch <drazen@urch.eu>

* Update Makefile

* Closes #245

* Bump aws-region

* s3 0.29.0

Co-authored-by: Marijn Suijten <marijns95@gmail.com>
  • Loading branch information
durch and MarijnS95 authored Feb 12, 2022
1 parent d54bbaa commit d1f231a
Show file tree
Hide file tree
Showing 14 changed files with 191 additions and 161 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ Cargo.lock
.idea/
test.file
.history
.envrc
minio
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
all: ci-all

ci: s3-ci region-ci creds-ci

ci-all: s3-all region-ci creds-ci
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ a `PUT` presigned URL, meaning they can upload to a specific key in S3 for the d

#### Features

There are a lot of various featuers that enable a wide variaty of use cases, refer to `s3/Cargo.toml` for an exhaustive list. Below is a table of various useful features as well as a short description for each.
There are a lot of various features that enable a wide variety of use cases, refer to `s3/Cargo.toml` for an exhaustive list. Below is a table of various useful features as well as a short description for each.

+ `default` - `tokio` runtime and a `native-tls` implementation
+ `blocking` - generates `*_blocking` variant of all `Bucket` methods, otherwise only `async` versions are available
Expand Down
2 changes: 1 addition & 1 deletion aws-creds/src/credentials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ impl Credentials {
access_key_id: String,
secret_access_key: String,
token: String,
//expiration: chrono::DateTime<chrono::Utc>, // TODO fix #163
//expiration: time::OffsetDateTime, // TODO fix #163
}

let resp: Response = match env::var("AWS_CONTAINER_CREDENTIALS_RELATIVE_URI") {
Expand Down
2 changes: 1 addition & 1 deletion aws-region/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aws-region"
version = "0.23.4"
version = "0.23.5"
authors = ["Drazen Urch"]
description = "Tiny Rust library for working with Amazon AWS regions, supports `s3` crate"
repository = "https://github.com/durch/rust-s3"
Expand Down
5 changes: 5 additions & 0 deletions aws-region/src/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ pub enum Region {
UsWest2,
/// ca-central-1
CaCentral1,
/// af-south-1
AfSouth1,
/// ap-east-1
ApEast1,
/// ap-south-1
Expand Down Expand Up @@ -100,6 +102,7 @@ impl fmt::Display for Region {
UsEast2 => write!(f, "us-east-2"),
UsWest1 => write!(f, "us-west-1"),
UsWest2 => write!(f, "us-west-2"),
AfSouth1 => write!(f, "af-south-1"),
CaCentral1 => write!(f, "ca-central-1"),
ApEast1 => write!(f, "ap-east-1"),
ApSouth1 => write!(f, "ap-south-1"),
Expand Down Expand Up @@ -142,6 +145,7 @@ impl FromStr for Region {
"us-west-1" => Ok(UsWest1),
"us-west-2" => Ok(UsWest2),
"ca-central-1" => Ok(CaCentral1),
"af-south-1" => Ok(AfSouth1),
"ap-east-1" => Ok(ApEast1),
"ap-south-1" => Ok(ApSouth1),
"ap-northeast-1" => Ok(ApNortheast1),
Expand Down Expand Up @@ -187,6 +191,7 @@ impl Region {
UsWest1 => String::from("s3-us-west-1.amazonaws.com"),
UsWest2 => String::from("s3-us-west-2.amazonaws.com"),
CaCentral1 => String::from("s3-ca-central-1.amazonaws.com"),
AfSouth1 => String::from("s3-af-south-1.amazonaws.com"),
ApEast1 => String::from("s3-ap-east-1.amazonaws.com"),
ApSouth1 => String::from("s3-ap-south-1.amazonaws.com"),
ApNortheast1 => String::from("s3-ap-northeast-1.amazonaws.com"),
Expand Down
8 changes: 4 additions & 4 deletions s3/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rust-s3"
version = "0.28.1"
version = "0.29.0"
authors = ["Drazen Urch"]
description = "Rust library for working with Amazon S3 and compatible object storage APIs"
repository = "https://github.com/durch/rust-s3"
Expand All @@ -26,7 +26,7 @@ aws-creds = { version = "0.27", default-features = false }
aws-region = "0.23"
base64 = "0.13"
cfg-if = "1"
chrono = "0.4"
time = { version = "0.3", features = ["formatting", "macros"] }
futures-io = { version = "0.3", optional = true }
futures-util = { version = "0.3", optional = true, features = ["io"] }
hex = "0.4"
Expand All @@ -44,14 +44,14 @@ sha2 = "0.9"
anyhow = "1"
surf = { version = "2", optional = true, default-features = false, features = ["h1-client-rustls"] }
tokio = { version = "1", features = ["io-util"], optional = true, default-features = false }
tokio-stream = "0.1"
tokio-stream = { version = "0.1", optional = true }
url = "2"
minidom = { version = "0.13", optional = true }

block_on_proc = { version = "0.2", optional = true }

[features]
with-tokio = ["reqwest", "tokio", "tokio/fs"]
with-tokio = ["reqwest", "tokio", "tokio/fs", "tokio-stream"]
with-async-std = ["async-std", "surf", "futures-io", "futures-util"]
sync = ["attohttpc", "maybe-async/is_sync"]
default = ["tags", "tokio-native-tls"]
Expand Down
8 changes: 4 additions & 4 deletions s3/src/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use attohttpc::header::HeaderName;

use super::bucket::Bucket;
use super::command::Command;
use chrono::{DateTime, Utc};
use time::OffsetDateTime;

use crate::command::HttpMethod;
use crate::request_trait::Request;
Expand All @@ -30,15 +30,15 @@ pub struct AttoRequest<'a> {
pub bucket: &'a Bucket,
pub path: &'a str,
pub command: Command<'a>,
pub datetime: DateTime<Utc>,
pub datetime: OffsetDateTime,
pub sync: bool,
}

impl<'a> Request for AttoRequest<'a> {
type Response = attohttpc::Response;
type HeaderMap = attohttpc::header::HeaderMap;

fn datetime(&self) -> DateTime<Utc> {
fn datetime(&self) -> OffsetDateTime {
self.datetime
}

Expand Down Expand Up @@ -133,7 +133,7 @@ impl<'a> AttoRequest<'a> {
bucket,
path,
command,
datetime: Utc::now(),
datetime: OffsetDateTime::now_utc(),
sync: false,
}
}
Expand Down
Loading

0 comments on commit d1f231a

Please sign in to comment.