Skip to content

SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.

Clean up bucket querying logic.

smicallef246a768592f6
diff --git a/modules/sfp_digitaloceanspace.py b/modules/sfp_digitaloceanspace.py
index b76411b5..602c9bdd 100644
--- a/modules/sfp_digitaloceanspace.py
+++ b/modules/sfp_digitaloceanspace.py
@@ -69,13 +69,21 @@ class sfp_digitaloceanspace(SpiderFootPlugin):
def checkSite(self, url):
res = self.sf.fetchUrl(url, timeout=10, useragent="SpiderFoot", noLog=True)
- if res['code'] not in ["301", "302", "200"] and (res['content'] is None or "NoSuchBucket" in res['content']):
+ if not res['content']:
+ return None
+
+ if "NoSuchBucket" in res['content']:
self.sf.debug(f"Not a valid bucket: {url}")
- else:
+ return None
+
+ # Bucket found
+ if res['code'] in ["301", "302", "200"]:
+ # Bucket has files
if "ListBucketResult" in res['content']:
with self.lock:
self.s3results[url] = res['content'].count("<Key>")
else:
+ # Bucket has no files
with self.lock:
self.s3results[url] = 0
diff --git a/modules/sfp_googleobjectstorage.py b/modules/sfp_googleobjectstorage.py
index fdab07ed..866f5a31 100644
--- a/modules/sfp_googleobjectstorage.py
+++ b/modules/sfp_googleobjectstorage.py
@@ -67,13 +67,21 @@ class sfp_googleobjectstorage(SpiderFootPlugin):
def checkSite(self, url):
res = self.sf.fetchUrl(url, timeout=10, useragent="SpiderFoot", noLog=True)
- if res['code'] not in ["301", "302", "200"] and (res['content'] is None or "NoSuchBucket" in res['content']):
+ if not res['content']:
+ return None
+
+ if "NoSuchBucket" in res['content']:
self.sf.debug(f"Not a valid bucket: {url}")
- else:
+ return None
+
+ # Bucket found
+ if res['code'] in ["301", "302", "200"]:
+ # Bucket has files
if "ListBucketResult" in res['content']:
with self.lock:
self.gosresults[url] = res['content'].count("<Key>")
else:
+ # Bucket has no files
with self.lock:
self.gosresults[url] = 0
diff --git a/modules/sfp_s3bucket.py b/modules/sfp_s3bucket.py
index 15c47c6f..104e3f8f 100644
--- a/modules/sfp_s3bucket.py
+++ b/modules/sfp_s3bucket.py
@@ -69,13 +69,21 @@ class sfp_s3bucket(SpiderFootPlugin):
def checkSite(self, url):
res = self.sf.fetchUrl(url, timeout=10, useragent="SpiderFoot", noLog=True)
- if res['code'] not in ["301", "302", "200"] and (res['content'] is None or "NoSuchBucket" in res['content']):
- self.sf.debug("Not a valid bucket: " + url)
- else:
+ if not res['content']:
+ return None
+
+ if "NoSuchBucket" in res['content']:
+ self.sf.debug(f"Not a valid bucket: {url}")
+ return None
+
+ # Bucket found
+ if res['code'] in ["301", "302", "200"]:
+ # Bucket has files
if "ListBucketResult" in res['content']:
with self.lock:
self.s3results[url] = res['content'].count("<Key>")
else:
+ # Bucket has no files
with self.lock:
self.s3results[url] = 0