Skip to content

Commit

Permalink
HIBP_Query - Option to include Unverified Breaches (#381)
Browse files Browse the repository at this point in the history
* Add configuration option to include unverified breaches

* Add configuration option to include unverified breaches

* Update user-agent header
  • Loading branch information
arnydo authored and nadouani committed Nov 29, 2018
1 parent 60593ec commit 3f328ab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
12 changes: 11 additions & 1 deletion analyzers/HIBP_Query/HIBP_Query.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,15 @@
"service": "query",
"url": "https://haveibeenpwned.com/api/v2/breachedaccount/"
},
"command": "HIBP_Query/hibpquery_analyzer.py"
"command": "HIBP_Query/hibpquery_analyzer.py",
"configurationItems": [
{
"name": "unverified",
"description": "Include unverified breaches",
"type": "boolean",
"multi": false,
"required": true,
"defaultValue": true
}
]
}
9 changes: 7 additions & 2 deletions analyzers/HIBP_Query/hibpquery_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def __init__(self):
self.service = self.getParam(
'config.service', None, 'Service parameter is missing')
self.api_url = self.getParam('config.url', None, 'Missing API URL')
self.unverified = self.getParam('config.unverified', None, 'Missing Unverified option')

@staticmethod
def cleanup(return_data):
Expand All @@ -35,9 +36,13 @@ def hibp_query(self, data):
results = dict()

try:
hibpurl = self.api_url + data
if self.unverified == True:
unverified = '?includeUnverified=true'
else:
unverified = ''
hibpurl = self.api_url + data + unverified
headers = {
'User-Agent': 'curl/7.38.0'
'User-Agent': 'HIBP-Cortex-Analyzer'
}

_query = requests.get(hibpurl, headers=headers)
Expand Down

0 comments on commit 3f328ab

Please sign in to comment.