censys.asm package
An easy-to-use and lightweight API wrapper for Censys ASM (app.censys.io).
- class censys.asm.AsmClient(api_key: Optional[str] = None, **kwargs)[source]
Bases:
object
Client ASM API class.
- class censys.asm.Assets(asset_type: str, *args, **kwargs)[source]
Bases:
CensysAsmAPI
Assets API class.
- add_comment(asset_id: str, comment: str) dict [source]
Adds a comment to a specified asset on the ASM platform.
- add_tag(asset_id: str, name: str, color: Optional[str] = None) dict [source]
Adds a tag to a specified asset on the ASM platform.
- delete_comment(asset_id: str, comment_id: int) dict [source]
Deletes a comment from a specified asset on the ASM platform by comment ID.
- delete_tag(asset_id: str, name: str) dict [source]
Deletes a tag from a specified asset on the ASM platform by tag name.
- get_assets(page_number: int = 1, page_size: Optional[int] = None, tag: Optional[List[str]] = None, tag_operator: Optional[str] = None, source: Optional[List[str]] = None, discovery_trail: Optional[bool] = None) Iterator[dict] [source]
Requests assets data.
- Parameters
page_number (int) – Optional; Page number to begin at when searching.
page_size (int) – Optional; Page size for retrieving assets.
tag (list) – Optional; List of tags to search for.
tag_operator (str) – Optional; Operator to use when searching for tags.
source (list) – Optional; List of sources to search for.
discovery_trail (bool) – Optional; Bool indicating whether to return discovery trail.
- Yields
dict – The assets result returned.
- get_comment_by_id(asset_id: str, comment_id: int) dict [source]
Requests a comment on a specified asset by comment ID.
- class censys.asm.CertificatesAssets(*args, **kwargs)[source]
Bases:
Assets
Certificates Assets API class.
- class censys.asm.Clouds(api_key: Optional[str] = None, **kwargs)[source]
Bases:
CensysAsmAPI
Clouds API class.
- base_path = '/v1/clouds'
- get_domain_counts(since: Union[str, date, datetime]) dict [source]
Retrieve domain counts by cloud.
- Parameters
since (Since) – Date to include domains from.
- Returns
Domain count result.
- Return type
- get_host_counts(since: Union[str, date, datetime]) dict [source]
Retrieve host counts by cloud.
Hosts found after the date provided in the since parameter will be included in the new asset counts.
- Parameters
since (Since) – Date to include hosts from.
- Returns
Host count result.
- Return type
- get_object_store_counts(since: Union[str, date, datetime]) dict [source]
Retrieve object store counts by cloud.
- Parameters
since (Since) – Date to include object stores from.
- Returns
Object store count result.
- Return type
- class censys.asm.DomainsAssets(*args, **kwargs)[source]
Bases:
Assets
Domains Assets API class.
- class censys.asm.Events(api_key: Optional[str] = None, **kwargs)[source]
Bases:
CensysAsmAPI
Events API class.
- base_path = '/v1/logbook'
- get_cursor(start: Optional[Union[datetime, int]] = None, filters: Optional[List[str]] = None) str [source]
Requests a logbook cursor.
- Parameters
start ([datetime.datetime, int]) – Optional; Timestamp or event ID to begin searching.
filters (list) – Optional; List of filters applied to logbook search results.
- Returns
Cursor result.
- Return type
- class censys.asm.InventorySearch(api_key: Optional[str] = None, **kwargs)[source]
Bases:
CensysAsmAPI
Inventory Search API class.
- aggregate(workspaces: List[str], query: Optional[str] = None, aggregation: Optional[dict] = None) dict [source]
Aggregate inventory data.
- base_path = '/inventory/v1'
- fields(fields: Optional[List[str]] = None) dict [source]
List inventory fields.
If no fields are specified, all fields will be returned.
- search(workspaces: List[str], query: Optional[str] = None, page_size: Optional[int] = None, cursor: Optional[str] = None, sort: Optional[List[str]] = None, fields: Optional[List[str]] = None) dict [source]
Search inventory data.
- Parameters
workspaces (List[str]) – List of workspace IDs to search.
query (str, optional) – Query string.
page_size (int, optional) – Number of results to return. Defaults to 50.
cursor (str, optional) – Cursor to start search from.
sort (List[str], optional) – List of fields to sort by.
fields (List[str], optional) – List of fields to return.
- Returns
Inventory search results.
- Return type
- class censys.asm.Risksv1(api_key: Optional[str] = None, **kwargs)[source]
Bases:
CensysAsmAPI
Risks v1 API class.
- base_path = '/v1/risks'
- get_risks(cloud: Optional[str] = None, environment: Optional[str] = None, include_accepted_risks: Optional[bool] = None, page_number: int = 1, page_size: int = 100) Iterator[dict] [source]
Retrieve risks.
Returns a full list of all risks that affect any assets in the system, along with a count of assets affected by each risk.
- Parameters
- Yields
dict – Host count result.
- class censys.asm.Risksv2(api_key: Optional[str] = None, **kwargs)[source]
Bases:
CensysAsmAPI
Risks v2 API class.
- base_path = '/v2/risk'
- get_risk_instance(risk_instance_id: int, include_events: Optional[bool] = None) dict [source]
Retrieve a risk instance.
- get_risk_instances(include_events: Optional[bool] = None, accept: Optional[str] = None) dict [source]
Retrieve risk instances.
- get_risk_type(risk_type: str, include_events: Optional[bool] = None) dict [source]
Retrieve a risk type.
- get_risk_types(sort: Optional[List[str]] = None, include_events: Optional[bool] = None, accept: Optional[str] = None) dict [source]
Retrieve risk types.
- risk_instances_path = '/v2/risk-instances'
- risk_types_path = '/v2/risk-types'
- class censys.asm.Seeds(api_key: Optional[str] = None, **kwargs)[source]
Bases:
CensysAsmAPI
Seeds API class.
- base_path = '/v1/seeds'
- get_seeds(seed_type: Optional[str] = None, label: Optional[str] = None) dict [source]
Requests seed data.
censys.asm.api module
Base for interacting with the Censys ASM API.