Debian Codegraph @

examples/asm/get_host_risks.py

raw
1 """Retrieve host risks and subsequent host info for each host risk."""
2
3 from censys.asm import HostsAssets, Logbook
4
5 logbook = Logbook()
6 hosts = HostsAssets()
7
8 cursor = logbook.get_cursor(filters=["HOST_RISK"])
9 events = logbook.get_events(cursor)
10
11 for event in events:
12 # only show logbook events with the 'add' tag
13 if event["operation"] == "ADD":
14 print(event)
15
16 # enrich the data of this host_risk with more data from the host itself
17 host = hosts.get_asset_by_id(event["entity"]["ipAddress"])
18 print(host)