maximillean_953
Apr 11, 2019Nimbostratus
regex irule without payload change
Hi, I try to write an irule which logs client ip with posted username on a json request. I can able to gather full post payload but that includes the password and other info so i generate a regex to only write the client ip and username on the log file but when i use regex vserver starts to reset connection. If i avoid regex and collect ip and full json payload no problem. Can anyone help me regarding this example? Appriciated.
when HTTP_REQUEST {
if { [HTTP::method] eq "POST" and [HTTP::uri] starts_with "/api/test/login" } {
set log_msg ""
set client_ip [IP::remote_addr]
set paypay [HTTP::payload]
set pay [HTTP::payload]
append log_msg "client_ip=$client_ip "
append log_msg [regexp {(?<=\{"username":").*?(?=",)} $paypay]
append log_msg "$paypay"
log local0. $payload
log 1.1.1.1 local0. $log_msg
}
}