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

S3 scan on demand failing when scanning bucket containing folders #287

Open
malexios opened this issue Aug 14, 2024 · 0 comments
Open

S3 scan on demand failing when scanning bucket containing folders #287

malexios opened this issue Aug 14, 2024 · 0 comments

Comments

@malexios
Copy link

When running quickscan_target.py against an S3 bucket containing folders, it fails when it tries to scan the folder object.

Steps to Reproduce:
Create an S3 bucket and add test objects
Run quickscan

Add an object in a folder
run quickscan

Expected Behavior:
The files will be uploaded and scanned

Actual Behavior:
When the script attempts to scan the folder, it will error out when attempting to upload the folder

File "/home/me/quickscan_target.py", line 307, in
upload_bucket_samples()
File "/home/me/quickscan_target.py", line 150, in upload_bucket_samples
sha = response["body"]["resources"][0]["sha256"]

Possible Cause:
When you create a folder in Amazon S3, S3 creates a 0-byte object with a key that's set to the folder name.
When scanning a bucket containing folders, quickscan_target.py attempts to get the object filename via os.path.basename. When the object is a folder, it results in filename, response and sha being empty and the script crashes when calling the analyzer.

Resolution:
Change line 137 to:
for item in [files for files in summaries if files.size != 0]:

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

No branches or pull requests

1 participant