forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresults.py
More file actions
111 lines (78 loc) · 2.79 KB
/
results.py
File metadata and controls
111 lines (78 loc) · 2.79 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
"""This module provides functions for getting scan results for a domain"""
import json
from core import execute_query
from queries import ALL_RESULTS, WEB_RESULTS, EMAIL_RESULTS, DOMAIN_STATUS
from formatting import (
format_all_results,
format_web_results,
format_email_results,
format_domain_status,
)
def get_all_results(client, domain):
"""Get all scan results for a domain
:param Client client: a gql Client object
:param str domain: domain to get results for
:return: formatted JSON data with all scan results for the domain
:rtype: str
:Example:
Coming soon, function likely to change
"""
params = {"domain": domain}
result = execute_query(client, ALL_RESULTS, params)
if "error" not in result:
result = format_all_results(result)
return json.dumps(result, indent=4)
def get_web_results(client, domain):
"""Get web scan results for a domain
:param Client client: a gql Client object
:param str domain: domain to get results for
:return: formatted JSON data with web scan results for the domain
:rtype: str
:Example:
"""
params = {"domain": domain}
result = execute_query(client, WEB_RESULTS, params)
if "error" not in result:
result = format_web_results(result)
return json.dumps(result, indent=4)
def get_email_results(client, domain):
"""Get email scan results for a domain
:param Client client: a gql Client object
:param str domain: domain to get results for
:return: formatted JSON data with email scan results for the domain
:rtype: str
:Example:
"""
params = {"domain": domain}
result = execute_query(client, EMAIL_RESULTS, params)
if "error" not in result:
result = format_email_results(result)
return json.dumps(result, indent=4)
def get_domain_status(client, domain):
"""Return pass/fail status information for a domain
:param Client client: a gql Client object
:param str domain: domain to get the status of
:return: formatted JSON data with the domain's status
:rtype: str
:Example:
>>> import tracker_client.client as tracker_client
>>> client = tracker_client.create_client(auth_token=tracker_client.get_auth_token())
>>> print(tracker_client.get_domain_status(client, "foo.bar"))
{
"foo.bar": {
"lastRan": "2021-01-23 22:33:26.921529",
"status": {
"https": "FAIL",
"ssl": "FAIL",
"dmarc": "PASS",
"dkim": "PASS",
"spf": "PASS"
}
}
}
"""
params = {"domain": domain}
result = execute_query(client, DOMAIN_STATUS, params)
if "error" not in result:
result = format_domain_status(result)
return json.dumps(result, indent=4)