Skip to content

Commit

Permalink
feat: rename some things (#50)
Browse files Browse the repository at this point in the history
- [x] sally -> run
- [x] raid -> plugin

Signed-off-by: jmeridth <[email protected]>
  • Loading branch information
jmeridth authored Dec 23, 2024
1 parent b60480b commit 5adde6a
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 1,528 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ dist/

test_output

**/generated-raid
**/generated-plugin
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

Privateer has been meticulously crafted with infrastructure engineers in mind. If you're seeking to validate your resources against regulations, taxonomies, or standards, Privateer is your trusted companion. With a user-friendly interface and powerful features, you can now effortlessly navigate the complexities of resource validation.

## Using Privateer Raids
## Using Privateer Plugins

There are several key benefits to Privateer Raids:
There are several key benefits to Privateer Plugins:

- **Community-Driven Raids:** Our open development model ensures that Raids are crafted and maintained collaboratively by the community, reflecting a wealth of expertise and insights.
- **Community-Driven Plugins:** Our open development model ensures that Plugins are crafted and maintained collaboratively by the community, reflecting a wealth of expertise and insights.
- **Comprehensive Resource Validation:** Privateer empowers you to validate a diverse array of resources in a single execution. No more piecemeal validation processes; instead, experience efficiency and thoroughness in one go.
- **Consistent Machine-Readable Output:** Regardless of the specific Raid, you're guaranteed a standardized, machine-readable test output. This consistency simplifies the automation and integration of test results, enabling seamless decision-making.
- **Empowering Service Providers:** Privateer finds its calling in projects like Compliant Financial Infrastructure and Common Cloud Controls within FINOS. Service providers can leverage Privateer Raids developed by FINOS to certify resources for use in regulated industries, such as insurance and banking.
- **Consistent Machine-Readable Output:** Regardless of the specific Plugin, you're guaranteed a standardized, machine-readable test output. This consistency simplifies the automation and integration of test results, enabling seamless decision-making.
- **Empowering Service Providers:** Privateer finds its calling in projects like Compliant Financial Infrastructure and Common Cloud Controls within FINOS. Service providers can leverage Privateer Plugins developed by FINOS to certify resources for use in regulated industries, such as insurance and banking.

## Install the Privateer CLI

Expand Down Expand Up @@ -52,18 +52,18 @@ To build privateer from source, follow these steps below:
make release
```

## Install Privateer Raids
## Install Privateer Plugins

Raids are built and maintained by the community. Choose the raid(s) that you wish to run, and install them to your binaries path.
Plugins are built and maintained by the community. Choose the plugin(s) that you wish to run, and install them to your binaries path.

- **Default Path:** $HOME/.privateer/bin
- **Customize via CLI:** Use `--binaries-path` in your CLI command to change the path to your binaries.
- **Customize via config:** Specify a custom binaries path in your config via the top level value `binaries-path: your/bin/path`

## Configuration

1. **Create a Configuration File**: Craft a configuration file (e.g., `config.yml`) that specifies the raids you intend to run and any necessary configuration options. Include secrets and settings required by the raid. Refer to the specific raid's documentation for precise details.
1. **Output Directory (Optional)**: If desired, define an output directory in your configuration. Privateer will generate log and result files for each raid in this directory. Results files are available in both JSON and YAML formats.
1. **Create a Configuration File**: Craft a configuration file (e.g., `config.yml`) that specifies the plugins you intend to run and any necessary configuration options. Include secrets and settings required by the plugin. Refer to the specific plugin's documentation for precise details.
1. **Output Directory (Optional)**: If desired, define an output directory in your configuration. Privateer will generate log and result files for each plugin in this directory. Results files are available in both JSON and YAML formats.
1. **Advanced Config Management**: Privateer's roadmap includes plans for integrating with systems like etcd and Consul to enhance configuration and secret management.

> [!NOTE]
Expand All @@ -89,17 +89,17 @@ services:
Here are some common commands you can use with Privateer:

- `-h` / `--help`: Display help information about Privateer and its commands.
- `sally`: Execute the specified raid(s).
- `generate-raid`: Automatically create the code for a raid based on a FINOS Common Cloud Controls catalog.
- `list`: Show raids requested by your configuration and whether they're installed.
- `list -a`: Show all raids you have installed.
- `run`: Execute the specified plugin(s).
- `generate-plugin`: Automatically create the code for a plugin based on a FINOS Common Cloud Controls catalog.
- `list`: Show plugins requested by your configuration and whether they're installed.
- `list -a`: Show all plugins you have installed.
## Output Customization
Privateer generates logs and results files for each raid. The output location may be specified by `-o` / `--output-dir`.
Privateer generates logs and results files for each plugin. The output location may be specified by `-o` / `--output-dir`.
- **Log Results**:` <output_dir>/<raid_name>/<raid_name>.log`
- **Raid Results**: `<output_dir>/<raid_name>/results.yaml`
- **Log Results**:` <output_dir>/<plugin_name>/<plugin_name>.log`
- **Plugin Results**: `<output_dir>/<plugin_name>/results.yaml`
- **Default Value**: `$HOME/privateer/output`
### Tailoring Verbosity
Expand Down
6 changes: 3 additions & 3 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ This roadmap should be moved into a GitHub Project before v0.3.
### Feature Improvements

- [x] remove redundancy of plugin name statements
- [x] Create a sample close handler on the raid wireframe
- [x] Create a sample close handler on the plugin wireframe

### Bugfixes

- [x] unnecessary error message when no config was supplied (skipping the config file may be intentional, or maybe not)
- [x] config wasn't being used in raid
- [x] config wasn't being used in plugin
- [x] Corrected -v usage and removed any instance of `log` in favor of `logger`. Basic `log` should not be used due to persistent unexpected behavior.
- [x] default loglevel is now error

Expand All @@ -45,7 +45,7 @@ This roadmap should be moved into a GitHub Project before v0.3.
- user friendly by default
- Improve machine output
- trim the fat
- Handle errors better for unknown sally raids
- Handle errors better for unknown run plugins
- Increase test coverage

### Bugfixes
Expand Down
183 changes: 0 additions & 183 deletions cmd/approved-raids.go

This file was deleted.

48 changes: 24 additions & 24 deletions cmd/generate-raid.go → cmd/generate-plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
type ControlCatalog struct {
CategoryIDFriendly string
ServiceName string
Tactics map[string][]string
TestSuites map[string][]string

Metadata Metadata `yaml:"metadata"`

Expand Down Expand Up @@ -93,29 +93,29 @@ var SourcePath string
var OutputDir string

// versionCmd represents the version command
var genRaidCmd = &cobra.Command{
Use: "generate-raid",
Short: "Generate a new raid",
var genPluginCmd = &cobra.Command{
Use: "generate-plugin",
Short: "Generate a new plugin",
Run: func(cmd *cobra.Command, args []string) {
generateRaid()
generatePlugin()
},
}

func init() {
rootCmd.AddCommand(genRaidCmd)
rootCmd.AddCommand(genPluginCmd)

genRaidCmd.PersistentFlags().StringP("source-path", "p", "", "The source file to generate the raid from.")
genRaidCmd.PersistentFlags().StringP("local-templates", "", "", "Path to a directory to use instead of downloading the latest templates.")
genRaidCmd.PersistentFlags().StringP("service-name", "n", "", "The name of the service (e.g. 'ECS, AKS, GCS').")
genRaidCmd.PersistentFlags().StringP("output-dir", "o", "generated-raid/", "Pathname for the generated raid.")
genPluginCmd.PersistentFlags().StringP("source-path", "p", "", "The source file to generate the plugin from.")
genPluginCmd.PersistentFlags().StringP("local-templates", "", "", "Path to a directory to use instead of downloading the latest templates.")
genPluginCmd.PersistentFlags().StringP("service-name", "n", "", "The name of the service (e.g. 'ECS, AKS, GCS').")
genPluginCmd.PersistentFlags().StringP("output-dir", "o", "generated-plugin/", "Pathname for the generated plugin.")

viper.BindPFlag("source-path", genRaidCmd.PersistentFlags().Lookup("source-path"))
viper.BindPFlag("local-templates", genRaidCmd.PersistentFlags().Lookup("local-templates"))
viper.BindPFlag("service-name", genRaidCmd.PersistentFlags().Lookup("service-name"))
viper.BindPFlag("output-dir", genRaidCmd.PersistentFlags().Lookup("output-dir"))
viper.BindPFlag("source-path", genPluginCmd.PersistentFlags().Lookup("source-path"))
viper.BindPFlag("local-templates", genPluginCmd.PersistentFlags().Lookup("local-templates"))
viper.BindPFlag("service-name", genPluginCmd.PersistentFlags().Lookup("service-name"))
viper.BindPFlag("output-dir", genPluginCmd.PersistentFlags().Lookup("output-dir"))
}

func generateRaid() {
func generatePlugin() {
err := setupTemplatingEnvironment()
if err != nil {
logger.Error(err.Error())
Expand All @@ -128,7 +128,7 @@ func generateRaid() {
}
data.ServiceName = viper.GetString("service-name")
if data.ServiceName == "" {
logger.Error("--service-name is required to generate a raid.")
logger.Error("--service-name is required to generate a plugin.")
return
}

Expand Down Expand Up @@ -156,7 +156,7 @@ func generateRaid() {
func setupTemplatingEnvironment() error {
SourcePath = viper.GetString("source-path")
if SourcePath == "" {
return fmt.Errorf("--source-path is required to generate a raid from a control set from local file or URL")
return fmt.Errorf("--source-path is required to generate a plugin from a control set from local file or URL")
}

if viper.GetString("local-templates") != "" {
Expand All @@ -167,7 +167,7 @@ func setupTemplatingEnvironment() error {
}

OutputDir = viper.GetString("output-dir")
logger.Trace(fmt.Sprintf("Generated raid will be stored in this directory: %s", OutputDir))
logger.Trace(fmt.Sprintf("Generated plugin will be stored in this directory: %s", OutputDir))

return os.MkdirAll(OutputDir, os.ModePerm)
}
Expand All @@ -183,7 +183,7 @@ func setupTemplatesDir() error {
// Pull latest templates from git
logger.Trace(fmt.Sprintf("Cloning templates repo to: %s", TemplatesDir))
_, err = git.PlainClone(TemplatesDir, false, &git.CloneOptions{
URL: "https://github.com/privateerproj/raid-generator-templates.git",
URL: "https://github.com/privateerproj/plugin-generator-templates.git",
Progress: os.Stdout,
})
return err
Expand Down Expand Up @@ -229,7 +229,7 @@ func readData() (data ControlCatalog, err error) {
return
}

data.Tactics = make(map[string][]string)
data.TestSuites = make(map[string][]string)
data.CategoryIDFriendly = strings.ReplaceAll(data.Metadata.ID, ".", "_")

for i := range data.Controls {
Expand All @@ -242,12 +242,12 @@ func readData() (data ControlCatalog, err error) {
// Replace periods with underscores for the friendly ID
data.Controls[i].TestRequirements[j].IDFriendly = strings.ReplaceAll(testReq.ID, ".", "_")

// Add the test ID to the tactics map for each TLP level
// Add the test ID to the TestSuites map for each TLP level
for _, tlpLevel := range testReq.TLPLevels {
if data.Tactics[tlpLevel] == nil {
data.Tactics[tlpLevel] = []string{}
if data.TestSuites[tlpLevel] == nil {
data.TestSuites[tlpLevel] = []string{}
}
data.Tactics[tlpLevel] = append(data.Tactics[tlpLevel], strings.ReplaceAll(testReq.ID, ".", "_"))
data.TestSuites[tlpLevel] = append(data.TestSuites[tlpLevel], strings.ReplaceAll(testReq.ID, ".", "_"))
}
}
}
Expand Down
Loading

0 comments on commit 5adde6a

Please sign in to comment.