Skip to content

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

sfp_flickr: resolve pep8 violations and use f-strings

Brendan Colesbe5c3496fced
diff --git a/modules/sfp_flickr.py b/modules/sfp_flickr.py
index e4cfc66a..6a2b8d37 100644
--- a/modules/sfp_flickr.py
+++ b/modules/sfp_flickr.py
@@ -14,8 +14,10 @@
import json
import re
import time
-import urllib.request, urllib.parse, urllib.error
-from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
+import urllib.request
+import urllib.parse
+import urllib.error
+from sflib import SpiderFootPlugin, SpiderFootEvent
class sfp_flickr(SpiderFootPlugin):
@@ -24,9 +26,9 @@ class sfp_flickr(SpiderFootPlugin):
meta = {
'name': "Flickr",
'summary': "Search Flickr for domains, URLs and emails related to the specified domain.",
- 'flags': [ "" ],
- 'useCases': [ "Footprint", "Investigate", "Passive" ],
- 'categories': [ "Social Media" ],
+ 'flags': [""],
+ 'useCases': ["Footprint", "Investigate", "Passive"],
+ 'categories': ["Social Media"],
'dataSource': {
'website': "https://www.flickr.com/",
'model': "FREE_NOAUTH_UNLIMITED",
@@ -38,13 +40,13 @@ class sfp_flickr(SpiderFootPlugin):
'favIcon': "https://combo.staticflickr.com/pw/favicon.ico",
'logo': "https://combo.staticflickr.com/pw/favicon.ico",
'description': "Flickr is almost certainly the best online photo management and sharing application in the world.\n "
- "On Flickr, members upload photos, share them securely, supplement their photos with "
- "metadata like license information, geo-location, people, tags, etc., "
- "and interact with their family, friends, contacts or anyone in the community. "
- "Practically all the features on Flickr's various platforms -- web, mobile and desktop -- "
- "are accompanied by a longstanding API program. "
- "Since 2005, developers have collaborated on top of Flickr's APIs to build fun, creative, "
- "and gorgeous experiences around photos that extend beyond Flickr.",
+ "On Flickr, members upload photos, share them securely, supplement their photos with "
+ "metadata like license information, geo-location, people, tags, etc., "
+ "and interact with their family, friends, contacts or anyone in the community. "
+ "Practically all the features on Flickr's various platforms -- web, mobile and desktop -- "
+ "are accompanied by a longstanding API program. "
+ "Since 2005, developers have collaborated on top of Flickr's APIs to build fun, creative, "
+ "and gorgeous experiences around photos that extend beyond Flickr.",
}
}
@@ -79,7 +81,7 @@ class sfp_flickr(SpiderFootPlugin):
# What events this module produces
def producedEvents(self):
- return ["EMAILADDR", "EMAILADDR_GENERIC", "INTERNET_NAME",
+ return ["EMAILADDR", "EMAILADDR_GENERIC", "INTERNET_NAME",
"DOMAIN_NAME", "LINKED_URL_INTERNAL"]
# Retrieve API key
@@ -127,7 +129,7 @@ class sfp_flickr(SpiderFootPlugin):
try:
data = json.loads(res['content'])
except BaseException as e:
- self.sf.debug("Error processing JSON response: " + str(e))
+ self.sf.debug(f"Error processing JSON response: {e}")
return None
return data
@@ -139,14 +141,15 @@ class sfp_flickr(SpiderFootPlugin):
eventData = event.data
if eventData in self.results:
+ self.sf.debug(f"Skipping {eventData} as already mapped.")
return None
self.results[eventData] = True
- self.sf.debug("Received event, %s, from %s" % (eventName, srcModuleName))
+ self.sf.debug(f"Received event, {eventName}, from {srcModuleName}")
if srcModuleName == 'sfp_flickr':
- self.sf.debug("Ignoring " + eventData + ", from self.")
+ self.sf.debug(f"Ignoring {eventData}, from self.")
return None
# Retrieve API key
@@ -156,7 +159,7 @@ class sfp_flickr(SpiderFootPlugin):
self.sf.error("Failed to obtain API key", False)
return None
- self.sf.debug("Retrieved API key: " + api_key)
+ self.sf.debug(f"Retrieved API key: {api_key}")
# Query API for event data
hosts = list()
@@ -183,6 +186,7 @@ class sfp_flickr(SpiderFootPlugin):
photos = data.get('photos')
if not photos:
+ self.sf.debug("No search results.")
return None
# Calculate number of pages to retrieve
@@ -196,7 +200,7 @@ class sfp_flickr(SpiderFootPlugin):
if pages > allowed_pages:
pages = allowed_pages
- self.sf.info("Parsing page " + str(page) + " of " + str(pages))
+ self.sf.info(f"Parsing page {page} of {pages}")
# Extract data
for photo in photos.get('photo', list()):
@@ -208,7 +212,7 @@ class sfp_flickr(SpiderFootPlugin):
mail_domain = email.lower().split('@')[1]
if not self.getTarget().matches(mail_domain, includeChildren=True, includeParents=True):
- self.sf.debug("Skipped unrelated address: " + email)
+ self.sf.debug(f"Skipped unrelated address: {email}")
continue
self.sf.info("Found e-mail address: " + email)
@@ -229,12 +233,12 @@ class sfp_flickr(SpiderFootPlugin):
host = self.sf.urlFQDN(link)
if not self.getTarget().matches(host, includeChildren=True, includeParents=True):
- self.sf.debug("Skipped unrelated link: " + link)
+ self.sf.debug(f"Skipped unrelated URL: {link}")
continue
hosts.append(host)
- self.sf.debug("Found a URL: " + link)
+ self.sf.debug(f"Found a URL: {link}")
evt = SpiderFootEvent('LINKED_URL_INTERNAL', link, self.__name__, event)
self.notifyListeners(evt)
self.results[link] = True
@@ -249,7 +253,7 @@ class sfp_flickr(SpiderFootPlugin):
return None
if self.opts['dns_resolve'] and not self.sf.resolveHost(host):
- self.sf.debug("Host " + host + " could not be resolved")
+ self.sf.debug(f"Host {host} could not be resolved")
evt = SpiderFootEvent("INTERNET_NAME_UNRESOLVED", host, self.__name__, event)
self.notifyListeners(evt)
continue