Skip to content

Commit

Permalink
fix: support new input validation (#1518)
Browse files Browse the repository at this point in the history
* fix: support new input validation
  • Loading branch information
ajewellamz authored Dec 18, 2024
1 parent ffc67be commit 12bbfbf
Show file tree
Hide file tree
Showing 24 changed files with 49 additions and 43 deletions.
1 change: 1 addition & 0 deletions DynamoDbEncryption/runtimes/rust/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ src/time.rs
src/types
src/types.rs
src/uuid.rs
src/validation.rs
target
19 changes: 10 additions & 9 deletions DynamoDbEncryption/runtimes/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "aws-db-esdk"
version = "0.1.1"
edition = "2021"
rust-version = "1.80.0"
rust-version = "1.81.0"
keywords = ["cryptography", "security", "dynamodb", "encryption", "client-side"]
license = "ISC AND (Apache-2.0 OR ISC)"
description = "aws-db-esdk is a library for implementing client side encryption with DynamoDB."
Expand All @@ -16,18 +16,19 @@ readme = "README.md"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
aws-config = "1.5.10"
aws-lc-rs = "1.11.1"
aws-lc-sys = "0.23.1"
aws-sdk-dynamodb = "1.54.0"
aws-sdk-kms = "1.50.0"
aws-config = "1.5.11"
aws-lc-rs = "1.12.0"
aws-lc-sys = "0.22.0"
aws-sdk-dynamodb = "1.56.0"
aws-sdk-kms = "1.52.0"
aws-smithy-runtime-api = {version = "1.7.3", features = ["client"] }
aws-smithy-types = "1.2.9"
chrono = "0.4.38"
aws-smithy-types = "1.2.10"
chrono = "0.4.39"
cpu-time = "1.0.0"
dafny-runtime = "0.1.1"
dashmap = "6.1.0"
pem = "3.0.4"
tokio = {version = "1.41.1", features = ["full"] }
tokio = {version = "1.42.0", features = ["full"] }
uuid = { version = "1.11.0", features = ["v4"] }

[[example]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
// 5. Create a new AWS SDK DynamoDb client using the TableEncryptionConfigs
let sdk_config = aws_config::load_defaults(aws_config::BehaviorVersion::latest()).await;
let dynamo_config = aws_sdk_dynamodb::config::Builder::from(&sdk_config)
.interceptor(DbEsdkInterceptor::new(table_configs))
.interceptor(DbEsdkInterceptor::new(table_configs)?)
.build();
let ddb = aws_sdk_dynamodb::Client::from_conf(dynamo_config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
// 5. Create a new AWS SDK DynamoDb client using the DynamoDb Config above
let sdk_config = aws_config::load_defaults(aws_config::BehaviorVersion::latest()).await;
let dynamo_config = aws_sdk_dynamodb::config::Builder::from(&sdk_config)
.interceptor(DbEsdkInterceptor::new(table_configs))
.interceptor(DbEsdkInterceptor::new(table_configs)?)
.build();
let ddb = aws_sdk_dynamodb::Client::from_conf(dynamo_config);

Expand Down Expand Up @@ -215,7 +215,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
.build()?;

let only_replica_dynamo_config = aws_sdk_dynamodb::config::Builder::from(&sdk_config)
.interceptor(DbEsdkInterceptor::new(only_replica_table_configs))
.interceptor(DbEsdkInterceptor::new(only_replica_table_configs)?)
.build();
let only_replica_ddb = aws_sdk_dynamodb::Client::from_conf(only_replica_dynamo_config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ pub async fn put_item_get_item(
// 7. Create a new AWS SDK DynamoDb client using the DynamoDb Encryption Interceptor above
let sdk_config = aws_config::load_defaults(aws_config::BehaviorVersion::latest()).await;
let dynamo_config = aws_sdk_dynamodb::config::Builder::from(&sdk_config)
.interceptor(DbEsdkInterceptor::new(table_configs))
.interceptor(DbEsdkInterceptor::new(table_configs)?)
.build();
let ddb = aws_sdk_dynamodb::Client::from_conf(dynamo_config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {

// 6. Create a new AWS SDK DynamoDb client using the DynamoDb Encryption Interceptor above
let dynamo_config = aws_sdk_dynamodb::config::Builder::from(&sdk_config)
.interceptor(DbEsdkInterceptor::new(table_configs))
.interceptor(DbEsdkInterceptor::new(table_configs)?)
.build();
let ddb = aws_sdk_dynamodb::Client::from_conf(dynamo_config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
// 5. Create a new AWS SDK DynamoDb client using the config above
let sdk_config = aws_config::load_defaults(aws_config::BehaviorVersion::latest()).await;
let dynamo_config = aws_sdk_dynamodb::config::Builder::from(&sdk_config)
.interceptor(DbEsdkInterceptor::new(table_configs))
.interceptor(DbEsdkInterceptor::new(table_configs)?)
.build();
let ddb = aws_sdk_dynamodb::Client::from_conf(dynamo_config);

Expand Down Expand Up @@ -182,7 +182,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
.build()?;

let dynamo_config_for_decrypt = aws_sdk_dynamodb::config::Builder::from(&sdk_config)
.interceptor(DbEsdkInterceptor::new(table_configs_for_decrypt))
.interceptor(DbEsdkInterceptor::new(table_configs_for_decrypt)?)
.build();
let ddb_for_decrypt = aws_sdk_dynamodb::Client::from_conf(dynamo_config_for_decrypt);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
// 7. Create a new AWS SDK DynamoDb client using the config above
let sdk_config = aws_config::load_defaults(aws_config::BehaviorVersion::latest()).await;
let dynamo_config = aws_sdk_dynamodb::config::Builder::from(&sdk_config)
.interceptor(DbEsdkInterceptor::new(table_configs))
.interceptor(DbEsdkInterceptor::new(table_configs)?)
.build();
let ddb = aws_sdk_dynamodb::Client::from_conf(dynamo_config);

Expand Down Expand Up @@ -217,7 +217,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
.build()?;

let only_aes_dynamo_config = aws_sdk_dynamodb::config::Builder::from(&sdk_config)
.interceptor(DbEsdkInterceptor::new(only_aes_table_configs))
.interceptor(DbEsdkInterceptor::new(only_aes_table_configs)?)
.build();
let only_aes_ddb = aws_sdk_dynamodb::Client::from_conf(only_aes_dynamo_config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
// 5. Create the DynamoDb Encryption Interceptor
let sdk_config = aws_config::load_defaults(aws_config::BehaviorVersion::latest()).await;
let dynamo_config = aws_sdk_dynamodb::config::Builder::from(&sdk_config)
.interceptor(DbEsdkInterceptor::new(table_configs))
.interceptor(DbEsdkInterceptor::new(table_configs)?)
.build();
let ddb = aws_sdk_dynamodb::Client::from_conf(dynamo_config);

Expand Down Expand Up @@ -218,7 +218,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
.build()?;

let only_replica_dynamo_config = aws_sdk_dynamodb::config::Builder::from(&sdk_config)
.interceptor(DbEsdkInterceptor::new(only_replica_table_configs))
.interceptor(DbEsdkInterceptor::new(only_replica_table_configs)?)
.build();
let only_replica_ddb = aws_sdk_dynamodb::Client::from_conf(only_replica_dynamo_config);

Expand Down Expand Up @@ -266,7 +266,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
.build()?;

let only_srk_dynamo_config = aws_sdk_dynamodb::config::Builder::from(&sdk_config)
.interceptor(DbEsdkInterceptor::new(only_srk_table_configs))
.interceptor(DbEsdkInterceptor::new(only_srk_table_configs)?)
.build();
let only_srk_ddb = aws_sdk_dynamodb::Client::from_conf(only_srk_dynamo_config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
// 5. Create a new AWS SDK DynamoDb client using the Config above
let sdk_config = aws_config::load_defaults(aws_config::BehaviorVersion::latest()).await;
let dynamo_config = aws_sdk_dynamodb::config::Builder::from(&sdk_config)
.interceptor(DbEsdkInterceptor::new(table_configs))
.interceptor(DbEsdkInterceptor::new(table_configs)?)
.build();
let ddb = aws_sdk_dynamodb::Client::from_conf(dynamo_config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
// 6. Create a new AWS SDK DynamoDb client using the config above
let sdk_config = aws_config::load_defaults(aws_config::BehaviorVersion::latest()).await;
let dynamo_config = aws_sdk_dynamodb::config::Builder::from(&sdk_config)
.interceptor(DbEsdkInterceptor::new(table_configs))
.interceptor(DbEsdkInterceptor::new(table_configs)?)
.build();
let ddb = aws_sdk_dynamodb::Client::from_conf(dynamo_config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub async fn multi_put_get() -> Result<(), crate::BoxError> {
// 5. Create a new AWS SDK DynamoDb client using the TableEncryptionConfigs
let sdk_config = aws_config::load_defaults(aws_config::BehaviorVersion::latest()).await;
let dynamo_config = aws_sdk_dynamodb::config::Builder::from(&sdk_config)
.interceptor(DbEsdkInterceptor::new(table_configs))
.interceptor(DbEsdkInterceptor::new(table_configs)?)
.build();
let ddb = aws_sdk_dynamodb::Client::from_conf(dynamo_config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ pub async fn put_and_query_with_beacon(branch_key_id: &str) -> Result<(), crate:
// 7. Create a new AWS SDK DynamoDb client using the TableEncryptionConfigs
let sdk_config = aws_config::load_defaults(aws_config::BehaviorVersion::latest()).await;
let dynamo_config = aws_sdk_dynamodb::config::Builder::from(&sdk_config)
.interceptor(DbEsdkInterceptor::new(table_configs))
.interceptor(DbEsdkInterceptor::new(table_configs)?)
.build();
let ddb = aws_sdk_dynamodb::Client::from_conf(dynamo_config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ pub async fn put_and_query_with_beacon(branch_key_id: &str) -> Result<(), crate:

// 10. Create a new AWS SDK DynamoDb client using the DynamoDb Config above
let dynamo_config = aws_sdk_dynamodb::config::Builder::from(&sdk_config)
.interceptor(DbEsdkInterceptor::new(encryption_config))
.interceptor(DbEsdkInterceptor::new(encryption_config)?)
.build();
let ddb = aws_sdk_dynamodb::Client::from_conf(dynamo_config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ pub async fn setup_beacon_config(
// 13. Create a new AWS SDK DynamoDb client using the config above
let sdk_config = aws_config::load_defaults(aws_config::BehaviorVersion::latest()).await;
let dynamo_config = aws_sdk_dynamodb::config::Builder::from(&sdk_config)
.interceptor(DbEsdkInterceptor::new(table_configs))
.interceptor(DbEsdkInterceptor::new(table_configs)?)
.build();

Ok(aws_sdk_dynamodb::Client::from_conf(dynamo_config))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ pub async fn put_and_query_with_beacon(branch_key_id: &str) -> Result<(), crate:

// 12. Create a new AWS SDK DynamoDb client using the DynamoDb Encryption Interceptor above
let dynamo_config = aws_sdk_dynamodb::config::Builder::from(&sdk_config)
.interceptor(DbEsdkInterceptor::new(encryption_config))
.interceptor(DbEsdkInterceptor::new(encryption_config)?)
.build();
let ddb = aws_sdk_dynamodb::Client::from_conf(dynamo_config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ pub async fn put_and_query_with_beacon(branch_key_id: &str) -> Result<(), crate:

// 13. Create a new AWS SDK DynamoDb client using the DynamoDb Encryption Interceptor above
let dynamo_config = aws_sdk_dynamodb::config::Builder::from(&sdk_config)
.interceptor(DbEsdkInterceptor::new(encryption_config))
.interceptor(DbEsdkInterceptor::new(encryption_config)?)
.build();
let ddb = aws_sdk_dynamodb::Client::from_conf(dynamo_config);

Expand Down
6 changes: 3 additions & 3 deletions DynamoDbEncryption/runtimes/rust/src/intercept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ pub struct DbEsdkInterceptor {
impl DbEsdkInterceptor {
pub fn new(
config: crate::types::dynamo_db_tables_encryption_config::DynamoDbTablesEncryptionConfig,
) -> Self {
let client = crate::client::Client::from_conf(config).unwrap(); // FIXME
DbEsdkInterceptor { client }
) -> Result<Self, crate::types::error::Error> {
let client = crate::client::Client::from_conf(config)?;
Ok(DbEsdkInterceptor { client })
}
}

Expand Down
1 change: 1 addition & 0 deletions DynamoDbEncryption/runtimes/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,4 @@ pub(crate) mod software_externs;
pub(crate) mod storm_tracker;
pub(crate) mod time;
pub(crate) mod uuid;
pub(crate) mod validation;
1 change: 1 addition & 0 deletions TestVectors/runtimes/rust/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ src/types.rs
src/uuid.rs
src/wrapped
src/wrapped.rs
src/validation.rs
target
19 changes: 10 additions & 9 deletions TestVectors/runtimes/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@
name = "aws-db-esdk-test-vectors"
version = "0.1.0"
edition = "2021"
rust-version = "1.80.0"
rust-version = "1.81.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
aws-config = "1.5.10"
aws-lc-rs = "1.11.1"
aws-lc-sys = "0.23.1"
aws-sdk-dynamodb = "1.54.0"
aws-sdk-kms = "1.50.0"
aws-config = "1.5.11"
aws-lc-rs = "1.12.0"
aws-lc-sys = "0.22.0"
aws-sdk-dynamodb = "1.56.0"
aws-sdk-kms = "1.52.0"
aws-smithy-runtime-api = {version = "1.7.3", features = ["client"] }
aws-smithy-types = "1.2.9"
chrono = "0.4.38"
aws-smithy-types = "1.2.10"
chrono = "0.4.39"
cpu-time = "1.0.0"
dafny_runtime = { path = "../../../submodules/MaterialProviders/smithy-dafny/TestModels/dafny-dependencies/dafny_runtime_rust"}
dashmap = "6.1.0"
pem = "3.0.4"
tokio = {version = "1.41.1", features = ["full"] }
tokio = {version = "1.42.0", features = ["full"] }
uuid = { version = "1.11.0", features = ["v4"] }
1 change: 1 addition & 0 deletions TestVectors/runtimes/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub mod error;
/// All operations that this crate can perform.
pub mod operation;
pub mod types;
pub mod validation;

#[cfg(feature = "wrapped-client")]
pub mod wrapped;
Expand Down
2 changes: 1 addition & 1 deletion submodules/MaterialProviders
2 changes: 1 addition & 1 deletion submodules/smithy-dafny

0 comments on commit 12bbfbf

Please sign in to comment.