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

Cloudfox GCP Functionality #79

Merged
merged 6 commits into from
Apr 12, 2024
Merged

Cloudfox GCP Functionality #79

merged 6 commits into from
Apr 12, 2024

Conversation

dbravo-bishopfox
Copy link
Contributor

Card

This PR adds functionality to cloudfox to support resources in GCP projects. The currently supported resources are artifact registry, bigquery tables and datasets, cloud storage buckets, iam policy bindings, compute engine instances, and secrets.

Details

The code related to each cobra command is in its own file in gcp/commands/. In each of those files there is high level logic to parse command line arguments, call appropriate services that return a GCP resource data structure, and output or present the information using internal/output2.go. Each command file also houses the logic related to defining the CSV / JSON headers, content, and file names based on the data structure returned by service(s).

The code related to retrieving the resource information from the GCP API and structuring them in a custom struct, is in gcp/services/. There each service is named after a given resource type in GCP and attempts to exports few functions that will return data structures ready to be "outputted" by commands.

In addition to adding functionality to support the new resources, a new HandleOutput function was added to the internal/output2.go file that is a flexible way to WriteFullOutput for any command that wants to write to std out or in a file.

New functionality in the internal/log.go was also added from @bishopfaure gcp branch. We plan to coordinate on integrating his code into upcoming functionality for GCP related workflows.

Some strings were added in globals/gcp.go and globals/utils.go to facilitate their use throughout the tool.

@dbravo-bishopfox
Copy link
Contributor Author

I added a whomai command and supporting service to facilitate knowing which account is being used to authenticate to the projects when using cloudfox gcp. Also fixed the bug where the logic that sets the projectIDs for gcp was being run on all the AWS & Azure commands

@@ -173,7 +218,8 @@ func (l *LootClient) writeLootFiles() []string {
for _, file := range l.LootFiles {
contents := []byte(file.Contents)
fullPath := path.Join(l.DirectoryName, "loot", file.Name)
err := afero.WriteFile(fileSystem, fullPath, contents, 0644) // Use Afero's WriteFile

err := os.WriteFile(fullPath, contents, 0644)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sethsec-bf should this be using afero package?

@sethsec-bf
Copy link
Contributor

Amazing work @dbravo-bishopfox, thanks for pushing this!

@dbravo-bishopfox dbravo-bishopfox merged commit 8e94b3c into main Apr 12, 2024
1 check passed
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