Skip to content

Commit

Permalink
Expose the unique execution ID in the TTPs runner
Browse files Browse the repository at this point in the history
  • Loading branch information
christophetd committed Apr 6, 2022
1 parent bbaaa74 commit 7559f18
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/providers/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

var awsProvider = AWSProvider{
UniqueCorrelationId: uuid.New(),
UniqueCorrelationId: UniqueExecutionId,
}

func AWS() *AWSProvider {
Expand Down
2 changes: 1 addition & 1 deletion internal/providers/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type K8sProvider struct {
}

var (
k8sProvider = K8sProvider{UniqueCorrelationId: uuid.New()}
k8sProvider = K8sProvider{UniqueCorrelationId: UniqueExecutionId}
kubeConfigPath string
kubeConfigPathWasResolved bool
)
Expand Down
3 changes: 3 additions & 0 deletions internal/providers/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions pkg/stratus/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package runner

import (
"errors"
"github.com/datadog/stratus-red-team/internal/providers"
"log"
"path/filepath"
"strings"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 7559f18

Please sign in to comment.