API¶
-
class
bhr_client.rest.
Client
(host, session, ident=None, timeout=30)[source]¶ BHR Client
-
block
(cidr, source, why, duration=300, autoscale=False, skip_whitelist=False, extend=False)[source]¶ Send a block request to the BHR system
Parameters: - cidr – The IP Address or CIDR network to block
- source – The source for this block. i.e., where the intel came from
- why – The reason for the block
- duration – The time to block in seconds, or a string like ‘1d’. Accepted suffixes are y, mo, d, h, m, s.
- autoscale – Whether or not to auto scale the duration based on server side block history
- skip_whitelist – Whether or not to bypass the server side whitelist
-
get_list
(source=None, since=None)[source]¶ Return a the current block list as a list of dictionaries
-
ident
¶
-
mblock
(block_records)[source]¶ Send a batch block request. :param block_records: A list of dictionaries whose keys are options to ‘
block()
’ For example: block_records = [dict(cidr=ip, duration=30, source=”test”, why=”testing”,) for ip in ips]
-
query
(cidr)[source]¶ Return the block history for an address”
Parameters: cidr – The IP Address or CIDR network to look up
-
set_blocked
(records)[source]¶ Mark a block record as blocked
This is not meant to be called directly
-
-
class
bhr_client.rest.
Delayer
(initial=0, lower=1, upper=60, factor=2, sleep=<built-in function sleep>)[source]¶
-
bhr_client.rest.
login
(host, token=None, username=None, password=None, ident=None, ssl_no_verify=False, timeout=30)[source]¶ Create an authenticated client object. To authenticate pass either a token or a username + password.
Parameters: - host – the URL to the BHR system
- token – A django-rest-framework api token
- username –
- password –
- ident – Ident to use for backend block entry tracking
- ssl_no_verify – Disable SSL certificate verification
-
bhr_client.rest.
login_from_env
()[source]¶ Create an authenticated client object using environment variables. This simply calls
login()
. The environment variables looked at are:BHR_HOST
- mapped to hostBHR_TOKEN
- mapped to tokenBHR_USERNAME
- mapped to usernameBHR_PASSWORD
- mapped to passwordBHR_IDENT
- mapped to identBHR_SSL_NO_VERIFY
- mapped to ssl_no_verify