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 List Azure Tenants command #341

Merged
merged 4 commits into from
Mar 17, 2021
Merged

Conversation

dmurray-lacework
Copy link
Collaborator

@dmurray-lacework dmurray-lacework commented Mar 16, 2021

Add new command to list Azure Tenants
Usage:
$ lacework compliance azure list-tenants

Output:

                TENANTS
----------------------------------------
  1aa11111-aa11-111a-1111-aaa11111aa11

Signed-off-by: Darren Murray [email protected]

Long: `List all Azure Tenants.`,
Args: cobra.NoArgs,
RunE: func(_ *cobra.Command, _ []string) error {
response, err := cli.LwApi.Compliance.ListAzureTenants()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting way to do this but, I'm afraid it doesn't follow the standard we put in compliance for AWS. Also, we are creating "an API that doesn't exist in the platform itself" and that goes against the principle to match 100% the Lacework API. I think we should add this functionality to the CLI alone, just like the command to list AWS accounts.

Copy link
Contributor

@afiune afiune left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to check the size of the Data field, check how we did it in AWS config. Lets print a message for a user to know what to do to add new integrations.

}

if cli.JSONOutput() {
return cli.OutputJSON(response.Data[0])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If an account doesn't have any Azure CFG integrations, we will panic here!

lacework comp az list --json -p mini
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/lacework/go-sdk/cli/cmd.glob..func8(0x1d49f80, 0xc0004fcf60, 0x0, 0x3, 0x0, 0x0)
	/Users/salimmaya/go/src/github.com/lacework/go-sdk/cli/cmd/compliance_azure.go:85 +0x48f
github.com/spf13/cobra.(*Command).execute(0x1d49f80, 0xc0004fcf30, 0x3, 0x3, 0x1d49f80, 0xc0004fcf30)
	/Users/salimmaya/go/src/github.com/lacework/go-sdk/vendor/github.com/spf13/cobra/command.go:842 +0x47c
github.com/spf13/cobra.(*Command).ExecuteC(0x1d4cc20, 0x16529cc, 0xc000607700, 0x1d58b22)
	/Users/salimmaya/go/src/github.com/lacework/go-sdk/vendor/github.com/spf13/cobra/command.go:950 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/salimmaya/go/src/github.com/lacework/go-sdk/vendor/github.com/spf13/cobra/command.go:887
github.com/lacework/go-sdk/cli/cmd.Execute(0x0, 0x0)
	/Users/salimmaya/go/src/github.com/lacework/go-sdk/cli/cmd/root.go:100 +0x85
main.main()
	/Users/salimmaya/go/src/github.com/lacework/go-sdk/cli/main.go:29 +0x26

@afiune afiune force-pushed the dmurray-lacework/az-tenants branch from 785bbd5 to 515ad42 Compare March 17, 2021 21:08
@afiune afiune self-requested a review March 17, 2021 23:02
Copy link
Contributor

@afiune afiune left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tenor-178953346

@afiune afiune merged commit 960a8b7 into main Mar 17, 2021
@afiune afiune deleted the dmurray-lacework/az-tenants branch March 17, 2021 23:12
@afiune afiune mentioned this pull request Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants