From 4cea63fcd45a260b12d0928cefe24d8425436131 Mon Sep 17 00:00:00 2001 From: Eddie Knight Date: Sat, 28 Oct 2023 19:08:43 -0500 Subject: [PATCH] Changed raids.RDS.aws to raids.rds Signed-off-by: Eddie Knight --- example-config.yml | 31 ++++++++++++++----------------- strikes/common.go | 35 +++++++++++++++++++++-------------- 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/example-config.yml b/example-config.yml index 436075b..cef3a78 100644 --- a/example-config.yml +++ b/example-config.yml @@ -1,22 +1,19 @@ loglevel: Debug WriteDirectory: test_output raids: - RDS: - aws: - creds: - aws_access_key: access - aws_secret_key: supersecret - aws_session_key: "" - aws_region: us-east-1 - config: - instance_identifier: unique-id-name - database: test - primary_region: us-east-1 - host: localhost - password: password - port: 3306 - user: root - # google - # azure + rds: + creds: + aws_access_key: access + aws_secret_key: supersecret + aws_session_key: "" + aws_region: us-east-1 + config: + instance_identifier: unique-id-name + database: test + primary_region: us-east-1 + host: localhost + password: password + port: 3306 + user: root tactics: - CCC-Taxonomy \ No newline at end of file diff --git a/strikes/common.go b/strikes/common.go index 22f3520..19862c6 100644 --- a/strikes/common.go +++ b/strikes/common.go @@ -27,36 +27,43 @@ func (a *Strikes) SetLogger(loggerName string) { } func getDBConfig() (string, error) { - if viper.IsSet("raids.RDS.aws.config.host") && viper.IsSet("raids.RDS.aws.config.database") { + if viper.IsSet("raids.rds.config.host") && viper.IsSet("raids.rds.config.database") { return "database_host_placeholder", nil } return "", errors.New("database url must be set in the config file") } func getHostDBInstanceIdentifier() (string, error) { - if viper.IsSet("raids.RDS.aws.config.instance_identifier") { - return viper.GetString("raids.RDS.aws.config.instance_identifier"), nil + if viper.IsSet("raids.rds.config.instance_identifier") { + return viper.GetString("raids.rds.config.instance_identifier"), nil } return "", errors.New("database instance identifier must be set in the config file") } func getHostRDSRegion() (string, error) { - if viper.IsSet("raids.RDS.aws.config.primary_region") { - return viper.GetString("raids.RDS.aws.config.primary_region"), nil + if viper.IsSet("raids.rds.config.primary_region") { + return viper.GetString("raids.rds.config.primary_region"), nil } return "", errors.New("database instance identifier must be set in the config file") } func getAWSConfig() (cfg aws.Config, err error) { - if viper.IsSet("raids.RDS.aws.creds") && - viper.IsSet("raids.RDS.aws.creds.aws_access_key") && - viper.IsSet("raids.RDS.aws.creds.aws_secret_key") && - viper.IsSet("raids.RDS.aws.creds.aws_region") { - - access_key := viper.GetString("raids.RDS.aws.creds.aws_access_key") - secret_key := viper.GetString("raids.RDS.aws.creds.aws_secret_key") - session_key := viper.GetString("raids.RDS.aws.creds.aws_session_key") - region := viper.GetString("raids.RDS.aws.creds.aws_region") + config_values = [ + "raids.rds.creds.aws_access_key", + "raids.rds.creds.aws_secret_key", + "raids.rds.creds.aws_session_key", + "raids.rds.creds.aws_region", + + ] + if viper.IsSet("raids.rds.creds") && + viper.IsSet("raids.rds.creds.aws_access_key") && + viper.IsSet("raids.rds.creds.aws_secret_key") && + viper.IsSet("raids.rds.creds.aws_region") { + + access_key := viper.GetString("raids.rds.creds.aws_access_key") + secret_key := viper.GetString("raids.rds.creds.aws_secret_key") + session_key := viper.GetString("raids.rds.creds.aws_session_key") + region := viper.GetString("raids.rds.creds.aws_region") creds := credentials.NewStaticCredentialsProvider(access_key, secret_key, session_key) cfg, err = config.LoadDefaultConfig(context.TODO(), config.WithCredentialsProvider(creds), config.WithRegion(region))