cancel
Showing results for 
Search instead for 
Did you mean: 

Print string found in Data Group to Log

spiv
Altocumulus
Altocumulus

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

       }

}

2 REPLIES 2

PeteWhite
F5 Employee
F5 Employee
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 } }

 

Thanks for your reply Pete.