File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,6 +19,11 @@ Docstrings are used to document the library.
1919Types are also used to inform the user on what type of objects the functions are
2020expecting.
2121
22+ Each API response is encoded in either a ` SuccessResponse ` object or a
23+ ` ErrorResponse ` .
24+ The methods ` is_success() ` or ` is_error() ` exist on each API response.
25+ You can get the actual response by using the method ` json() ` on the response object.
26+
2227The output are events described in
2328[ l9format] ( https://github.com/LeakIX/l9format-python ) .
2429When you have an object of type ` l9Event ` (or the longer
@@ -29,6 +34,16 @@ model class for the available fields.
2934For instance, to access the IP of an object ` event ` of type ` L9Event ` , you can
3035use ` event.ip ` .
3136
37+ Each object can be transformed back into a Python dictionary/JSON using the method ` to_dict() ` .
38+ For instance, for the response of the subdomains endpoint, you can get back individual JSON by using:
39+
40+ ``` python
41+ def example_get_subdomains ():
42+ response = CLIENT .get_subdomains(" leakix.net" )
43+ for subdomain in response.json():
44+ print (subdomain.to_dict())
45+ ```
46+
3247## Support
3348
3449Feel free to open an issue if you have any question.
Original file line number Diff line number Diff line change @@ -120,6 +120,12 @@ def example_bulk_service():
120120 print (response .json ())
121121
122122
123+ def example_get_subdomains ():
124+ domain = "leakix.net"
125+ response = CLIENT .get_subdomains (domain )
126+ print (response .json ())
127+
128+
123129if __name__ == "__main__" :
124130 example_get_host_filter_plugin ()
125131 example_get_service_filter_plugin ()
@@ -132,3 +138,4 @@ def example_bulk_service():
132138 example_bulk_export ()
133139 example_bulk_service ()
134140 example_bulk_export_last_event ()
141+ example_get_subdomain ()
Original file line number Diff line number Diff line change 99from leakix .plugin import *
1010from leakix .plugin import APIResult
1111from leakix .field import *
12+ from leakix .domain import L9Subdomain
1213
1314
1415__VERSION__ = "0.1.9"
@@ -153,6 +154,18 @@ def get_plugins(self):
153154 r .response_json = [APIResult .from_dict (d ) for d in r .json ()]
154155 return r
155156
157+ def get_subdomains (self , domain : str ):
158+ """
159+ Returns the list of subdomains for a given domain.
160+ The output is a list of `L9Subdomain` objects. The fields are `subdomain`, `distinct_ips` and `last_seen`.
161+ To get back a JSON/Python dictionary, use the method `to_dict` on the individual element of the response object.
162+ """
163+ url = "%s/api/subdomains/%s" % (self .base_url , domain )
164+ r = self .__get (url , params = None )
165+ if r .is_success ():
166+ r .response_json = [L9Subdomain .from_dict (d ) for d in r .json ()]
167+ return r
168+
156169 def bulk_export (self , queries : Optional [List [Query ]] = None ):
157170 url = "%s/bulk/search" % (self .base_url )
158171 if queries is None or len (queries ) == 0 :
Original file line number Diff line number Diff line change 1+ from serde import Model , fields
2+
3+
4+ class L9Subdomain (Model ):
5+ subdomain : fields .Str ()
6+ distinct_ips : fields .Int ()
7+ last_seen : fields .DateTime ()
Original file line number Diff line number Diff line change 11from leakix .plugin import Plugin
2- from abc import ABCMeta , abstractmethod
32from datetime import datetime
43from typing import Optional
54from enum import Enum
You can’t perform that action at this time.
0 commit comments