From e44eb1cf17203af2fac4d85abd853008bf77b6db Mon Sep 17 00:00:00 2001 From: Eddie Knight Date: Tue, 17 Oct 2023 15:54:04 -0500 Subject: [PATCH] Bugfix: tactic config var target Signed-off-by: Eddie Knight --- cmd/debug.go | 3 +-- cmd/root.go | 16 ++++++++++++---- go.mod | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/cmd/debug.go b/cmd/debug.go index 8310f46..0e8f23e 100644 --- a/cmd/debug.go +++ b/cmd/debug.go @@ -4,7 +4,6 @@ import ( "log" "github.com/spf13/cobra" - "github.com/spf13/viper" "github.com/privateerproj/privateer-sdk/raidengine" ) @@ -15,7 +14,7 @@ var ( Use: "debug", Short: "Run the Raid in debug mode", Run: func(cmd *cobra.Command, args []string) { - err := raidengine.Run(RaidName, viper.GetString("raids.wireframe.tactic"), getStrikes()) + err := raidengine.Run(RaidName, getStrikes()) if err != nil { log.Fatal(err) } diff --git a/cmd/root.go b/cmd/root.go index 177762b..b49ccb8 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,6 +1,7 @@ package cmd import ( + "fmt" "os" "github.com/spf13/cobra" @@ -72,17 +73,17 @@ func cleanupFunc() error { // Adding raidengine.SetupCloseHandler(cleanupFunc) will allow you to append custom cleanup behavior func (r *Raid) Start() error { raidengine.SetupCloseHandler(cleanupFunc) - return raidengine.Run(RaidName, viper.GetString("tactic"), getStrikes()) // Return errors from strike executions + return raidengine.Run(RaidName, getStrikes()) // Return errors from strike executions } // GetStrikes returns a list of probe objects -func getStrikes() map[string][]raidengine.Strike { +func getStrikes() []raidengine.Strike { logger := raidengine.GetLogger(RaidName, false) a := &strikes.Antijokes{ Log: logger, } - return map[string][]raidengine.Strike{ - "PCI": { + availableStrikes := map[string][]raidengine.Strike{ + "CCC-Taxonomy": { a.KnockKnock, }, "CIS": { @@ -90,4 +91,11 @@ func getStrikes() map[string][]raidengine.Strike { a.ChickenCrossedRoad, }, } + tactic := viper.GetString("raids.wireframe.tactic") + strikes := availableStrikes[tactic] + if len(strikes) == 0 { + message := fmt.Sprintf("No strikes were found for the provided strike set: %s", tactic) + logger.Error(message) + } + return strikes } diff --git a/go.mod b/go.mod index 172c3d8..4ba0579 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.14 require ( github.com/hashicorp/go-hclog v1.2.0 - github.com/privateerproj/privateer-sdk v0.0.3 + github.com/privateerproj/privateer-sdk v0.0.4 github.com/spf13/cobra v1.4.0 github.com/spf13/viper v1.15.0 )