-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:krumIO/raid-rds into strike-messages
- Loading branch information
Showing
5 changed files
with
217 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package strikes | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go-v2/aws" | ||
"github.com/privateerproj/privateer-sdk/raidengine" | ||
"github.com/privateerproj/privateer-sdk/utils" | ||
) | ||
|
||
// Todo/Roadmap: Features to evaluate implementing | ||
// Encryption.go - AWS CLI | ||
|
||
// This creates a database table | ||
func (a *Strikes) Encryption() (strikeName string, result raidengine.StrikeResult) { | ||
strikeName = "Encryption" | ||
result = raidengine.StrikeResult{ | ||
Passed: false, | ||
Description: "Check if storage is encrypted on the specified RDS instance", | ||
DocsURL: "https://www.github.com/krumIO/raid-rds", | ||
ControlID: "CCC-Taxonomy-1", | ||
Movements: make(map[string]raidengine.MovementResult), | ||
} | ||
|
||
// Get Configuration | ||
cfg, err := getAWSConfig() | ||
if err != nil { | ||
result.Message = err.Error() | ||
return | ||
} | ||
|
||
rdsInstanceMovement := checkRDSInstanceMovement(cfg) | ||
result.Movements["CheckForDBInstance"] = rdsInstanceMovement | ||
if !rdsInstanceMovement.Passed { | ||
result.Message = rdsInstanceMovement.Message | ||
return | ||
} | ||
|
||
storageEncryptedMovement := checkIfStorageIsEncryptedMovement(cfg) | ||
result.Movements["CheckForStorageEncryption"] = storageEncryptedMovement | ||
if !storageEncryptedMovement.Passed { | ||
result.Message = storageEncryptedMovement.Message | ||
return | ||
} | ||
|
||
result.Passed = true | ||
result.Message = "Completed Successfully" | ||
return | ||
} | ||
|
||
func checkIfStorageIsEncryptedMovement(cfg aws.Config) (result raidengine.MovementResult) { | ||
|
||
result = raidengine.MovementResult{ | ||
Description: "Check if the instance has storage encryption enabled", | ||
Function: utils.CallerPath(0), | ||
} | ||
|
||
instanceIdentifier, _ := getHostDBInstanceIdentifier() | ||
|
||
instance, err := getRDSInstanceFromIdentifier(cfg, instanceIdentifier) | ||
if err != nil { | ||
// Handle error | ||
result.Message = err.Error() | ||
result.Passed = false | ||
return | ||
} | ||
|
||
if !instance.DBInstances[0].StorageEncrypted { | ||
result.Message = "Storage encryption is not enabled" | ||
result.Passed = false | ||
return | ||
} | ||
|
||
// Loop through the instances and print information | ||
result.Passed = true | ||
return | ||
} |
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,32 @@ | ||
package strikes | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/spf13/viper" | ||
) | ||
|
||
func TestEncryption(t *testing.T) { | ||
viper.AddConfigPath("../") | ||
viper.SetConfigName("config") | ||
viper.SetConfigType("yaml") | ||
err := viper.ReadInConfig() | ||
|
||
if err != nil { | ||
fmt.Println("Config file not found...") | ||
return | ||
} | ||
|
||
strikes := Strikes{} | ||
strikeName, result := strikes.Encryption() | ||
|
||
fmt.Println(strikeName) | ||
b, err := json.MarshalIndent(result, "", " ") | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
fmt.Print(string(b)) | ||
fmt.Println() | ||
} |
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,75 @@ | ||
package strikes | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go-v2/aws" | ||
"github.com/privateerproj/privateer-sdk/raidengine" | ||
"github.com/privateerproj/privateer-sdk/utils" | ||
) | ||
|
||
// Todo/Roadmap: Features to evaluate implementing | ||
// RBAC.go - AWS CLI | ||
|
||
// This creates a database table | ||
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", | ||
DocsURL: "https://www.github.com/krumIO/raid-rds", | ||
ControlID: "CCC-Taxonomy-1", | ||
Movements: make(map[string]raidengine.MovementResult), | ||
} | ||
|
||
// Get Configuration | ||
cfg, err := getAWSConfig() | ||
if err != nil { | ||
result.Message = err.Error() | ||
return | ||
} | ||
|
||
rdsInstanceMovement := checkRDSInstanceMovement(cfg) | ||
result.Movements["CheckForDBInstance"] = rdsInstanceMovement | ||
if !rdsInstanceMovement.Passed { | ||
result.Message = rdsInstanceMovement.Message | ||
return | ||
} | ||
|
||
iamDatabaseAuthMovement := checkForIAMDatabaseAuthMovement(cfg) | ||
result.Movements["CheckForIAMDatabaseAuth"] = iamDatabaseAuthMovement | ||
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", | ||
Function: utils.CallerPath(0), | ||
} | ||
|
||
instanceIdentifier, _ := getHostDBInstanceIdentifier() | ||
|
||
instance, err := getRDSInstanceFromIdentifier(cfg, instanceIdentifier) | ||
if err != nil { | ||
// Handle error | ||
result.Message = err.Error() | ||
result.Passed = false | ||
return | ||
} | ||
|
||
if !instance.DBInstances[0].IAMDatabaseAuthenticationEnabled { | ||
result.Message = "IAM Database Authentication is not enabled" | ||
result.Passed = false | ||
return | ||
} | ||
|
||
// Loop through the instances and print information | ||
result.Passed = true | ||
return | ||
} |
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,32 @@ | ||
package strikes | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/spf13/viper" | ||
) | ||
|
||
func TestRBAC(t *testing.T) { | ||
viper.AddConfigPath("../") | ||
viper.SetConfigName("config") | ||
viper.SetConfigType("yaml") | ||
err := viper.ReadInConfig() | ||
|
||
if err != nil { | ||
fmt.Println("Config file not found...") | ||
return | ||
} | ||
|
||
strikes := Strikes{} | ||
strikeName, result := strikes.RBAC() | ||
|
||
fmt.Println(strikeName) | ||
b, err := json.MarshalIndent(result, "", " ") | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
fmt.Print(string(b)) | ||
fmt.Println() | ||
} |