-
Notifications
You must be signed in to change notification settings - Fork 4
/
SherlockFindingsScraper.py
50 lines (48 loc) · 1.94 KB
/
SherlockFindingsScraper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import json
import requests
class SherlockFindingsScraper:
def getUserFindings(self, user):
url = f"https://api.github.com/search/issues?q=is:issue+label:Reward+{user}%20in:title%20org:sherlock-audit"
reports = json.loads(requests.get(url).text)
print(f"[+] Searching findings by {user} on Sherlock")
repositories = {}
for report in reports["items"]:
name = report["repository_url"].split("sherlock-audit/")[1]
if name in repositories:
repositories[name]["count"] += 1
else:
repositories[name] = {}
repositories[name]["contest_name"] = name
repositories[name]["reports"] = []
repositories[name]["count"] = 1
repositories[name]["highs"] = 0
repositories[name]["mediums"] = 0
repositories[name]["date"] = ""
severity = ""
for label in report["labels"]:
if label["name"] == "Medium":
severity = "Medium"
repositories[name]["mediums"] += 1
break
if label["name"] == "High":
severity = "High"
repositories[name]["highs"] += 1
break
repositories[name]["reports"].append(
{
"id": report["id"],
"title": report["title"],
"body": report["body"],
"updated_at": report["updated_at"],
"html_url": report["html_url"],
"severity": severity,
}
)
repositories[name]["date"] = report["updated_at"]
for key in repositories.keys():
print(
" [-] Found {} findings in {}".format(
repositories[key]["count"], key
)
)
return repositories