@@ -21,4 +21,126 @@ def __init__(self, host, api_key, verify_ssl, timeout, headers, user_agent, cert
2121 the private key and the certificate) or as a tuple of both file’s path
2222 :param debug: Prints requests and responses, useful for debugging.
2323 """
24- super ().__init__ (host , api_key , verify_ssl , timeout , headers , user_agent , cert , debug )
24+ super ().__init__ (host , api_key , verify_ssl , timeout , headers , user_agent , cert , debug )
25+
26+ def get_scan_stats_for_system (self ):
27+ """
28+ Gets scan statistics for the ThreadFix system
29+ """
30+ return super ().request ('GET' , '/api/search/scans/stats' )
31+
32+ def get_asset_vulnerability_statistic_by_severity_using_ips (self , page = 1 , limit = 50 , href = None , severity = None , status = None , first_found_date = None , last_seen_date = None , ip_address = None ):
33+ """
34+ Get number of vulnerabilities for each severity by using ips
35+ :param page: Page of results to get
36+ :param limit: Number of results per page
37+ :param href: The link to the next page in the system from a previous call
38+ :param severity: Severity of vulnerabilities to get
39+ :param first_found_date: Get vulnerabilities found on this date
40+ :param last_seen_date: Get vulnerabilities last seen on this date
41+ :param ip_address: IP addresses to filter vulnerabilities with
42+ """
43+ params = {}
44+ if severity :
45+ params ['severity' ] = severity
46+ if status :
47+ params ['status' ] = status
48+ if first_found_date :
49+ params ['firstFoundDate' ] = first_found_date
50+ if last_seen_date :
51+ params ['lastSeenDate' ] = last_seen_date
52+ if ip_address :
53+ params ['ipAddress' ] = ip_address
54+ if href :
55+ return super ().request ('GET' , '/api/search/assets/ipAddresses/vulnerabilities' + href )
56+ return super ().request ('GET' , f'/api/search/assets/ipAddresses/vulnerabilities/counts?_page={ page } &_limit={ limit } ' , params = params )
57+
58+ def get_asset_vulnerability_details (self , page = 1 , limit = 50 , href = None , severity = None , status = None , first_found_date = None , last_seen_date = None , ip_address = None ,
59+ include_stats = False , port = None , cve = None , cvss = None ):
60+ """
61+ Get all the details from a vulnerability
62+ :param page: Page of results to get
63+ :param limit: Number of results per page
64+ :param href: The link to the next page in the system from a previous call
65+ :param severity: Severity of vulnerabilities to get
66+ :param first_found_date: Get vulnerabilities found on this date
67+ :param last_seen_date: Get vulnerabilities last seen on this date
68+ :param ip_address: IP addresses to filter vulnerabilities with
69+ :param include_stats: Whether or not to return the severity counts of vulnerabilities
70+ :param port: Find vulnerabilities based on the port value
71+ :param cve: Find vulnerabilities related to this cve
72+ :param cvss: Find vulnerabilities related to this cvss
73+ """
74+ params = { 'includeStats' : include_stats }
75+ if severity :
76+ params ['severity' ] = severity
77+ if status :
78+ params ['status' ] = status
79+ if first_found_date :
80+ params ['firstFoundDate' ] = first_found_date
81+ if last_seen_date :
82+ params ['lastSeenDate' ] = last_seen_date
83+ if ip_address :
84+ params ['ipAddress' ] = ip_address
85+ if port :
86+ params ['port' ] = port
87+ if cve :
88+ params ['cve' ] = cve
89+ if cvss :
90+ params ['cvss' ] = cvss
91+ if href :
92+ return super ().request ('GET' , '/api/search/assets/ipAddresses/vulnerabilities' + href )
93+ return super ().request ('GET' , f'/api/search/assets/ipAddresses/vulnerabilities/counts?_page={ page } &_limit={ limit } ' , params = params )
94+
95+ def get_asset_vulnerability_details_using_ip (self , page = 1 , limit = 50 , href = None , severity = None , status = None , first_found_date = None , last_seen_date = None , ip_address = None , include_stats = False ):
96+ """
97+ Get all the details from a vulnerability
98+ :param page: Page of results to get
99+ :param limit: Number of results per page
100+ :param href: The link to the next page in the system from a previous call
101+ :param severity: Severity of vulnerabilities to get
102+ :param first_found_date: Get vulnerabilities found on this date
103+ :param last_seen_date: Get vulnerabilities last seen on this date
104+ :param ip_address: IP addresses to filter vulnerabilities with
105+ :param include_stats: Whether or not to return the severity counts of vulnerabilities
106+ """
107+ params = { 'includeStats' : include_stats }
108+ if severity :
109+ params ['severity' ] = severity
110+ if status :
111+ params ['status' ] = status
112+ if first_found_date :
113+ params ['firstFoundDate' ] = first_found_date
114+ if last_seen_date :
115+ params ['lastSeenDate' ] = last_seen_date
116+ if ip_address :
117+ params ['ipAddress' ] = ip_address
118+ if href :
119+ return super ().request ('GET' , '/api/search/assets/ipAddresses/vulnerabilities' + href )
120+ return super ().request ('GET' , f'/api/search/assets/ipAddresses/vulnerabilities/counts?_page={ page } &_limit={ limit } ' , params = params )
121+
122+ def fetch_networks_for_asset (self , asset_id , page = 1 , limit = 50 , href = None ):
123+ """
124+ Gets all networks connected to that asset
125+ :param asset_id: ID of asset to fetch networks for
126+ :param page: Page of results to get
127+ :param limit: Number of results per page
128+ :param href: The link to the next page in the system from a previous call
129+ """
130+ if href :
131+ super ().request ('GET' , f'/api/search/assets/{ asset_id } ' + href )
132+ return super ().request ('GET' , f'/api/search/assets/{ asset_id } /networks?_page={ page } &_limit={ limit } ' )
133+
134+ def fetch_assets_for_network (self , network_id , is_archived = False , page = 1 , limit = 50 , href = None ):
135+ """
136+ Gets all assets connected to that network
137+ :param network_id: ID of asset to fetch networks for
138+ :param is_archived: Filters assets based on archival status
139+ :param page: Page of results to get
140+ :param limit: Number of results per page
141+ :param href: The link to the next page in the system from a previous call
142+ """
143+ params = { 'isArchived' : is_archived }
144+ if href :
145+ super ().request ('GET' , f'/api/search/assets/{ network_id } ' + href , params = params )
146+ return super ().request ('GET' , f'/api/search/assets/{ network_id } /networks?_page={ page } &_limit={ limit } ' , params = params )
0 commit comments