-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alex Jones <[email protected]>
- Loading branch information
1 parent
2b7c7f2
commit a715387
Showing
5 changed files
with
56 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use crate::analyzer::analyzer_trait; | ||
use crate::analyzer::types::AnalysisResults; | ||
use crate::utils; | ||
use async_trait::async_trait; | ||
use aws_sdk_iam; | ||
use colored::Colorize; | ||
use std::sync::Arc; | ||
pub struct STSAnalyzer { | ||
pub config: Arc<aws_config::SdkConfig>, | ||
} | ||
#[async_trait] | ||
impl analyzer_trait::Analyzer for STSAnalyzer { | ||
async fn run(&self) -> Option<Vec<AnalysisResults>> { | ||
println!( | ||
"{} {} {}", | ||
"Running".green(), | ||
"STS".blue(), | ||
"analyzer".green() | ||
); | ||
|
||
let mut results = vec![AnalysisResults { | ||
message: "".to_string(), | ||
}]; | ||
let iam = aws_sdk_iam::Client::new(&self.config.clone()); | ||
let list_users_response = iam.list_users().send().await; | ||
let users = list_users_response.unwrap().users.unwrap_or_default(); | ||
for user in users { | ||
let username = user.user_name.as_deref().unwrap_or_default(); | ||
|
||
// Use IAM to get user's MFA status | ||
let mfa_devices_response = iam.list_mfa_devices().user_name(username).send().await; | ||
let mfa_devices = mfa_devices_response.unwrap().mfa_devices.unwrap_or_default(); | ||
|
||
if mfa_devices.is_empty() { | ||
results.push(AnalysisResults{ | ||
message: format!("MFA is not enabled for user {}", username) | ||
}); | ||
} | ||
} | ||
|
||
Some(results) | ||
} | ||
|
||
fn get_name(&self) -> &str { | ||
"sts" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters