diff --git a/Makefile b/Makefile index 57dc14d..c09d512 100644 --- a/Makefile +++ b/Makefile @@ -1,39 +1,39 @@ -PACKNAME=example +PACKNAME=example-plugin BUILD_FLAGS=-X 'main.GitCommitHash=`git rev-parse --short HEAD`' -X 'main.BuiltAt=`date +%FT%T%z`' BUILD_WIN=@env GOOS=windows GOARCH=amd64 go build -o $(PACKNAME).exe BUILD_LINUX=@env GOOS=linux GOARCH=amd64 go build -o $(PACKNAME) BUILD_MAC=@env GOOS=darwin GOARCH=amd64 go build -o $(PACKNAME)-darwin -release: go-package go-release go-bin -release-candidate: go-package go-release-candidate -binary: go-package go-build +release: package release bin +release-candidate: package release-candidate +binary: package build -go-release: release-nix release-win release-mac +release: release-nix release-win release-mac -go-build: +build: @echo " > Building binary ..." @go build -o $(PACKNAME) -ldflags="$(BUILD_FLAGS)" -go-package: go-tidy go-test +package: tidy test @echo " > Packaging static files..." -go-test: +test: @echo " > Validating code ..." @go vet ./... @go clean -testcache @go test ./... -go-tidy: +tidy: @echo " > Tidying go.mod ..." @go mod tidy -go-test-cov: +test-cov: @echo "Running tests and generating coverage output ..." @go test ./... -coverprofile coverage.out -covermode count @sleep 2 # Sleeping to allow for coverage.out file to get generated @echo "Current test coverage : $(shell go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+') %" -go-release-candidate: go-tidy go-test +release-candidate: tidy test @echo " > Building release candidate for Linux..." $(BUILD_LINUX) -ldflags="$(BUILD_FLAGS) -X 'main.VersionPostfix=nix-rc'" @echo " > Building release candidate for Windows..." @@ -53,5 +53,5 @@ release-mac: @echo " > Building release for Darwin..." $(BUILD_MAC) -ldflags="$(BUILD_FLAGS) -X 'main.VersionPostfix=darwin'" -go-bin: +bin: @mv $(PACKNAME)* ~/privateer/bin diff --git a/README.md b/README.md index 62fcd3a..8239103 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Privateer Plugin example +# Privateer Plugin example-plugin This wireframe is designed to quickly get your service pack repository up to speed! diff --git a/armory/armory.go b/armory/armory.go index 16075d3..fbbb7d8 100644 --- a/armory/armory.go +++ b/armory/armory.go @@ -11,112 +11,47 @@ var ( "tlp_amber": { CCC_C01_TR01, CCC_C01_TR02, - CCC_C02_TR01, - CCC_C03_TR01, - CCC_C03_TR02, - CCC_C03_TR03, - CCC_C03_TR04, - CCC_C03_TR05, - CCC_C03_TR06, - CCC_C04_TR01, - CCC_C04_TR02, - CCC_C05_TR01, - CCC_C05_TR02, - CCC_C05_TR03, - CCC_C05_TR04, CCC_C06_TR01, CCC_C06_TR02, - CCC_C07_TR02, CCC_C08_TR01, CCC_C08_TR02, CCC_C09_TR01, CCC_C09_TR02, CCC_C09_TR03, CCC_C10_TR01, - CCC_C11_TR01, - CCC_C11_TR02, - CCC_C11_TR03, - CCC_C11_TR04, - CCC_VPC_C01_TR01, - CCC_VPC_C03_TR01, - CCC_VPC_C04_TR01, }, "tlp_clear": { CCC_C01_TR01, CCC_C01_TR02, - CCC_C02_TR01, - CCC_C03_TR01, - CCC_C03_TR04, - CCC_C03_TR06, - CCC_C04_TR02, - CCC_C05_TR02, - CCC_C05_TR04, CCC_C06_TR01, CCC_C06_TR02, - CCC_C07_TR02, CCC_C09_TR01, CCC_C09_TR02, CCC_C09_TR03, - CCC_C11_TR01, - CCC_C11_TR02, }, "tlp_green": { CCC_C01_TR01, CCC_C01_TR02, - CCC_C02_TR01, - CCC_C03_TR01, - CCC_C03_TR04, - CCC_C03_TR06, - CCC_C04_TR02, - CCC_C05_TR02, - CCC_C05_TR04, CCC_C06_TR01, CCC_C06_TR02, - CCC_C07_TR02, CCC_C08_TR01, CCC_C08_TR02, CCC_C09_TR01, CCC_C09_TR02, CCC_C09_TR03, CCC_C10_TR01, - CCC_C11_TR01, - CCC_C11_TR02, - CCC_VPC_C03_TR01, }, "tlp_red": { CCC_C01_TR01, CCC_C01_TR02, - CCC_C02_TR01, - CCC_C03_TR01, - CCC_C03_TR02, - CCC_C03_TR03, - CCC_C03_TR04, - CCC_C03_TR05, - CCC_C03_TR06, - CCC_C04_TR01, - CCC_C04_TR02, - CCC_C05_TR01, - CCC_C05_TR02, - CCC_C05_TR03, - CCC_C05_TR04, CCC_C06_TR01, CCC_C06_TR02, - CCC_C07_TR01, - CCC_C07_TR02, CCC_C08_TR01, CCC_C08_TR02, CCC_C09_TR01, CCC_C09_TR02, CCC_C09_TR03, CCC_C10_TR01, - CCC_C11_TR01, - CCC_C11_TR02, - CCC_C11_TR03, - CCC_C11_TR04, - CCC_VPC_C01_TR01, - CCC_VPC_C02_TR01, - CCC_VPC_C03_TR01, - CCC_VPC_C04_TR01, }, }, } diff --git a/armory/examples.go b/armory/examples.go index 3477642..cb2065f 100644 --- a/armory/examples.go +++ b/armory/examples.go @@ -47,11 +47,11 @@ func ExampleTestSet01() (testSetName string, result pluginkit.TestSetResult) { } // ExampleTest0101 does not apply a change to the system -func ExampleTest0101() (moveResult pluginkit.TestResult) { +func ExampleTest0101() (testResult pluginkit.TestResult) { // Pretend we're making some API call or other logic to determine if the test is applicable customLogicResults := true - moveResult = pluginkit.TestResult{ + testResult = pluginkit.TestResult{ Description: "Making an API call to see if HTTPS is enforced.", Function: utils.CallerPath(0), // This allows interested users to jump directly to the code that is executing this test Passed: customLogicResults, @@ -61,7 +61,7 @@ func ExampleTest0101() (moveResult pluginkit.TestResult) { // ExampleTest0102 applies an invasive change to the system. Not all changes are invasive, but this one is. // Use ExecuteInvasiveTest() to ensure it is run only when the user has opted in to potentially destructive changes. -func ExampleTest0102() (moveResult pluginkit.TestResult) { +func ExampleTest0102() (testResult pluginkit.TestResult) { // The functions here can be defined whereever you like // If you have a lot of changes or plan to reuse them, you may want to put them in a separate file change1 := pluginkit.NewChange( @@ -84,7 +84,7 @@ func ExampleTest0102() (moveResult pluginkit.TestResult) { change1.Revert() // Note that we are not setting Passed to true or false. That will be determined by ExecuteTest() or ExecuteInvasiveTest() - moveResult = pluginkit.TestResult{ + testResult = pluginkit.TestResult{ Description: "Making an API call to see if HTTPS is enforced.", Function: utils.CallerPath(0), // This allows interested users to jump directly to the code that is executing this test Changes: map[string]*pluginkit.Change{ diff --git a/armory/testSets.go b/armory/testSets.go index 05ba384..d2c40d0 100644 --- a/armory/testSets.go +++ b/armory/testSets.go @@ -4,18 +4,19 @@ import ( "github.com/privateerproj/privateer-sdk/pluginkit" "github.com/privateerproj/privateer-sdk/utils" ) - +// ---------- +// TestSets for Data Protection Control Family +// ---------- // ----- -// TestSet and Tests for CCC_C01_TR01 +// TestSet and Tests for Requirement CCC_C01_TR01 // ----- // CCC_C01_TR01 conforms to the TestSet function type func CCC_C01_TR01() (testSetName string, result pluginkit.TestSetResult) { // set default return values - testSetName = "CCC_C01_TR01" + testSetName = "CCC.C01.TR01" result = pluginkit.TestSetResult{ - Passed: false, - Description: "When a port is exposed for non-SSH network traffic, all traffic MUST include a TLS handshake AND be encrypted using TLS 1.2 or higher.", + Description: "When a port is exposed for non-SSH network traffic, all traffic MUST include a TLS handshake AND be encrypted using TLS 1_2 or higher_", ControlID: "CCC.C01", Tests: make(map[string]pluginkit.TestResult), } @@ -26,8 +27,8 @@ func CCC_C01_TR01() (testSetName string, result pluginkit.TestSetResult) { return } -func CCC_C01_TR01_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ +func CCC_C01_TR01_T01() (testResult pluginkit.TestResult) { + testResult = pluginkit.TestResult{ Description: "This test is still under construction", Function: utils.CallerPath(0), } @@ -36,18 +37,16 @@ func CCC_C01_TR01_T01() (moveResult pluginkit.TestResult) { return } - // ----- -// TestSet and Tests for CCC_C01_TR02 +// TestSet and Tests for Requirement CCC_C01_TR02 // ----- // CCC_C01_TR02 conforms to the TestSet function type func CCC_C01_TR02() (testSetName string, result pluginkit.TestSetResult) { // set default return values - testSetName = "CCC_C01_TR02" + testSetName = "CCC.C01.TR02" result = pluginkit.TestSetResult{ - Passed: false, - Description: "When a port is exposed for SSH network traffic, all traffic MUST include a SSH handshake AND be encrypted using SSHv2 or higher.", + Description: "When a port is exposed for SSH network traffic, all traffic MUST include a SSH handshake AND be encrypted using SSHv2 or higher_", ControlID: "CCC.C01", Tests: make(map[string]pluginkit.TestResult), } @@ -58,8 +57,8 @@ func CCC_C01_TR02() (testSetName string, result pluginkit.TestSetResult) { return } -func CCC_C01_TR02_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ +func CCC_C01_TR02_T01() (testResult pluginkit.TestResult) { + testResult = pluginkit.TestResult{ Description: "This test is still under construction", Function: utils.CallerPath(0), } @@ -68,434 +67,16 @@ func CCC_C01_TR02_T01() (moveResult pluginkit.TestResult) { return } - -// ----- -// TestSet and Tests for CCC_C02_TR01 -// ----- - -// CCC_C02_TR01 conforms to the TestSet function type -func CCC_C02_TR01() (testSetName string, result pluginkit.TestSetResult) { - // set default return values - testSetName = "CCC_C02_TR01" - result = pluginkit.TestSetResult{ - Passed: false, - Description: "When data is stored at rest, the service MUST be configured to encrypt data at rest using the latest industry-standard encryption methods.", - ControlID: "CCC.C02", - Tests: make(map[string]pluginkit.TestResult), - } - - result.ExecuteTest(CCC_C02_TR01_T01) - // TODO: Additional test calls go here - - return -} - -func CCC_C02_TR01_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ - Description: "This test is still under construction", - Function: utils.CallerPath(0), - } - - // TODO: Use this section to write a single step or test that contributes to CCC_C02_TR01 - return -} - - -// ----- -// TestSet and Tests for CCC_C03_TR01 -// ----- - -// CCC_C03_TR01 conforms to the TestSet function type -func CCC_C03_TR01() (testSetName string, result pluginkit.TestSetResult) { - // set default return values - testSetName = "CCC_C03_TR01" - result = pluginkit.TestSetResult{ - Passed: false, - Description: "When an entity attempts to modify the service, the service MUST attempt to verify the client's identity through an authentication process.", - ControlID: "CCC.C03", - Tests: make(map[string]pluginkit.TestResult), - } - - result.ExecuteTest(CCC_C03_TR01_T01) - // TODO: Additional test calls go here - - return -} - -func CCC_C03_TR01_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ - Description: "This test is still under construction", - Function: utils.CallerPath(0), - } - - // TODO: Use this section to write a single step or test that contributes to CCC_C03_TR01 - return -} - - -// ----- -// TestSet and Tests for CCC_C03_TR02 -// ----- - -// CCC_C03_TR02 conforms to the TestSet function type -func CCC_C03_TR02() (testSetName string, result pluginkit.TestSetResult) { - // set default return values - testSetName = "CCC_C03_TR02" - result = pluginkit.TestSetResult{ - Passed: false, - Description: "When an entity attempts to view information presented by the service, service, the service MUST attempt to verify the client's identity through an authentication process.", - ControlID: "CCC.C03", - Tests: make(map[string]pluginkit.TestResult), - } - - result.ExecuteTest(CCC_C03_TR02_T01) - // TODO: Additional test calls go here - - return -} - -func CCC_C03_TR02_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ - Description: "This test is still under construction", - Function: utils.CallerPath(0), - } - - // TODO: Use this section to write a single step or test that contributes to CCC_C03_TR02 - return -} - - -// ----- -// TestSet and Tests for CCC_C03_TR03 -// ----- - -// CCC_C03_TR03 conforms to the TestSet function type -func CCC_C03_TR03() (testSetName string, result pluginkit.TestSetResult) { - // set default return values - testSetName = "CCC_C03_TR03" - result = pluginkit.TestSetResult{ - Passed: false, - Description: "When an entity attempts to view information on the service through a user interface, the authentication process MUST require multiple identifying factors from the user.", - ControlID: "CCC.C03", - Tests: make(map[string]pluginkit.TestResult), - } - - result.ExecuteTest(CCC_C03_TR03_T01) - // TODO: Additional test calls go here - - return -} - -func CCC_C03_TR03_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ - Description: "This test is still under construction", - Function: utils.CallerPath(0), - } - - // TODO: Use this section to write a single step or test that contributes to CCC_C03_TR03 - return -} - - -// ----- -// TestSet and Tests for CCC_C03_TR04 -// ----- - -// CCC_C03_TR04 conforms to the TestSet function type -func CCC_C03_TR04() (testSetName string, result pluginkit.TestSetResult) { - // set default return values - testSetName = "CCC_C03_TR04" - result = pluginkit.TestSetResult{ - Passed: false, - Description: "When an entity attempts to modify the service through an API endpoint, the authentication process MUST be limited to a specific allowed network.", - ControlID: "CCC.C03", - Tests: make(map[string]pluginkit.TestResult), - } - - result.ExecuteTest(CCC_C03_TR04_T01) - // TODO: Additional test calls go here - - return -} - -func CCC_C03_TR04_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ - Description: "This test is still under construction", - Function: utils.CallerPath(0), - } - - // TODO: Use this section to write a single step or test that contributes to CCC_C03_TR04 - return -} - - -// ----- -// TestSet and Tests for CCC_C03_TR05 -// ----- - -// CCC_C03_TR05 conforms to the TestSet function type -func CCC_C03_TR05() (testSetName string, result pluginkit.TestSetResult) { - // set default return values - testSetName = "CCC_C03_TR05" - result = pluginkit.TestSetResult{ - Passed: false, - Description: "When an entity attempts to view information on the service through an API endpoint, the authentication process MUST be limited to a specific allowed network.", - ControlID: "CCC.C03", - Tests: make(map[string]pluginkit.TestResult), - } - - result.ExecuteTest(CCC_C03_TR05_T01) - // TODO: Additional test calls go here - - return -} - -func CCC_C03_TR05_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ - Description: "This test is still under construction", - Function: utils.CallerPath(0), - } - - // TODO: Use this section to write a single step or test that contributes to CCC_C03_TR05 - return -} - - -// ----- -// TestSet and Tests for CCC_C03_TR06 -// ----- - -// CCC_C03_TR06 conforms to the TestSet function type -func CCC_C03_TR06() (testSetName string, result pluginkit.TestSetResult) { - // set default return values - testSetName = "CCC_C03_TR06" - result = pluginkit.TestSetResult{ - Passed: false, - Description: "When an entity attempts to modify the service through a user interface, the authentication process MUST require multiple identifying factors from the user.", - ControlID: "CCC.C03", - Tests: make(map[string]pluginkit.TestResult), - } - - result.ExecuteTest(CCC_C03_TR06_T01) - // TODO: Additional test calls go here - - return -} - -func CCC_C03_TR06_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ - Description: "This test is still under construction", - Function: utils.CallerPath(0), - } - - // TODO: Use this section to write a single step or test that contributes to CCC_C03_TR06 - return -} - - -// ----- -// TestSet and Tests for CCC_C04_TR01 -// ----- - -// CCC_C04_TR01 conforms to the TestSet function type -func CCC_C04_TR01() (testSetName string, result pluginkit.TestSetResult) { - // set default return values - testSetName = "CCC_C04_TR01" - result = pluginkit.TestSetResult{ - Passed: false, - Description: "When any access attempt is made to the service, the service MUST log the client identity, time, and result of the attempt.", - ControlID: "CCC.C04", - Tests: make(map[string]pluginkit.TestResult), - } - - result.ExecuteTest(CCC_C04_TR01_T01) - // TODO: Additional test calls go here - - return -} - -func CCC_C04_TR01_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ - Description: "This test is still under construction", - Function: utils.CallerPath(0), - } - - // TODO: Use this section to write a single step or test that contributes to CCC_C04_TR01 - return -} - - -// ----- -// TestSet and Tests for CCC_C04_TR02 -// ----- - -// CCC_C04_TR02 conforms to the TestSet function type -func CCC_C04_TR02() (testSetName string, result pluginkit.TestSetResult) { - // set default return values - testSetName = "CCC_C04_TR02" - result = pluginkit.TestSetResult{ - Passed: false, - Description: "When any change is made to the service configuration, the service MUST log the change, including the client, time, previous state, and the new state following the change.", - ControlID: "CCC.C04", - Tests: make(map[string]pluginkit.TestResult), - } - - result.ExecuteTest(CCC_C04_TR02_T01) - // TODO: Additional test calls go here - - return -} - -func CCC_C04_TR02_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ - Description: "This test is still under construction", - Function: utils.CallerPath(0), - } - - // TODO: Use this section to write a single step or test that contributes to CCC_C04_TR02 - return -} - - -// ----- -// TestSet and Tests for CCC_C05_TR01 -// ----- - -// CCC_C05_TR01 conforms to the TestSet function type -func CCC_C05_TR01() (testSetName string, result pluginkit.TestSetResult) { - // set default return values - testSetName = "CCC_C05_TR01" - result = pluginkit.TestSetResult{ - Passed: false, - Description: "When access to sensitive resources is attempted, the service MUST block requests from untrusted sources, including IP addresses, domains, or networks that are not explicitly included in a pre-approved allowlist.", - ControlID: "CCC.C05", - Tests: make(map[string]pluginkit.TestResult), - } - - result.ExecuteTest(CCC_C05_TR01_T01) - // TODO: Additional test calls go here - - return -} - -func CCC_C05_TR01_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ - Description: "This test is still under construction", - Function: utils.CallerPath(0), - } - - // TODO: Use this section to write a single step or test that contributes to CCC_C05_TR01 - return -} - - -// ----- -// TestSet and Tests for CCC_C05_TR02 -// ----- - -// CCC_C05_TR02 conforms to the TestSet function type -func CCC_C05_TR02() (testSetName string, result pluginkit.TestSetResult) { - // set default return values - testSetName = "CCC_C05_TR02" - result = pluginkit.TestSetResult{ - Passed: false, - Description: "When administrative access is attempted, the service MUST validate that the request originates from an explicitly allowed source as defined in the allowlist.", - ControlID: "CCC.C05", - Tests: make(map[string]pluginkit.TestResult), - } - - result.ExecuteTest(CCC_C05_TR02_T01) - // TODO: Additional test calls go here - - return -} - -func CCC_C05_TR02_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ - Description: "This test is still under construction", - Function: utils.CallerPath(0), - } - - // TODO: Use this section to write a single step or test that contributes to CCC_C05_TR02 - return -} - - -// ----- -// TestSet and Tests for CCC_C05_TR03 -// ----- - -// CCC_C05_TR03 conforms to the TestSet function type -func CCC_C05_TR03() (testSetName string, result pluginkit.TestSetResult) { - // set default return values - testSetName = "CCC_C05_TR03" - result = pluginkit.TestSetResult{ - Passed: false, - Description: "When resources are accessed in a multi-tenant environment, the service MUST enforce isolation by allowing access only to explicitly allowlisted tenants.", - ControlID: "CCC.C05", - Tests: make(map[string]pluginkit.TestResult), - } - - result.ExecuteTest(CCC_C05_TR03_T01) - // TODO: Additional test calls go here - - return -} - -func CCC_C05_TR03_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ - Description: "This test is still under construction", - Function: utils.CallerPath(0), - } - - // TODO: Use this section to write a single step or test that contributes to CCC_C05_TR03 - return -} - - -// ----- -// TestSet and Tests for CCC_C05_TR04 -// ----- - -// CCC_C05_TR04 conforms to the TestSet function type -func CCC_C05_TR04() (testSetName string, result pluginkit.TestSetResult) { - // set default return values - testSetName = "CCC_C05_TR04" - result = pluginkit.TestSetResult{ - Passed: false, - Description: "When an access attempt from an untrusted source is blocked, the service MUST log the event, including the source details, time, and reason for denial.", - ControlID: "CCC.C05", - Tests: make(map[string]pluginkit.TestResult), - } - - result.ExecuteTest(CCC_C05_TR04_T01) - // TODO: Additional test calls go here - - return -} - -func CCC_C05_TR04_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ - Description: "This test is still under construction", - Function: utils.CallerPath(0), - } - - // TODO: Use this section to write a single step or test that contributes to CCC_C05_TR04 - return -} - - // ----- -// TestSet and Tests for CCC_C06_TR01 +// TestSet and Tests for Requirement CCC_C06_TR01 // ----- // CCC_C06_TR01 conforms to the TestSet function type func CCC_C06_TR01() (testSetName string, result pluginkit.TestSetResult) { // set default return values - testSetName = "CCC_C06_TR01" + testSetName = "CCC.C06.TR01" result = pluginkit.TestSetResult{ - Passed: false, - Description: "When a deployment request is made, the service MUST validate that the deployment region is not to a restricted or regions or availability zones.", + Description: "When a deployment request is made, the service MUST validate that the deployment region is not to a restricted or regions or availability zones_", ControlID: "CCC.C06", Tests: make(map[string]pluginkit.TestResult), } @@ -506,8 +87,8 @@ func CCC_C06_TR01() (testSetName string, result pluginkit.TestSetResult) { return } -func CCC_C06_TR01_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ +func CCC_C06_TR01_T01() (testResult pluginkit.TestResult) { + testResult = pluginkit.TestResult{ Description: "This test is still under construction", Function: utils.CallerPath(0), } @@ -516,18 +97,16 @@ func CCC_C06_TR01_T01() (moveResult pluginkit.TestResult) { return } - // ----- -// TestSet and Tests for CCC_C06_TR02 +// TestSet and Tests for Requirement CCC_C06_TR02 // ----- // CCC_C06_TR02 conforms to the TestSet function type func CCC_C06_TR02() (testSetName string, result pluginkit.TestSetResult) { // set default return values - testSetName = "CCC_C06_TR02" + testSetName = "CCC.C06.TR02" result = pluginkit.TestSetResult{ - Passed: false, - Description: "When a deployment request is made, the service MUST validate that replication of data, backups, and disaster recovery operations will not occur in restricted regions or availability zones.", + Description: "When a deployment request is made, the service MUST validate that replication of data, backups, and disaster recovery operations will not occur in restricted regions or availability zones_", ControlID: "CCC.C06", Tests: make(map[string]pluginkit.TestResult), } @@ -538,8 +117,8 @@ func CCC_C06_TR02() (testSetName string, result pluginkit.TestSetResult) { return } -func CCC_C06_TR02_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ +func CCC_C06_TR02_T01() (testResult pluginkit.TestResult) { + testResult = pluginkit.TestResult{ Description: "This test is still under construction", Function: utils.CallerPath(0), } @@ -548,82 +127,16 @@ func CCC_C06_TR02_T01() (moveResult pluginkit.TestResult) { return } - -// ----- -// TestSet and Tests for CCC_C07_TR01 -// ----- - -// CCC_C07_TR01 conforms to the TestSet function type -func CCC_C07_TR01() (testSetName string, result pluginkit.TestSetResult) { - // set default return values - testSetName = "CCC_C07_TR01" - result = pluginkit.TestSetResult{ - Passed: false, - Description: "When suspicious enumeration activities are detected, the service MUST generate real-time alerts to notify security personnel.", - ControlID: "CCC.C07", - Tests: make(map[string]pluginkit.TestResult), - } - - result.ExecuteTest(CCC_C07_TR01_T01) - // TODO: Additional test calls go here - - return -} - -func CCC_C07_TR01_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ - Description: "This test is still under construction", - Function: utils.CallerPath(0), - } - - // TODO: Use this section to write a single step or test that contributes to CCC_C07_TR01 - return -} - - -// ----- -// TestSet and Tests for CCC_C07_TR02 -// ----- - -// CCC_C07_TR02 conforms to the TestSet function type -func CCC_C07_TR02() (testSetName string, result pluginkit.TestSetResult) { - // set default return values - testSetName = "CCC_C07_TR02" - result = pluginkit.TestSetResult{ - Passed: false, - Description: "When suspicious enumeration activities are detected, the service MUST log the event, including the source details, time, and nature of the activity.", - ControlID: "CCC.C07", - Tests: make(map[string]pluginkit.TestResult), - } - - result.ExecuteTest(CCC_C07_TR02_T01) - // TODO: Additional test calls go here - - return -} - -func CCC_C07_TR02_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ - Description: "This test is still under construction", - Function: utils.CallerPath(0), - } - - // TODO: Use this section to write a single step or test that contributes to CCC_C07_TR02 - return -} - - // ----- -// TestSet and Tests for CCC_C08_TR01 +// TestSet and Tests for Requirement CCC_C08_TR01 // ----- // CCC_C08_TR01 conforms to the TestSet function type func CCC_C08_TR01() (testSetName string, result pluginkit.TestSetResult) { // set default return values - testSetName = "CCC_C08_TR01" + testSetName = "CCC.C08.TR01" result = pluginkit.TestSetResult{ - Passed: false, - Description: "When data is stored, the service MUST ensure that data is replicated across multiple availability zones or regions.", + Description: "When data is stored, the service MUST ensure that data is replicated across multiple availability zones or regions_", ControlID: "CCC.C08", Tests: make(map[string]pluginkit.TestResult), } @@ -634,8 +147,8 @@ func CCC_C08_TR01() (testSetName string, result pluginkit.TestSetResult) { return } -func CCC_C08_TR01_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ +func CCC_C08_TR01_T01() (testResult pluginkit.TestResult) { + testResult = pluginkit.TestResult{ Description: "This test is still under construction", Function: utils.CallerPath(0), } @@ -644,18 +157,16 @@ func CCC_C08_TR01_T01() (moveResult pluginkit.TestResult) { return } - // ----- -// TestSet and Tests for CCC_C08_TR02 +// TestSet and Tests for Requirement CCC_C08_TR02 // ----- // CCC_C08_TR02 conforms to the TestSet function type func CCC_C08_TR02() (testSetName string, result pluginkit.TestSetResult) { // set default return values - testSetName = "CCC_C08_TR02" + testSetName = "CCC.C08.TR02" result = pluginkit.TestSetResult{ - Passed: false, - Description: "When data is replicated across multiple zones or regions, the service MUST be able to verify the replication state, including the replication locations and data synchronization status.", + Description: "When data is replicated across multiple zones or regions, the service MUST be able to verify the replication state, including the replication locations and data synchronization status_", ControlID: "CCC.C08", Tests: make(map[string]pluginkit.TestResult), } @@ -666,8 +177,8 @@ func CCC_C08_TR02() (testSetName string, result pluginkit.TestSetResult) { return } -func CCC_C08_TR02_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ +func CCC_C08_TR02_T01() (testResult pluginkit.TestResult) { + testResult = pluginkit.TestResult{ Description: "This test is still under construction", Function: utils.CallerPath(0), } @@ -676,18 +187,16 @@ func CCC_C08_TR02_T01() (moveResult pluginkit.TestResult) { return } - // ----- -// TestSet and Tests for CCC_C09_TR01 +// TestSet and Tests for Requirement CCC_C09_TR01 // ----- // CCC_C09_TR01 conforms to the TestSet function type func CCC_C09_TR01() (testSetName string, result pluginkit.TestSetResult) { // set default return values - testSetName = "CCC_C09_TR01" + testSetName = "CCC.C09.TR01" result = pluginkit.TestSetResult{ - Passed: false, - Description: "When access logs are stored, the service MUST ensure that access logs cannot be accessed without proper authorization.", + Description: "When access logs are stored, the service MUST ensure that access logs cannot be accessed without proper authorization_", ControlID: "CCC.C09", Tests: make(map[string]pluginkit.TestResult), } @@ -698,8 +207,8 @@ func CCC_C09_TR01() (testSetName string, result pluginkit.TestSetResult) { return } -func CCC_C09_TR01_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ +func CCC_C09_TR01_T01() (testResult pluginkit.TestResult) { + testResult = pluginkit.TestResult{ Description: "This test is still under construction", Function: utils.CallerPath(0), } @@ -708,18 +217,16 @@ func CCC_C09_TR01_T01() (moveResult pluginkit.TestResult) { return } - // ----- -// TestSet and Tests for CCC_C09_TR02 +// TestSet and Tests for Requirement CCC_C09_TR02 // ----- // CCC_C09_TR02 conforms to the TestSet function type func CCC_C09_TR02() (testSetName string, result pluginkit.TestSetResult) { // set default return values - testSetName = "CCC_C09_TR02" + testSetName = "CCC.C09.TR02" result = pluginkit.TestSetResult{ - Passed: false, - Description: "When access logs are stored, the service MUST ensure that access logs cannot be modified without proper authorization.", + Description: "When access logs are stored, the service MUST ensure that access logs cannot be modified without proper authorization_", ControlID: "CCC.C09", Tests: make(map[string]pluginkit.TestResult), } @@ -730,8 +237,8 @@ func CCC_C09_TR02() (testSetName string, result pluginkit.TestSetResult) { return } -func CCC_C09_TR02_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ +func CCC_C09_TR02_T01() (testResult pluginkit.TestResult) { + testResult = pluginkit.TestResult{ Description: "This test is still under construction", Function: utils.CallerPath(0), } @@ -740,18 +247,16 @@ func CCC_C09_TR02_T01() (moveResult pluginkit.TestResult) { return } - // ----- -// TestSet and Tests for CCC_C09_TR03 +// TestSet and Tests for Requirement CCC_C09_TR03 // ----- // CCC_C09_TR03 conforms to the TestSet function type func CCC_C09_TR03() (testSetName string, result pluginkit.TestSetResult) { // set default return values - testSetName = "CCC_C09_TR03" + testSetName = "CCC.C09.TR03" result = pluginkit.TestSetResult{ - Passed: false, - Description: "When access logs are stored, the service MUST ensure that access logs cannot be deleted without proper authorization.", + Description: "When access logs are stored, the service MUST ensure that access logs cannot be deleted without proper authorization_", ControlID: "CCC.C09", Tests: make(map[string]pluginkit.TestResult), } @@ -762,8 +267,8 @@ func CCC_C09_TR03() (testSetName string, result pluginkit.TestSetResult) { return } -func CCC_C09_TR03_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ +func CCC_C09_TR03_T01() (testResult pluginkit.TestResult) { + testResult = pluginkit.TestResult{ Description: "This test is still under construction", Function: utils.CallerPath(0), } @@ -772,18 +277,16 @@ func CCC_C09_TR03_T01() (moveResult pluginkit.TestResult) { return } - // ----- -// TestSet and Tests for CCC_C10_TR01 +// TestSet and Tests for Requirement CCC_C10_TR01 // ----- // CCC_C10_TR01 conforms to the TestSet function type func CCC_C10_TR01() (testSetName string, result pluginkit.TestSetResult) { // set default return values - testSetName = "CCC_C10_TR01" + testSetName = "CCC.C10.TR01" result = pluginkit.TestSetResult{ - Passed: false, - Description: "When data is replicated, the service MUST ensure that replication is restricted to explicitly trusted destinations.", + Description: "When data is replicated, the service MUST ensure that replication is restricted to explicitly trusted destinations_", ControlID: "CCC.C10", Tests: make(map[string]pluginkit.TestResult), } @@ -794,8 +297,8 @@ func CCC_C10_TR01() (testSetName string, result pluginkit.TestSetResult) { return } -func CCC_C10_TR01_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ +func CCC_C10_TR01_T01() (testResult pluginkit.TestResult) { + testResult = pluginkit.TestResult{ Description: "This test is still under construction", Function: utils.CallerPath(0), } @@ -803,260 +306,4 @@ func CCC_C10_TR01_T01() (moveResult pluginkit.TestResult) { // TODO: Use this section to write a single step or test that contributes to CCC_C10_TR01 return } - - -// ----- -// TestSet and Tests for CCC_C11_TR01 -// ----- - -// CCC_C11_TR01 conforms to the TestSet function type -func CCC_C11_TR01() (testSetName string, result pluginkit.TestSetResult) { - // set default return values - testSetName = "CCC_C11_TR01" - result = pluginkit.TestSetResult{ - Passed: false, - Description: "When encryption keys are used, the service MUST verify that all encryption keys use approved cryptographic algorithms as per organizational standards.", - ControlID: "CCC.C11", - Tests: make(map[string]pluginkit.TestResult), - } - - result.ExecuteTest(CCC_C11_TR01_T01) - // TODO: Additional test calls go here - - return -} - -func CCC_C11_TR01_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ - Description: "This test is still under construction", - Function: utils.CallerPath(0), - } - - // TODO: Use this section to write a single step or test that contributes to CCC_C11_TR01 - return -} - - -// ----- -// TestSet and Tests for CCC_C11_TR02 -// ----- - -// CCC_C11_TR02 conforms to the TestSet function type -func CCC_C11_TR02() (testSetName string, result pluginkit.TestSetResult) { - // set default return values - testSetName = "CCC_C11_TR02" - result = pluginkit.TestSetResult{ - Passed: false, - Description: "When encryption keys are used, the service MUST verify that encryption keys are rotated at a frequency compliant with organizational policies.", - ControlID: "CCC.C11", - Tests: make(map[string]pluginkit.TestResult), - } - - result.ExecuteTest(CCC_C11_TR02_T01) - // TODO: Additional test calls go here - - return -} - -func CCC_C11_TR02_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ - Description: "This test is still under construction", - Function: utils.CallerPath(0), - } - - // TODO: Use this section to write a single step or test that contributes to CCC_C11_TR02 - return -} - - -// ----- -// TestSet and Tests for CCC_C11_TR03 -// ----- - -// CCC_C11_TR03 conforms to the TestSet function type -func CCC_C11_TR03() (testSetName string, result pluginkit.TestSetResult) { - // set default return values - testSetName = "CCC_C11_TR03" - result = pluginkit.TestSetResult{ - Passed: false, - Description: "When encrypting data, the service MUST verify that customer-managed encryption keys (CMEKs) are used.", - ControlID: "CCC.C11", - Tests: make(map[string]pluginkit.TestResult), - } - - result.ExecuteTest(CCC_C11_TR03_T01) - // TODO: Additional test calls go here - - return -} - -func CCC_C11_TR03_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ - Description: "This test is still under construction", - Function: utils.CallerPath(0), - } - - // TODO: Use this section to write a single step or test that contributes to CCC_C11_TR03 - return -} - - -// ----- -// TestSet and Tests for CCC_C11_TR04 -// ----- - -// CCC_C11_TR04 conforms to the TestSet function type -func CCC_C11_TR04() (testSetName string, result pluginkit.TestSetResult) { - // set default return values - testSetName = "CCC_C11_TR04" - result = pluginkit.TestSetResult{ - Passed: false, - Description: "When encryption keys are accessed, the service MUST verify that access to encryption keys is restricted to authorized personnel and services, following the principle of least privilege.", - ControlID: "CCC.C11", - Tests: make(map[string]pluginkit.TestResult), - } - - result.ExecuteTest(CCC_C11_TR04_T01) - // TODO: Additional test calls go here - - return -} - -func CCC_C11_TR04_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ - Description: "This test is still under construction", - Function: utils.CallerPath(0), - } - - // TODO: Use this section to write a single step or test that contributes to CCC_C11_TR04 - return -} - - -// ----- -// TestSet and Tests for CCC_VPC_C01_TR01 -// ----- - -// CCC_VPC_C01_TR01 conforms to the TestSet function type -func CCC_VPC_C01_TR01() (testSetName string, result pluginkit.TestSetResult) { - // set default return values - testSetName = "CCC_VPC_C01_TR01" - result = pluginkit.TestSetResult{ - Passed: false, - Description: "When a subscription is created, the subscription MUST NOT contain default network resources.", - ControlID: "CCC.VPC.C01", - Tests: make(map[string]pluginkit.TestResult), - } - - result.ExecuteTest(CCC_VPC_C01_TR01_T01) - // TODO: Additional test calls go here - - return -} - -func CCC_VPC_C01_TR01_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ - Description: "This test is still under construction", - Function: utils.CallerPath(0), - } - - // TODO: Use this section to write a single step or test that contributes to CCC_VPC_C01_TR01 - return -} - - -// ----- -// TestSet and Tests for CCC_VPC_C02_TR01 -// ----- - -// CCC_VPC_C02_TR01 conforms to the TestSet function type -func CCC_VPC_C02_TR01() (testSetName string, result pluginkit.TestSetResult) { - // set default return values - testSetName = "CCC_VPC_C02_TR01" - result = pluginkit.TestSetResult{ - Passed: false, - Description: "When a resource is created in a public subnet, that resource MUST NOT be assigned an external IP address by default.", - ControlID: "CCC.VPC.C02", - Tests: make(map[string]pluginkit.TestResult), - } - - result.ExecuteTest(CCC_VPC_C02_TR01_T01) - // TODO: Additional test calls go here - - return -} - -func CCC_VPC_C02_TR01_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ - Description: "This test is still under construction", - Function: utils.CallerPath(0), - } - - // TODO: Use this section to write a single step or test that contributes to CCC_VPC_C02_TR01 - return -} - - -// ----- -// TestSet and Tests for CCC_VPC_C03_TR01 -// ----- - -// CCC_VPC_C03_TR01 conforms to the TestSet function type -func CCC_VPC_C03_TR01() (testSetName string, result pluginkit.TestSetResult) { - // set default return values - testSetName = "CCC_VPC_C03_TR01" - result = pluginkit.TestSetResult{ - Passed: false, - Description: "When a VPC peering connection is requested, the service MUST prevent connections from VPCs that are not explicitly allowed.", - ControlID: "CCC.VPC.C03", - Tests: make(map[string]pluginkit.TestResult), - } - - result.ExecuteTest(CCC_VPC_C03_TR01_T01) - // TODO: Additional test calls go here - - return -} - -func CCC_VPC_C03_TR01_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ - Description: "This test is still under construction", - Function: utils.CallerPath(0), - } - - // TODO: Use this section to write a single step or test that contributes to CCC_VPC_C03_TR01 - return -} - - -// ----- -// TestSet and Tests for CCC_VPC_C04_TR01 -// ----- - -// CCC_VPC_C04_TR01 conforms to the TestSet function type -func CCC_VPC_C04_TR01() (testSetName string, result pluginkit.TestSetResult) { - // set default return values - testSetName = "CCC_VPC_C04_TR01" - result = pluginkit.TestSetResult{ - Passed: false, - Description: "When any network traffic goes to or from an interface in the VPC, the service MUST capture and log all relevant information.", - ControlID: "CCC.VPC.C04", - Tests: make(map[string]pluginkit.TestResult), - } - - result.ExecuteTest(CCC_VPC_C04_TR01_T01) - // TODO: Additional test calls go here - - return -} - -func CCC_VPC_C04_TR01_T01() (moveResult pluginkit.TestResult) { - moveResult = pluginkit.TestResult{ - Description: "This test is still under construction", - Function: utils.CallerPath(0), - } - - // TODO: Use this section to write a single step or test that contributes to CCC_VPC_C04_TR01 - return -} - + diff --git a/cmd/debug.go b/cmd/debug.go deleted file mode 100644 index 5684941..0000000 --- a/cmd/debug.go +++ /dev/null @@ -1,25 +0,0 @@ -package cmd - -import ( - "log" - - "github.com/spf13/cobra" -) - -var ( - // debugCmd represents the base command when called without any subcommands - debugCmd = &cobra.Command{ - Use: "debug", - Short: "Run the Plugin in debug mode", - Run: func(cmd *cobra.Command, args []string) { - err := Vessel.Mobilize() // Replace nil with a slice of your required var names - if err != nil { - log.Fatal(err) - } - }, - } -) - -func init() { - runCmd.AddCommand(debugCmd) // This enables the debug command for use while working on your Plugin -} diff --git a/cmd/plugin.go b/cmd/plugin.go deleted file mode 100644 index ccefe25..0000000 --- a/cmd/plugin.go +++ /dev/null @@ -1,22 +0,0 @@ -package cmd - -import ( - "github.com/privateerproj/privateer-plugin-example/armory" - - "github.com/privateerproj/privateer-sdk/pluginkit" -) - -var ( - Vessel = pluginkit.Vessel{ - PluginName: "example", // Double check that this is what you want the plugin to be named - Armory: &armory.Armory, - } // Used by the plugin or debug function to run the Plugin -) - -type Plugin struct {} - -// Plugin.Start() is called by plugin.Serve -func (p *Plugin) Start() (err error) { - err = Vessel.Mobilize() - return -} diff --git a/cmd/root.go b/cmd/root.go deleted file mode 100644 index 7bd5dd4..0000000 --- a/cmd/root.go +++ /dev/null @@ -1,55 +0,0 @@ -package cmd - -import ( - "fmt" - "os" - - "github.com/spf13/cobra" - - "github.com/privateerproj/privateer-sdk/command" - "github.com/privateerproj/privateer-sdk/shared" -) - -var ( - // Build information is added by the Makefile at compile time - buildVersion string - buildGitCommitHash string - buildTime string - - PluginName = "example" - - // runCmd represents the base command when called without any subcommands - runCmd = &cobra.Command{ - Use: PluginName, - Short: fmt.Sprintf("Test suite for %s.", PluginName), - PersistentPreRun: func(cmd *cobra.Command, args []string) { - // optional - }, - Run: func(cmd *cobra.Command, args []string) { - // Serve plugin - plugin := &Plugin{} - serveOpts := &shared.ServeOpts{ - Plugin: plugin, - } - - shared.Serve(PluginName, serveOpts) - }, - } -) - -// Execute adds all child commands to the root command and sets flags appropriately. -// This is called by main.main(). It only needs to happen once to the runCmd. -func Execute(version, commitHash, builtAt string) { - buildVersion = version - buildGitCommitHash = commitHash - buildTime = builtAt - - err := runCmd.Execute() - if err != nil { - os.Exit(1) - } -} - -func init() { - command.SetBase(runCmd) // This initializes the base CLI functionality -} diff --git a/cmd/version.go b/cmd/version.go deleted file mode 100644 index 624c19c..0000000 --- a/cmd/version.go +++ /dev/null @@ -1,31 +0,0 @@ -package cmd - -import ( - "fmt" - "os" - "text/tabwriter" - - "github.com/spf13/cobra" - "github.com/spf13/viper" -) - -// versionCmd represents the version command -var versionCmd = &cobra.Command{ - Use: "version", - Short: "Display version details.", - Run: func(cmd *cobra.Command, args []string) { - writer := tabwriter.NewWriter(os.Stdout, 1, 1, 1, ' ', 0) - if viper.GetBool("verbose") { - fmt.Fprintf(writer, "Version:\t%s\n", buildVersion) - fmt.Fprintf(writer, "Commit:\t%s\n", buildGitCommitHash) - fmt.Fprintf(writer, "Build Time:\t%s\n", buildTime) - writer.Flush() - } else { - fmt.Println(buildVersion) - } - }, -} - -func init() { - runCmd.AddCommand(versionCmd) -} diff --git a/example-config.yml b/example-config.yml index 3af13a4..05b211c 100644 --- a/example-config.yml +++ b/example-config.yml @@ -1,8 +1,10 @@ loglevel: Debug write-directory: test_output +write: true +output: yaml services: my-cloud-service1: - plugin: example + plugin: example-plugin test-suites: - tlp_red # - tlp_amber diff --git a/go.mod b/go.mod index 1d534eb..6b10653 100644 --- a/go.mod +++ b/go.mod @@ -1,19 +1,15 @@ -module github.com/privateerproj/privateer-plugin-example +module github.com/privateerproj/privateer-plugin-example-plugin // Replace this globally with your module name go 1.23 -require ( - github.com/privateerproj/privateer-sdk v0.0.17 - github.com/spf13/cobra v1.8.1 - github.com/spf13/viper v1.19.0 -) +require github.com/privateerproj/privateer-sdk v0.7.0 require ( github.com/fatih/color v1.14.1 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/hashicorp/go-hclog v1.6.3 // indirect - github.com/hashicorp/go-plugin v1.6.2 // indirect + github.com/hashicorp/go-plugin v1.6.3 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect @@ -28,17 +24,19 @@ require ( github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect - github.com/spf13/pflag v1.0.5 // indirect + github.com/spf13/cobra v1.9.1 // indirect + github.com/spf13/pflag v1.0.6 // indirect + github.com/spf13/viper v1.19.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.9.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect - golang.org/x/net v0.23.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/net v0.34.0 // indirect + golang.org/x/sys v0.29.0 // indirect + golang.org/x/text v0.21.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c // indirect google.golang.org/grpc v1.62.1 // indirect - google.golang.org/protobuf v1.33.0 // indirect + google.golang.org/protobuf v1.36.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index f15d7c6..8b1ca74 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,6 @@ github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= -github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= @@ -20,8 +20,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= -github.com/hashicorp/go-plugin v1.6.2 h1:zdGAEd0V1lCaU0u+MxWQhtSDQmahpkwOun8U8EiRVog= -github.com/hashicorp/go-plugin v1.6.2/go.mod h1:CkgLQ5CZqNmdL9U9JzM532t8ZiYQ35+pj3b1FD37R0Q= +github.com/hashicorp/go-plugin v1.6.3 h1:xgHB+ZUSYeuJi96WtxEjzi23uh7YQpznjGh0U0UUrwg= +github.com/hashicorp/go-plugin v1.6.3/go.mod h1:MRobyh+Wc/nYy1V4KAXUiYfzxoYhs7V1mlH1Z7iY2h0= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= @@ -54,8 +54,8 @@ github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/privateerproj/privateer-sdk v0.0.17 h1:buTquGwlM3+lLggiaWUsOOxlPpNaYOYFv3R39HWN2ss= -github.com/privateerproj/privateer-sdk v0.0.17/go.mod h1:XC29QRTD3NqSVDby1wIVcd3rer5lFFn9I/8Px0xPsrs= +github.com/privateerproj/privateer-sdk v0.7.0 h1:8Kdf8i+4TplU4jN2jIy7Y+SigAKMqvU6oahcy56S5o4= +github.com/privateerproj/privateer-sdk v0.7.0/go.mod h1:SqFAkYGvTIf9ZNJpWw/PSbC5fvTZoEWGeO6jPUdx3Oo= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -69,10 +69,10 @@ github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= -github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= -github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo= +github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0= +github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= +github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -94,18 +94,18 @@ go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= +golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= +golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c h1:lfpJ/2rWPa/kJgxyyXM8PrNnfCzcmxJ265mADgwmvLI= google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= @@ -113,8 +113,8 @@ google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk= +google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/main.go b/main.go index 3246828..eb59847 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,12 @@ package main import ( "fmt" - "github.com/privateerproj/privateer-plugin-example/cmd" + "os" + + "github.com/privateerproj/privateer-plugin-example-plugin/armory" + + "github.com/privateerproj/privateer-sdk/command" + "github.com/privateerproj/privateer-sdk/config" ) var ( @@ -15,11 +20,38 @@ var ( GitCommitHash = "" // BuiltAt is the actual build datetime BuiltAt = "" + + PluginName = "example-plugin" + RequiredVars = []string{ + "your", + "required", + "variables", + } + + runCmd = command.NewPluginCommands( + PluginName, + Version, + VersionPostfix, + GitCommitHash, + &armory.Armory, + initializer, + RequiredVars, + ) ) +// initializer is a custom function to run after the config has been read +// this could be omitted or replaced by something like armory.SetupArmory(c) +func initializer(c *config.Config) (err error) { + return +} + func main() { if VersionPostfix != "" { Version = fmt.Sprintf("%s-%s", Version, VersionPostfix) } - cmd.Execute(Version, GitCommitHash, BuiltAt) + + err := runCmd.Execute() + if err != nil { + os.Exit(1) + } }