Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed raids.RDS.aws to raids.rds #7

Merged
merged 2 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions example-config.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
loglevel: Debug
WriteDirectory: test_output
AWS:
access_key: access
secret_key: supersecret
session_key: ""
region: us-east-1
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:
config:
instance_identifier: unique-id-name
database: test
primary_region: us-east-1
host: localhost
password: password
port: 3306
user: root
tactics:
- CCC-Taxonomy
28 changes: 14 additions & 14 deletions strikes/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,36 @@ 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")
if viper.IsSet("aws") &&
viper.IsSet("aws.access_key") &&
viper.IsSet("aws.secret_key") &&
viper.IsSet("aws.region") {

access_key := viper.GetString("aws.access_key")
secret_key := viper.GetString("aws.secret_key")
session_key := viper.GetString("aws.session_key")
region := viper.GetString("aws.region")

creds := credentials.NewStaticCredentialsProvider(access_key, secret_key, session_key)
cfg, err = config.LoadDefaultConfig(context.TODO(), config.WithCredentialsProvider(creds), config.WithRegion(region))
Expand Down
Loading