Forum Discussion
Print string found in Data Group to Log
I have an iRule that is looking in the HTTP POST request method data payload for a string that is defined in a data-group. I would like to print to the log whichever string from the referenced data-group is found.
# See https://devcentral.f5.com/s/question/0D51T00006i7hpJSAQ/irule-to-block-requests-with-specific-word
#
# ltm data-group internal restricted_dg {
# records {
# restricted {}
# }
# type string
# }
when HTTP_REQUEST_DATA {
set payload [HTTP::payload]
if {[class match [string tolower $payload] contains "restricted_dg"]} {
# set variable named restricted_text to the string found in $payload
# that matches something in data-group restricted_dg
log local0. "Rejecting restricted content $restricted_text"
reject
}
}
- PeteWhiteEmployee
when HTTP_REQUEST_DATA { set payload [HTTP::payload] set value [class match -value [string tolower $payload] contains "restricted_dg"] if {$value != ""} { # set variable named restricted_text to the string found in $payload # that matches something in data-group restricted_dg log local0. "Rejecting restricted content $restricted_text :$value" reject } }
- spivAltocumulus
Thanks for your reply Pete.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com