Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for azure active directory activity log #1680

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion cli/cmd/generate_azure.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package cmd

import (
"github.com/AlecAivazis/survey/v2"
"strconv"
"strings"
"time"

"github.com/AlecAivazis/survey/v2"
"github.com/imdario/mergo"
"github.com/spf13/cobra"

Expand Down Expand Up @@ -190,6 +190,7 @@ the new cloud account. In interactive mode, this command will:
azure.WithStorageAccountName(GenerateAzureCommandState.StorageAccountName),
azure.WithStorageLocation(GenerateAzureCommandState.StorageLocation),
azure.WithActivityLogIntegrationName(GenerateAzureCommandState.ActivityLogIntegrationName),
azure.WithActiveDirectoryActivityLogIntegrationName(GenerateAzureCommandState.ActiveDirectoryActivityLogIntegrationName),
azure.WithConfigIntegrationName(GenerateAzureCommandState.ConfigIntegrationName),
azure.WithEntraIdActivityLogIntegrationName(GenerateAzureCommandState.EntraIdIntegrationName),
azure.WithEventHubLocation(GenerateAzureCommandState.EventHubLocation),
Expand Down Expand Up @@ -225,6 +226,7 @@ the new cloud account. In interactive mode, this command will:
data := azure.NewTerraform(
GenerateAzureCommandState.Config,
GenerateAzureCommandState.ActivityLog,
GenerateAzureCommandState.ActiveDirectoryActivityLog,
GenerateAzureCommandState.EntraIdActivityLog,
GenerateAzureCommandState.CreateAdIntegration,
mods...)
Expand Down Expand Up @@ -373,12 +375,24 @@ func initGenerateAzureTfCommandFlags() {
false,
"enable activity log integration")

generateAzureTfCommand.PersistentFlags().BoolVar(
&GenerateAzureCommandState.ActiveDirectoryActivityLog,
"active_directory_activity_log",
false,
"enable active directory activity log integration")

generateAzureTfCommand.PersistentFlags().StringVar(
&GenerateAzureCommandState.ActivityLogIntegrationName,
"activity_log_integration_name",
"",
"specify a custom activity log integration name")

generateAzureTfCommand.PersistentFlags().StringVar(
&GenerateAzureCommandState.ActiveDirectoryActivityLogIntegrationName,
"active_directory_activity_log_integration_name",
"",
"specify a custom active directory activity log integration name")

generateAzureTfCommand.PersistentFlags().BoolVar(
&GenerateAzureCommandState.EntraIdActivityLog,
"entra_id_activity_log",
Expand Down
25 changes: 20 additions & 5 deletions lwgenerate/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ type GenerateAzureTfConfigurationArgs struct {
// Should we configure Activity Log integration in LW?
ActivityLog bool

// Should we configure Active Directory Activity Log in LW?
ActiveDirectoryActivityLog bool

// Should we add Config integration in LW?
Config bool

Expand All @@ -26,6 +29,10 @@ type GenerateAzureTfConfigurationArgs struct {
// If ActivityLog is true, give the user the opportunity to name their integration. Defaults to "TF activity log"
ActivityLogIntegrationName string

// If ActiveDirectoryActivityLog is true, give the user the opportunity to name their integration. Defaults to
// "TF active directory activity log"
ActiveDirectoryActivityLogIntegrationName string

// If EntraIdIntegration is true, give the user the opportunity to name their integration.
// Defaults to "TF Entra ID activity log"
EntraIdIntegrationName string
Expand Down Expand Up @@ -123,14 +130,15 @@ type AzureTerraformModifier func(c *GenerateAzureTfConfigurationArgs)
//
// Note: Additional configuration details may be set using modifiers of the AzureTerraformModifier type
func NewTerraform(
enableConfig bool, enableActivityLog bool, enableEntraIdActivityLog, createAdIntegration bool,
enableConfig bool, enableActivityLog bool, enableActiveDirectoryActivityLog bool, enableEntraIdActivityLog, createAdIntegration bool,
mods ...AzureTerraformModifier,
) *GenerateAzureTfConfigurationArgs {
config := &GenerateAzureTfConfigurationArgs{
ActivityLog: enableActivityLog,
Config: enableConfig,
EntraIdActivityLog: enableEntraIdActivityLog,
CreateAdIntegration: createAdIntegration,
ActivityLog: enableActivityLog,
ActiveDirectoryActivityLog: enableActiveDirectoryActivityLog,
Config: enableConfig,
EntraIdActivityLog: enableEntraIdActivityLog,
CreateAdIntegration: createAdIntegration,
}
for _, m := range mods {
m(config)
Expand Down Expand Up @@ -190,6 +198,13 @@ func WithActivityLogIntegrationName(name string) AzureTerraformModifier {
}
}

// WithActivityLogIntegrationName Set the Activity Log Integration name to be displayed on the Lacework UI
func WithActiveDirectoryActivityLogIntegrationName(name string) AzureTerraformModifier {
return func(c *GenerateAzureTfConfigurationArgs) {
c.ActiveDirectoryActivityLogIntegrationName = name
}
}

// WithEntraIdActivityLogIntegrationName Set the Entra ID Activity Log Integration name
// to be displayed on the Lacework UI
func WithEntraIdActivityLogIntegrationName(name string) AzureTerraformModifier {
Expand Down
Loading