Skip to content

Commit

Permalink
chore: removed old deps
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Jones <[email protected]>
  • Loading branch information
AlexsJones committed Oct 25, 2023
1 parent 06e59d8 commit 0176813
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 94 deletions.
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
seahorse = "2.1"
simple-home-dir = "0.2.0"
serde_json = "1.0.107"
serde = {version= "1.0.188", features = ["derive"] }
Expand Down
10 changes: 2 additions & 8 deletions src/analyze/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ pub async fn run_analysis(args: &Args) {
match filtered_analyzer {
Some(x) => {
let thread_tx = tx.clone();
// Init analyzer
x.run().await;

let response = x.run().await;
match response {
Some(respResults) => {
thread_tx.send(respResults).unwrap();
Some(resp_results) => {
thread_tx.send(resp_results).unwrap();
}
None => {
thread_tx.send(vec![AnalysisResults::new()]).unwrap();
Expand All @@ -52,10 +50,6 @@ pub async fn run_analysis(args: &Args) {
for current_analyzer in analyzers {
let thread_tx = tx.clone();
tasks.push(tokio::spawn(async move {

// Init analyzer
current_analyzer.init().await;

let response = current_analyzer.run().await;
match response {
Some(resp_results) => {
Expand Down
24 changes: 12 additions & 12 deletions src/analyzer/s3_analyzer.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use crate::analyzer::analyzer_trait;
use crate::analyzer::types::AnalysisResults;
use crate::utils;

use async_trait::async_trait;
use colored::Colorize;
use std::sync::Arc;
use aws_sdk_s3;
const role_name: &str = "DetectPublicS3BucketsRole";
const policy_name: &str = "DetectPublicS3BucketsPolicy";
const policy_document: &str = r#"{
const ROLE_NAME: &str = "DetectPublicS3BucketsRole";
const POLICY_NAME: &str = "DetectPublicS3BucketsPolicy";
const POLICY_DOCUMENT: &str = r#"{
"Version": "2012-10-17",
"Statement": [
{
Expand All @@ -21,7 +21,7 @@ const policy_document: &str = r#"{
]
}
"#;
const assume_role_policy_document: &str = r#"{
const ASSUME_ROLE_POLICY_DOCUMENT: &str = r#"{
"Version": "2012-10-17",
"Statement": [
{
Expand Down Expand Up @@ -56,27 +56,27 @@ impl analyzer_trait::Analyzer for S3Analyzer {
// let c4 = Arc::clone(&self.config);
// let mut shouldCreate: bool = false;
// // Role ------------------------------------------------------------------------------------
// match utils::iam::check_role_exists(c2, role_name).await {
// Ok(x) => println!("Role {} exists", role_name),
// match utils::iam::check_role_exists(c2, ROLE_NAME).await {
// Ok(x) => println!("Role {} exists", ROLE_NAME),
// _ => {
// shouldCreate = true;
// println!("Role {} does not exist", role_name)
// println!("Role {} does not exist", ROLE_NAME)
// }
// }
// if shouldCreate {
// let response = utils::iam::create_role(c3, role_name, assume_role_policy_document).await?;
// let response = utils::iam::create_role(c3, ROLE_NAME, ASSUME_ROLE_POLICY_DOCUMENT).await?;
// println!(
// "Created role {} with ARN {}",
// response.role_name.unwrap(),
// response.ROLE_NAME.unwrap(),
// response.arn.unwrap()
// );
// }
// // Policy ----------------------------------------------------------------------------------
// let policy = utils::iam::create_policy(c4, policy_name, policy_document).await;
// let policy = utils::iam::create_policy(c4, POLICY_NAME, POLICY_DOCUMENT).await;
// match policy {
// Ok(p) => println!("Created {:?}", p),
// Err(e) => {
// println!("Error creating policy {} {}", policy_name, e);
// println!("Error creating policy {} {}", POLICY_NAME, e);
// },
// }
// -----------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ pub struct AnalysisResults {

impl AnalysisResults {
pub fn new() -> AnalysisResults{
return Self{ message: "".to_string()}
Self{ message: "".to_string()}
}
}
52 changes: 0 additions & 52 deletions src/configure/mod.rs

This file was deleted.

2 changes: 0 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use clap::{Parser};
mod analyze;
mod configure;
mod config;
mod analyzer;
mod outputs;
mod utils;

// const
const CARGO_PKG_NAME: &str = "isotope";
Expand Down
14 changes: 7 additions & 7 deletions src/utils/iam.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::error::Error;
use std::sync::Arc;
use aws_sdk_iam::operation::create_role::{CreateRoleError, CreateRoleOutput};
use aws_sdk_iam::operation::create_role::{CreateRoleError};
use aws_sdk_iam::types::{Policy, Role};
use aws_sdk_sts;

use aws_sdk_iam::error::SdkError;
use aws_sdk_iam::operation::create_policy::{CreatePolicyError, CreatePolicyOutput};
use aws_sdk_iam::operation::create_policy::{CreatePolicyError};
use aws_smithy_runtime_api::client::orchestrator::HttpResponse;
pub async fn check_role_exists(
config: Arc<aws_config::SdkConfig>,
Expand All @@ -14,7 +14,7 @@ pub async fn check_role_exists(
let iam = aws_sdk_iam::Client::new(&config);

// Create a request to get information about the role.
let get_role_request = iam.get_role().role_name(role_name).send().await?;
let _get_role_request = iam.get_role().role_name(role_name).send().await?;
// Attempt to get information about the role.
Ok(())
}
Expand Down Expand Up @@ -42,18 +42,18 @@ pub async fn create_role(
// Configure the AWS region and create an IAM client.
let iam = aws_sdk_iam::Client::new(&config);

let strippedPolicy = &assume_role_policy_document.to_string();
let stripped_policy = &assume_role_policy_document.to_string();
let response = iam
.create_role()
.role_name(role_name)
.assume_role_policy_document(strippedPolicy)
.assume_role_policy_document(stripped_policy)
.send()
.await;
match response {
Ok(x) => Ok(x.role.unwrap()),
Err(e) => {
println!("create_role {:?}", e);
return Err(e);
Err(e)
}
}
}
8 changes: 4 additions & 4 deletions src/utils/sts.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use aws_sdk_sts::error::SdkError;
use aws_sdk_sts::operation::assume_role::{AssumeRoleError, AssumeRoleOutput};
use aws_smithy_runtime_api::client::orchestrator::HttpResponse;
use std::error::Error;




use std::sync::Arc;

pub async fn get_account_id(config: Arc<aws_config::SdkConfig>) -> Option<String> {
Expand Down

0 comments on commit 0176813

Please sign in to comment.