diff --git a/internal/providers/aws.go b/internal/providers/aws.go index 50aac1e5..4e19641e 100644 --- a/internal/providers/aws.go +++ b/internal/providers/aws.go @@ -13,7 +13,7 @@ import ( ) var awsProvider = AWSProvider{ - UniqueCorrelationId: uuid.New(), + UniqueCorrelationId: UniqueExecutionId, } func AWS() *AWSProvider { diff --git a/internal/providers/kubernetes.go b/internal/providers/kubernetes.go index 34f96487..c7a92877 100644 --- a/internal/providers/kubernetes.go +++ b/internal/providers/kubernetes.go @@ -26,7 +26,7 @@ type K8sProvider struct { } var ( - k8sProvider = K8sProvider{UniqueCorrelationId: uuid.New()} + k8sProvider = K8sProvider{UniqueCorrelationId: UniqueExecutionId} kubeConfigPath string kubeConfigPathWasResolved bool ) diff --git a/internal/providers/main.go b/internal/providers/main.go index 18503178..033f062d 100644 --- a/internal/providers/main.go +++ b/internal/providers/main.go @@ -3,10 +3,13 @@ package providers import ( "errors" "github.com/datadog/stratus-red-team/pkg/stratus" + "github.com/google/uuid" ) const StratusUserAgent = "stratus-red-team" +var UniqueExecutionId = uuid.New() + // EnsureAuthenticated ensures that the current user is properly authenticated against a specific platform func EnsureAuthenticated(platform stratus.Platform) error { switch platform { diff --git a/pkg/stratus/runner/runner.go b/pkg/stratus/runner/runner.go index 8f00508c..b1e229be 100644 --- a/pkg/stratus/runner/runner.go +++ b/pkg/stratus/runner/runner.go @@ -2,6 +2,7 @@ package runner import ( "errors" + "github.com/datadog/stratus-red-team/internal/providers" "log" "path/filepath" "strings" @@ -194,6 +195,11 @@ func (m *Runner) setState(state stratus.AttackTechniqueState) { m.TechniqueState = state } +// GetUniqueExecutionId returns an unique execution ID, unique per run of Stratus Red Team (not for each TTP detonated) +func (m *Runner) GetUniqueExecutionId() string { + return providers.UniqueExecutionId.String() +} + // Utility function to display better error messages than the Terraform ones func errorMessageFromTerraformError(err error) string { const MissingRegionErrorMessage = "The argument \"region\" is required, but no definition was found"