Phx2Ban.Rule behaviour (Phx2Ban v0.2.2)

This module defines the behaviour for a filter rule. Once a module implements the behaviour it can safetly be plugged into the Phx2Ban firewall engine. All the prebuilt firewall rules implement this behaviour but of course you can write your own using the same behaviour.

Summary

Callbacks

Returns a string that describes what the rule checks for. For example: "This rule checks for common PHP extensions like *.php.".

Returns an atom that acts as the shorthand label for the rule module. For example: :php_extensions.

This function analyzes the provided ConnData struct and determines if it is an invalid request. If is is determined that the request is malicious this function should return true.

Callbacks

@callback description() :: String.t()

Returns a string that describes what the rule checks for. For example: "This rule checks for common PHP extensions like *.php.".

@callback label() :: atom()

Returns an atom that acts as the shorthand label for the rule module. For example: :php_extensions.

Link to this callback

valid_request?(t)

@callback valid_request?(Phx2Ban.ConnData.t()) :: boolean()

This function analyzes the provided ConnData struct and determines if it is an invalid request. If is is determined that the request is malicious this function should return true.