From 9b1d32ebdf13e71ae01a7356eca8f522562bc9ec Mon Sep 17 00:00:00 2001 From: mbecker20 Date: Mon, 3 Jun 2024 00:44:45 -0700 Subject: [PATCH] base64 encode aws user data before send --- Cargo.lock | 1 + Cargo.toml | 7 ++++--- bin/core/Cargo.toml | 1 + bin/core/src/cloud/aws.rs | 6 +++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0a6e10865..b69ddab72 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2200,6 +2200,7 @@ dependencies = [ "aws-sdk-ec2", "axum 0.7.5", "axum-extra", + "base64 0.22.1", "bcrypt", "derive_variants", "dotenv", diff --git a/Cargo.toml b/Cargo.toml index 3df7b5a57..cf1a3a8dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,11 +76,12 @@ envy = "0.4.2" # CRYPTO uuid = { version = "1.8.0", features = ["v4", "fast-rng", "serde"] } urlencoding = "2.1.3" -rand = "0.8.5" -jwt = "0.16.0" +bcrypt = "0.15.1" +base64 = "0.22.1" hmac = "0.12.1" sha2 = "0.10.8" -bcrypt = "0.15.1" +rand = "0.8.5" +jwt = "0.16.0" hex = "0.4.3" # SYSTEM diff --git a/bin/core/Cargo.toml b/bin/core/Cargo.toml index 38317060c..9f11b39a0 100644 --- a/bin/core/Cargo.toml +++ b/bin/core/Cargo.toml @@ -46,6 +46,7 @@ futures.workspace = true anyhow.workspace = true dotenv.workspace = true bcrypt.workspace = true +base64.workspace = true tokio.workspace = true tower.workspace = true serde.workspace = true diff --git a/bin/core/src/cloud/aws.rs b/bin/core/src/cloud/aws.rs index 43109bbfa..f7abf5a00 100644 --- a/bin/core/src/cloud/aws.rs +++ b/bin/core/src/cloud/aws.rs @@ -12,6 +12,7 @@ use aws_sdk_ec2::{ }, Client, }; +use base64::Engine; use monitor_client::entities::{ alert::{Alert, AlertData}, monitor_timestamp, @@ -92,7 +93,10 @@ pub async fn launch_ec2_instance( ) .min_count(1) .max_count(1) - .user_data(user_data); + .user_data( + base64::engine::general_purpose::STANDARD_NO_PAD + .encode(user_data), + ); for volume in volumes { let ebs = EbsBlockDevice::builder()