Skip to content

Commit

Permalink
tests: resolve darglint violations
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoles committed Sep 12, 2020
1 parent bf5db77 commit 29863b4
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 94 deletions.
1 change: 1 addition & 0 deletions modules/sfp_abuseipdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def queryBlacklist(self):

def parseBlacklist(self, blacklist):
"""Parse plaintext blacklist
Args:
blacklist (str): plaintext blacklist from AbuseIPDB
Expand Down
52 changes: 28 additions & 24 deletions modules/sfp_hybrid_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ class sfp_hybrid_analysis(SpiderFootPlugin):
errorState = False

def setup(self, sfc, userOpts=dict()):
"""
Initialize module and module options
"""
self.sf = sfc
self.results = self.tempStorage()
self.errorState = False
Expand All @@ -74,21 +71,19 @@ def setup(self, sfc, userOpts=dict()):
self.opts[opt] = userOpts[opt]

def watchedEvents(self):
"""
What events is this module interested in for input
"""
return ["IP_ADDRESS", "DOMAIN_NAME"]

def producedEvents(self):
"""
What events this module produces
"""
return ["RAW_RIR_DATA", "INTERNET_NAME", "DOMAIN_NAME", "LINKED_URL_INTERNAL"]

def queryDomain(self, qry):
"""
Query domain
https://www.hybrid-analysis.com/docs/api/v2
"""Query a domain
Args:
qry (str): domain
Returns:
str: API response as JSON
"""

params = {
Expand All @@ -111,9 +106,13 @@ def queryDomain(self, qry):
return self.parseAPIResponse(res)

def queryHost(self, qry):
"""
Query host
https://www.hybrid-analysis.com/docs/api/v2
"""Query a host
Args:
qry (str): host
Returns:
str: API response as JSON
"""

params = {
Expand All @@ -136,9 +135,13 @@ def queryHost(self, qry):
return self.parseAPIResponse(res)

def queryHash(self, qry):
"""
Query hash
https://www.hybrid-analysis.com/docs/api/v2
"""Query a hash
Args:
qry (str): hash
Returns:
str: API response as JSON
"""

params = {
Expand All @@ -161,8 +164,13 @@ def queryHash(self, qry):
return self.parseAPIResponse(res)

def parseAPIResponse(self, res):
"""
Parse API response
"""Parse HTTP response from API
Args:
res (dict): HTTP response from SpiderFoot.fetchUrl()
Returns:
str: API response as JSON
"""

if res['code'] == '400':
Expand Down Expand Up @@ -194,10 +202,6 @@ def parseAPIResponse(self, res):
return data

def handleEvent(self, event):
"""
Handle events sent to this module
"""

eventName = event.eventType
srcModuleName = event.module
eventData = event.data
Expand Down
9 changes: 8 additions & 1 deletion modules/sfp_recondev.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ def producedEvents(self):
return ["RAW_RIR_DATA", "INTERNET_NAME"]

def queryDomain(self, qry):
"""https://recon.dev/api/docs"""
"""Query a domain
Args:
qry (str): domain
Returns:
str: API response as JSON
"""

headers = {
"Accept": "application/json"
Expand Down
8 changes: 6 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
[flake8]
flake8-max-line-length = 120
max-complexity = 100
select = C,E,F,W,B,DUO
ignore = E501 W503 B006 DUO130 D
select = C,E,F,W,B,DUO,D
ignore = E501 W503 B006 DUO130
per-file-ignores =
spiderfoot/__init__.py:F401
sfcli.py:D
sflib.py:D
sfscan.py:D
sfwebui.py:D

[darglint]
docstring_style=google
14 changes: 12 additions & 2 deletions sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,12 @@ def start_scan(sfConfig, sfModules, args):


def start_web_server(sfWebUiConfig, sfConfig):
"""Start the web server so you can start looking at results"""
"""Start the web server so you can start looking at results
Args:
sfWebUiConfig (dict): web server options
sfConfig (dict): SpiderFoot config options
"""

web_host = sfWebUiConfig.get('host', '127.0.0.1')
web_port = sfWebUiConfig.get('port', 5001)
Expand Down Expand Up @@ -531,7 +536,12 @@ def start_web_server(sfWebUiConfig, sfConfig):


def handle_abort(signal, frame):
"""Handle interrupt and abort scan."""
"""Handle interrupt and abort scan.
Args:
signal: TBD
frame: TBD
"""
global dbh
global scanId

Expand Down
5 changes: 0 additions & 5 deletions sfscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,10 @@ def __init__(self, scanName, scanId, targetValue, targetType, moduleList, global

@property
def scanId(self):
"""Unique identifier for this scan"""
return self.__scanId

@property
def status(self):
"""Status of this scan"""
return self.__status

def __setStatus(self, status, started=None, ended=None):
Expand All @@ -204,9 +202,6 @@ def __setStatus(self, status, started=None, ended=None):
started (float): timestamp at start of scan
ended (float): timestamp at end of scan
Returns:
None
Raises:
TypeError: arg type was invalid
ValueError: arg value was invalid
Expand Down
43 changes: 6 additions & 37 deletions spiderfoot/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,6 @@ def __init__(self, opts, init=False):
init (bool): initialise the database schema.
if the database file does not exist this option will be ignored.
Returns:
None: success
Raises:
TypeError: arg type was invalid
ValueError: arg value was invalid
Expand Down Expand Up @@ -329,9 +326,6 @@ def __dbregex__(qry, data):
def create(self):
"""Create the database schema.
Returns:
None: success
Raises:
IOError: database I/O failed
"""
Expand All @@ -348,11 +342,7 @@ def create(self):
raise IOError(f"SQL error encountered when setting up database: {e.args[0]}")

def close(self):
"""Close the database handle
Returns:
None: success
"""
"""Close the database handle."""

with self.dbhLock:
self.dbh.close()
Expand Down Expand Up @@ -467,10 +457,8 @@ def scanLogEvent(self, instanceId, classification, message, component=None):
message (str): TBD
component (str): TBD
Returns:
None: success
Raises:
TypeError: arg type was invalid
IOError: database I/O failed
Todo:
Expand Down Expand Up @@ -515,9 +503,6 @@ def scanInstanceCreate(self, instanceId, scanName, scanTarget):
scanName(str): scan name
scanTarget (str): scan target
Returns:
None: success
Raises:
TypeError: arg type was invalid
IOError: database I/O failed
Expand Down Expand Up @@ -554,9 +539,6 @@ def scanInstanceSet(self, instanceId, started=None, ended=None, status=None):
ended (str): scan end time
status (str): scan status
Returns:
None: success
Raises:
TypeError: arg type was invalid
IOError: database I/O failed
Expand Down Expand Up @@ -854,9 +836,6 @@ def scanInstanceDelete(self, instanceId):
Args:
instanceId (str): scan instance ID
Returns:
None: success
Raises:
TypeError: arg type was invalid
IOError: database I/O failed
Expand Down Expand Up @@ -926,9 +905,6 @@ def configSet(self, optMap=dict()):
Args:
optMap (dict): config options
Returns:
None: success
Raises:
TypeError: arg type was invalid
ValueError: arg value was invalid
Expand Down Expand Up @@ -993,9 +969,6 @@ def configClear(self):
"""Reset the config to default.
Clears the config from the database and lets the hard-coded settings in the code take effect.
Returns:
None: success
Raises:
IOError: database I/O failed
"""
Expand All @@ -1015,9 +988,6 @@ def scanConfigSet(self, id, optMap=dict()):
id (int): scan instance ID
optMap (dict): config options
Returns:
None: success
Raises:
TypeError: arg type was invalid
ValueError: arg value was invalid
Expand Down Expand Up @@ -1095,9 +1065,6 @@ def scanEventStore(self, instanceId, sfEvent, truncateSize=0):
sfEvent (SpiderFootEvent): event to be stored in the database
truncateSize (int): truncate size for event data
Returns:
None: success
Raises:
TypeError: arg type was invalid
ValueError: arg value was invalid
Expand Down Expand Up @@ -1225,6 +1192,9 @@ def scanInstanceList(self):
def scanResultHistory(self, instanceId):
"""History of data from the scan.
Args:
instanceId (str): scan instance ID
Returns:
list: scan data history
Expand Down Expand Up @@ -1361,7 +1331,7 @@ def scanElementSourcesAll(self, instanceId, childData):
Raises:
TypeError: arg type was invalid
IOError: database I/O failed
ValueError: arg value was invalid
"""

if not isinstance(instanceId, str):
Expand Down Expand Up @@ -1432,7 +1402,6 @@ def scanElementChildrenAll(self, instanceId, parentIds):
Raises:
TypeError: arg type was invalid
IOError: database I/O failed
Note: This function is not the same as the scanElementParent* functions.
This function returns only ids.
Expand Down
Loading

0 comments on commit 29863b4

Please sign in to comment.