google / gcp_scanner

A comprehensive scanner for Google Cloud
Apache License 2.0
311 stars 97 forks source link

Add GCS bucket root folder into the output #23

Closed mshudrak closed 1 year ago

mshudrak commented 1 year ago

We currently don't include GCS bucket root folder in the report which makes it hard to follow and identify sensitive buckets. We need to include them too.

sudiptob2 commented 1 year ago

interested in this issue, could you please assign it to me?

mshudrak commented 1 year ago

We have a lot of interest from other members of community. So, I will drop assignees for all bugs, so anyone can work on them.

sudiptob2 commented 1 year ago

Agreed. I also think that's better because when you assign someone it gets kind of restricted. Anyone interested should open a PR (draft PR at least) @mshudrak

saurabhmj11 commented 1 year ago

To include the GCS bucket root folder in the report output, you can modify the script or tool that you are using to generate the report. The specific steps may vary depending on the tool or script you are using, but in general, you will need to do the following:

Modify the code to include the root folder of the GCS bucket in the report output. Test the modified code to ensure that it correctly identifies the root folder of the GCS bucket and includes it in the report output. Run the modified code to generate a new report that includes the root folder of the GCS bucket. Here is an example Python code that you can use to list all the files and folders in a GCS bucket, including the root folder:

makefile Copy code from google.cloud import storage

Initialize a client object

client = storage.Client()

Specify the name of the bucket to list

bucket_name = 'my-bucket'

Get a reference to the bucket object

bucket = client.get_bucket(bucket_name)

List all the blobs (files and folders) in the bucket

blobs = bucket.list_blobs()

Print the name of each blob (including the root folder)

for blob in blobs: print(blob.name) This code uses the Google Cloud Storage client library for Python to list all the blobs (files and folders) in a GCS bucket, including the root folder. You can modify this code to suit your specific needs and include the root folder in the report output.

Alternatively, if you are using a tool or script that already generates a report of GCS bucket contents, you can modify the code to include the root folder in the report output. The specific steps will depend on the tool or script you are using, so you may need to refer to the documentation or source code for guidance.

Bhardwaj-Himanshu commented 1 year ago

Hi @mshudrak, looking onto the issue, I do want to work on this but don't know where to start from? Could you please elaborate me on more details on "where is this located and how to start?"

mshudrak commented 1 year ago

@Bhardwaj-Himanshu #132 already addressing this problem.

Bhardwaj-Himanshu commented 1 year ago

Thanks for letting me know!