policy/frameworks/netcontrol/catch-and-release.zeek
- NetControl
Implementation of catch-and-release functionality for NetControl.
- Namespace:
NetControl
- Imports:
Summary
Runtime Options
|
If true, catch and release warns if packets of an IP address are still seen after it should have been blocked. |
Redefinable Options
Time intervals for which subsequent drops of the same IP take effect. |
|
If true, catch_release_seen is called on the connection originator in new_connection, connection_established, partial_connection, connection_attempt, connection_rejected, connection_reset and connection_pending |
Types
This record is used for storing information about current blocks that are part of catch and release. |
|
The enum that contains the different kinds of messages that are logged by catch and release. |
|
The record type that is used for representing and logging |
Redefinitions
Events
Event is raised when catch and release cases management of an IP address because no activity was seen within the watch_until period. |
|
Event that can be handled to access the |
Hooks
Functions
This function can be called to notify the catch and release script that activity by an IP address was seen. |
|
Stops all packets involving an IP address from being forwarded. |
|
Get the |
|
Removes an address from being watched with catch and release. |
Detailed Interface
Runtime Options
- NetControl::catch_release_warn_blocked_ip_encountered
-
If true, catch and release warns if packets of an IP address are still seen after it should have been blocked.
Redefinable Options
- NetControl::catch_release_intervals
-
Time intervals for which subsequent drops of the same IP take effect.
- NetControl::watch_connections
-
If true, catch_release_seen is called on the connection originator in new_connection, connection_established, partial_connection, connection_attempt, connection_rejected, connection_reset and connection_pending
Types
- NetControl::BlockInfo
- Type:
- Fields:
This record is used for storing information about current blocks that are part of catch and release.
- NetControl::CatchReleaseActions
- Type:
-
- NetControl::INFO
Log lines marked with info are purely informational; no action was taken.
- NetControl::ADDED
A rule for the specified IP address already existed in NetControl (outside of catch-and-release). Catch and release did not add a new rule, but is now watching the IP address and will add a new rule after the current rule expires.
- NetControl::DROP_REQUESTED
A drop was requested by catch and release.
- NetControl::DROPPED
An address was successfully blocked by catch and release.
- NetControl::UNBLOCK
An address was unblocked after the timeout expired.
- NetControl::FORGOTTEN
An address was forgotten because it did not reappear within the watch_until interval.
- NetControl::SEEN_AGAIN
A watched IP address was seen again; catch and release will re-block it.
The enum that contains the different kinds of messages that are logged by catch and release.
- NetControl::CatchReleaseInfo
- Type:
- Fields:
-
-
action:
NetControl::CatchReleaseActions&log The action that was taken in this log-line.
-
block_interval:
interval&log&optional The current block_interval (for how long the address is blocked).
-
watch_interval:
interval&log&optional The current watch_interval (for how long the address will be watched and re-block if it reappears).
-
num_blocked:
count&log&optional Number of times that this address was blocked in the current cycle.
-
action:
The record type that is used for representing and logging
Events
- NetControl::catch_release_block_new
- Type:
event(a:addr, b:NetControl::BlockInfo)
- NetControl::catch_release_forgotten
- Type:
event(a:addr, bi:NetControl::BlockInfo)
Event is raised when catch and release cases management of an IP address because no activity was seen within the watch_until period.
- Parameters:
a – The address that is no longer being managed.
bi – The
NetControl::BlockInforecord containing information about the block.
- NetControl::log_netcontrol_catch_release
- Type:
Event that can be handled to access the
NetControl::CatchReleaseInforecord as it is sent on to the logging framework.
Hooks
Functions
- NetControl::catch_release_seen
-
This function can be called to notify the catch and release script that activity by an IP address was seen. If the respective IP address is currently monitored by catch and release and not blocked, the block will be reinstated. See the documentation of watch_new_connection which events the catch and release functionality usually monitors for activity.
- Parameters:
a – The address that was seen and should be re-dropped if it is being watched.
- NetControl::drop_address_catch_release
-
Stops all packets involving an IP address from being forwarded. This function uses catch-and-release functionality, where the IP address is only dropped for a short amount of time that is incremented steadily when the IP is encountered again.
In cluster mode, this function works on workers as well as the manager. On managers, the returned
NetControl::BlockInforecord will not contain the block ID, which will be assigned on the manager.- Parameters:
a – The address to be dropped.
t – How long to drop it, with 0 being indefinitely.
location – An optional string describing where the drop was triggered.
- Returns:
The
NetControl::BlockInforecord containing information about the inserted block.
- NetControl::get_catch_release_info
- Type:
function(a:addr) :NetControl::BlockInfo
Get the
NetControl::BlockInforecord for an address currently blocked by catch and release. If the address is unknown to catch and release, the watch_until time will be set to 0.In cluster mode, this function works on the manager and workers. On workers, the data will lag slightly behind the manager; if you add a block, it will not be instantly available via this function.
- Parameters:
a – The address to get information about.
- Returns:
The
NetControl::BlockInforecord containing information about the inserted block.
- NetControl::unblock_address_catch_release
-
Removes an address from being watched with catch and release. Returns true if the address was found and removed; returns false if it was unknown to catch and release.
If the address is currently blocked, and the block was inserted by catch and release, the block is removed.
- Parameters:
a – The address to be unblocked.
reason – A reason for the unblock.
- Returns:
True if the address was unblocked.