Skip to content

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

fix: handle empty results from bing API

Amr Awad92c298507436
diff --git a/modules/sfp_bingsearch.py b/modules/sfp_bingsearch.py
index ffc058e9..44014a43 100644
--- a/modules/sfp_bingsearch.py
+++ b/modules/sfp_bingsearch.py
@@ -65,7 +65,7 @@ class sfp_bingsearch(SpiderFootPlugin):
},
)
if results is None:
- # Failed to talk to bing api
+ # Failed to talk to bing api or no results returned
return None
urls = results["urls"]
new_links = list(set(urls) - set(self.results))
diff --git a/modules/sfp_bingsharedip.py b/modules/sfp_bingsharedip.py
index 7baa6bcb..68ba8904 100644
--- a/modules/sfp_bingsharedip.py
+++ b/modules/sfp_bingsharedip.py
@@ -125,8 +125,9 @@ class sfp_bingsharedip(SpiderFootPlugin):
},
)
if results is None:
- # Failed to talk to bing api
+ # Failed to talk to bing api or no results returned
return None
+
urls = results["urls"]
for url in urls:
diff --git a/sflib.py b/sflib.py
index 175b1d12..5bae66be 100644
--- a/sflib.py
+++ b/sflib.py
@@ -1334,10 +1334,14 @@ class SpiderFoot:
response_json = json.loads(response['content'])
- results = {
- "urls": [result["url"] for result in response_json["webPages"]["value"]],
- "webSearchUrl": response_json["webPages"]["webSearchUrl"],
- }
+ if "webPages" in response_json:
+ results = {
+ "urls": [result["url"] for result in response_json["webPages"]["value"]],
+ "webSearchUrl": response_json["webPages"]["webSearchUrl"],
+ }
+ else:
+ return None
+
return results