Skip to content

Commit

Permalink
Merge pull request #10 from eddie-knight/strike-messages
Browse files Browse the repository at this point in the history
Polished some strike messages
  • Loading branch information
grudra7714 authored Oct 31, 2023
2 parents cab7eb4 + d2e1501 commit 75fe694
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
9 changes: 6 additions & 3 deletions strikes/AutomatedBackups.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package strikes

import (
"context"
"fmt"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/rds"
Expand Down Expand Up @@ -45,14 +46,14 @@ func (a *Strikes) AutomatedBackups() (strikeName string, result raidengine.Strik
}

result.Passed = true
result.Message = "Completed Successfully"
result.Message = "Automated Backups are enabled"
return
}

func checkRDSAutomatedBackupMovement(cfg aws.Config) (result raidengine.MovementResult) {

result = raidengine.MovementResult{
Description: "Check if the instance has automated backups enabled",
Description: "Check whether the instance has automated backups enabled",
Function: utils.CallerPath(0),
}

Expand All @@ -71,6 +72,8 @@ func checkRDSAutomatedBackupMovement(cfg aws.Config) (result raidengine.Movement
}

// Loop through the instances and print information
result.Passed = len(backups.DBInstanceAutomatedBackups) > 0
backupCount := len(backups.DBInstanceAutomatedBackups)
result.Message = fmt.Sprintf("%d Automated backups found", backupCount)
result.Passed = backupCount > 0
return
}
4 changes: 2 additions & 2 deletions strikes/Encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ func (a *Strikes) Encryption() (strikeName string, result raidengine.StrikeResul
}

result.Passed = true
result.Message = "Completed Successfully"
result.Message = "Storage encryption is enabled"
return
}

func checkIfStorageIsEncryptedMovement(cfg aws.Config) (result raidengine.MovementResult) {

result = raidengine.MovementResult{
Description: "Check if the instance has storage encryption enabled",
Description: "Check whether the instance has storage encryption enabled",
Function: utils.CallerPath(0),
}

Expand Down
10 changes: 5 additions & 5 deletions strikes/MultiRegion.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func (a *Strikes) MultiRegion() (strikeName string, result raidengine.StrikeResu
strikeName = "MultiRegion"
result = raidengine.StrikeResult{
Passed: false,
Description: "Check if AWS RDS instance has multi region. This strike only checks for a read replica in a seperate region",
Description: "Check whether AWS RDS instance has multi-region read replicas",
DocsURL: "https://www.github.com/krumIO/raid-rds",
ControlID: "CCC-Taxonomy-1",
Movements: make(map[string]raidengine.MovementResult),
Expand Down Expand Up @@ -46,7 +46,7 @@ func (a *Strikes) MultiRegion() (strikeName string, result raidengine.StrikeResu
func checkRDSMultiRegionMovement(cfg aws.Config) (result raidengine.MovementResult) {

result = raidengine.MovementResult{
Description: "Check if the instance has multi region enabled",
Description: "Look for read replicas in a different region than the host instance",
Function: utils.CallerPath(0),
}
instanceIdentifier, _ := getHostDBInstanceIdentifier()
Expand All @@ -58,7 +58,7 @@ func checkRDSMultiRegionMovement(cfg aws.Config) (result raidengine.MovementResu

if len(readReplicas) == 0 {
result.Passed = false
result.Message = "Multi Region instances not found"
result.Message = "Read replicas not found for this instance"
return
}

Expand All @@ -78,7 +78,7 @@ func checkRDSMultiRegionMovement(cfg aws.Config) (result raidengine.MovementResu

if len(replicaInstance.DBInstances) == 0 {
result.Passed = false
result.Message = "Cannot access the replica instance " + replica
result.Message = "Read replica exists, but cannot access: " + replica
return
}

Expand All @@ -87,7 +87,7 @@ func checkRDSMultiRegionMovement(cfg aws.Config) (result raidengine.MovementResu
// db instance doesnt contain the region so we need to remove the last character from the az
if az[:len(az)-1] == hostRDSRegion {
result.Passed = false
result.Message = "Multi Region instances not found"
result.Message = "Read replica exists, but not in a different region"
return
}
}
Expand Down
8 changes: 4 additions & 4 deletions strikes/RBAC.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func (a *Strikes) RBAC() (strikeName string, result raidengine.StrikeResult) {
strikeName = "RBAC"
result = raidengine.StrikeResult{
Passed: false,
Description: "Check if database IAM authentication is enabled on the specified RDS instance",
Description: "Check whether primary RDS instance supports RBAC authentication",
DocsURL: "https://www.github.com/krumIO/raid-rds",
ControlID: "CCC-Taxonomy-1",
Movements: make(map[string]raidengine.MovementResult),
Expand All @@ -36,20 +36,19 @@ func (a *Strikes) RBAC() (strikeName string, result raidengine.StrikeResult) {

iamDatabaseAuthMovement := checkForIAMDatabaseAuthMovement(cfg)
result.Movements["CheckForIAMDatabaseAuth"] = iamDatabaseAuthMovement
result.Message = iamDatabaseAuthMovement.Message
if !iamDatabaseAuthMovement.Passed {
result.Message = iamDatabaseAuthMovement.Message
return
}

result.Passed = true
result.Message = "Completed Successfully"
return
}

func checkForIAMDatabaseAuthMovement(cfg aws.Config) (result raidengine.MovementResult) {

result = raidengine.MovementResult{
Description: "Check if the instance has IAM Database Authentication enabled",
Description: "Check whether the instance has IAM Database Authentication enabled",
Function: utils.CallerPath(0),
}

Expand All @@ -71,5 +70,6 @@ func checkForIAMDatabaseAuthMovement(cfg aws.Config) (result raidengine.Movement

// Loop through the instances and print information
result.Passed = true
result.Message = "IAM Database Authentication is enabled"
return
}
3 changes: 2 additions & 1 deletion strikes/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func connectToDb() (result raidengine.MovementResult) {
func checkRDSInstanceMovement(cfg aws.Config) (result raidengine.MovementResult) {
// check if the instance is available
result = raidengine.MovementResult{
Description: "Check if the instance is available/exists",
Description: "Check whether the instance can be reached",
Function: utils.CallerPath(0),
}

Expand All @@ -105,6 +105,7 @@ func checkRDSInstanceMovement(cfg aws.Config) (result raidengine.MovementResult)
result.Passed = false
return
}
result.Message = "Instance found"
result.Passed = len(instance.DBInstances) > 0
return
}
Expand Down

0 comments on commit 75fe694

Please sign in to comment.