Client¶
PYTW Client module
-
class
pytw.client.
Client
(email, key, host='api.threatwatch.io')[source]¶ User-created PYTW Client object.
Parameters: - email – Email to identify the user
- key – API key to be used
- host – Host name to connect to for API calls. Note by default connects to ThreatWatch Cloud SaaS
-
create_asset
(asset)[source]¶ Parameters: asset – The asset to be created : Returns Response JSON with ‘status’
-
get_asset_by_id
(asset_id)[source]¶ Parameters: asset_id – Specifies ID of the asset to be retrieved. :Returns an Asset object.
-
get_assets
(search_params)[source]¶ Parameters: search_params – The search parameters for the search :Returns The specified asset object
-
get_assets_by_locations
(locations_list)[source]¶ Parameters: locations_list – Specifies locations of the assets to be retrieved. :Returns an AssetCollection object.
-
get_assets_by_names
(names_list)[source]¶ Parameters: names_list – Specifies the names of the assets to be retrieved. :Returns an AssetCollection object.
-
get_assets_by_patch
(patch)[source]¶ Parameters: patch – Retrieves assets containing specified patch :Returns an AssetCollection object.
-
get_assets_by_product
(product)[source]¶ Parameters: product – Retrieves assets containing specified product :Returns an AssetCollection object.
-
get_assets_by_types
(types_list)[source]¶ Parameters: types_list – Specifies the types of the assets to be retrieved. :Returns an AssetCollection object.
-
get_assets_with_open_impacts
()[source]¶ :Retrieves assets with open impacts :Returns an AssetCollection object.
-
get_impacts
(search_params)[source]¶ Parameters: search_params – An object of type SearchParams :Returns an ImpactCollection object containing instances of Impact objects.
-
get_impacts_by_asset_ids
(asset_ids_list, window_start=None, offset=0, limit=-1)[source]¶ Parameters: - asset_ids_list – A list of asset IDs to filter for.
- window_start – An optional number of days argument to retrieve impacts Only recent vulnerabilities from window_start days will be returned if specified.
- offset – An optional offset indicating from where to start in the result set.
- limit – An optional limit indicate how many entries from offset to return in the result set.
:Returns an ImpactCollection object containing instances of Impact objects which meet the criteria.
-
get_impacts_by_rating
(ratings, window_start=None, offset=0, limit=-1)[source]¶ Parameters: - ratings – A list of ratings (rating.Rating) to filter on.
- window_start – An optional number of days argument to retrieve impacts Only recent vulnerabilities from window_start days will be returned if specified.
- offset – An optional offset indicating from where to start in the result set.
- limit – An optional limit indicate how many entries from offset to return in the result set.
:Returns an ImpactCollection object containing instances of Impact objects which meet the criteria.
-
get_impacts_by_status
(status_list, window_start=None, offset=0, limit=-1)[source]¶ Parameters: - threshold – Only Impacts with specified status values will be returned
- window_start – An optional number of days argument to retrieve impacts Only impacts with confidence higher than threshold from window_start days will be returned if specified.
- offset – An optional offset indicating from where to start in the result set.
- limit – An optional limit indicate how many entries from offset to return in the result set.
:Returns an ImpactCollection object containing instances of Impact objects.
-
get_impacts_by_threshold
(threshold, window_start=None, offset=0, limit=-1)[source]¶ Parameters: - threshold – Only Impacts with confidence higher than threshold will be returned
- window_start – An optional number of days argument to retrieve impacts Only impacts with confidence higher than threshold from window_start days will be returned if specified.
- offset – An optional offset indicating from where to start in the result set.
- limit – An optional limit indicate how many entries from offset to return in the result set.
:Returns an ImpactCollection object containing instances of Impact objects.
-
get_impacts_by_vuln_ids
(vuln_ids_list, window_start=None, offset=0, limit=-1)[source]¶ Parameters: - vuln_ids_list – A list of vuln IDs to filter for.
- window_start – An optional number of days argument to retrieve impacts Only recent vulnerabilities from window_start days will be returned if specified.
- offset – An optional offset indicating from where to start in the result set.
- limit – An optional limit indicate how many entries from offset to return in the result set.
:Returns an ImpactCollection object containing instances of Impact objects which meet the criteria.
-
get_impacts_with_exploits
(window_start=None, offset=0, limit=-1)[source]¶ Parameters: - window_start – An optional number of days argument to retrieve impacts Only impacts with exploits from window_start days will be returned if specified.
- offset – An optional offset indicating from where to start in the result set.
- limit – An optional limit indicate how many entries from offset to return in the result set.
:Returns an ImpactCollection object containing instances of Impact objects.
-
get_impacts_with_patches
(window_start=None, offset=0, limit=-1)[source]¶ Parameters: - window_start – An optional number of days argument to retrieve impacts Only impacts with patches from window_start days will be returned if specified.
- offset – An optional offset indicating from where to start in the result set.
- limit – An optional limit indicate how many entries from offset to return in the result set.
:Returns an ImpactCollection object containing instances of Impact objects which have patches available.
-
get_impacts_with_remediations
(window_start=None, offset=0, limit=-1)[source]¶ Parameters: - window_start – An optional number of days argument to retrieve impacts Only impacts with remediations from window_start days will be returned if specified.
- offset – An optional offset indicating from where to start in the result set.
- limit – An optional limit indicate how many entries from offset to return in the result set.
:Returns an ImpactCollection object containing instances of Impact objects which have patches available.
-
get_recent_impacts
(window_start=None, threshold=None, offset=0, limit=-1)[source]¶ Parameters: - window_start – An optional number of days argument to retrieve recent impacts Only recent impacts from window_start days will be returned if specified.
- threshold – An optional threshold, only impacts with confidence greater than threshold will be returned
- offset – An optional offset indicating from where to start in the result set.
- limit – An optional limit indicate how many entries from offset to return in the result set.
:Returns an ImpactCollection object containing instances of Impact objects.
-
get_recent_vulns
(window_start=None, offset=0, limit=-1)[source]¶ Parameters: - window_start – An optional number of days argument to retrieve recent vulnerabilities Only recent vulnerabilities from window_start days will be returned if specified.
- offset – An optional offset indicating from where to start in the result set.
- limit – An optional limit indicate how many entries from offset to return in the result set.
:Returns a CVEVulnCollection object containing CVEVuln instances
-
get_tracked_vulns
(window_start=None, offset=0, limit=-1)[source]¶ Parameters: - window_start – An optional number of days argument to retrieve vulnerabilities Only tracked vulnerabilities from window_start days will be returned if specified.
- offset – An optional offset indicating from where to start in the result set.
- limit – An optional limit indicate how many entries from offset to return in the result set.
:Returns a CVEVulnCollection object containing CVEVuln instances
-
get_vulns
(search_params)[source]¶ Parameters: search_params – An object of type SearchParams :Returns a CVEVulnCollection object containing CVEVuln instances
-
get_vulns_by_publisher
(publishers, window_start=None, offset=0, limit=-1)[source]¶ Parameters: - ratings – A list of publishers to filter on.
- window_start – An optional number of days argument to retrieve vulnerabilities Only vulnerabilities from window_start days will be returned if specified.
- offset – An optional offset indicating from where to start in the result set.
- limit – An optional limit indicate how many entries from offset to return in the result set.
:Returns a CVEVulnCollection object containing CVEVuln instances
-
get_vulns_by_rating
(ratings, window_start=None, offset=0, limit=-1)[source]¶ Parameters: - ratings – A list of ratings (rating.Rating) to filter on.
- window_start – An optional number of days argument to retrieve vulnerabilities Only vulnerabilities from window_start days will be returned if specified.
- offset – An optional offset indicating from where to start in the result set.
- limit – An optional limit indicate how many entries from offset to return in the result set.
:Returns a CVEVulnCollection object containing CVEVuln instances
-
get_vulns_by_threshold
(threshold, window_start=None, offset=0, limit=-1)[source]¶ Parameters: - threshold – The threshold to filter on.
- window_start – An optional number of days argument to retrieve vulnerabilities Only vulnerabilities from window_start days will be returned if specified.
- offset – An optional offset indicating from where to start in the result set.
- limit – An optional limit indicate how many entries from offset to return in the result set.
:Returns a CVEVulnCollection object containing CVEVuln instances
-
get_vulns_by_vuln_ids
(vuln_ids_list, window_start=None, offset=0, limit=-1)[source]¶ Parameters: - vuln_ids_list – A list of vulnerability IDs to filter for.
- window_start – An optional number of days argument to retrieve vulnerabilities Only vulnerabilities from window_start days will be returned if specified.
- offset – An optional offset indicating from where to start in the result set.
- limit – An optional limit indicate how many entries from offset to return in the result set.
:Returns a CVEVulnCollection object containing CVEVuln instances
-
get_vulns_with_exploits
(window_start=None, offset=0, limit=-1)[source]¶ Parameters: - window_start – An optional number of days argument to retrieve vulnerabilities Only vulnerabilities from window_start days with exploits will be returned if specified.
- offset – An optional offset indicating from where to start in the result set.
- limit – An optional limit indicate how many entries from offset to return in the result set.
:Returns a CVEVulnCollection object containing CVEVuln instances
-
get_vulns_with_patches
(window_start=None, offset=0, limit=-1)[source]¶ Parameters: - window_start – An optional number of days argument to retrieve vulnerabilities Only vulnerabilities from window_start days with patches will be returned if specified.
- offset – An optional offset indicating from where to start in the result set.
- limit – An optional limit indicate how many entries from offset to return in the result set.
:Returns a CVEVulnCollection object containing CVEVuln instances
-
get_vulns_with_remediations
(window_start=None, offset=0, limit=-1)[source]¶ Parameters: - window_start – An optional number of days argument to retrieve vulnerabilities Only vulnerabilities from window_start days with remediations will be returned if specified.
- offset – An optional offset indicating from where to start in the result set.
- limit – An optional limit indicate how many entries from offset to return in the result set.
:Returns a CVEVulnCollection object containing CVEVuln instances