Forum Discussion
find an dreplace XML Value with irule
I made a couple of tweaks to the script below:
when HTTP_REQUEST {
log local0. "Inside Request"
if { [HTTP::host] contains "dev.integration.services.7-5.identifythebest.com" } {
if {[HTTP::method] eq "POST" && [HTTP::header value Content-Type] contains "text/xml"}{
log local0. "Inside IF"
HTTP::collect [HTTP::header Content-Length]
HTTP::header remove "Accept-Encoding"
HTTP::collect
}
}
}
when HTTP_REQUEST_DATA {
log local0. "Inside Request_data"
set offset [string first {"SSN">} [HTTP::payload]]
set length [expr {[string first {<} [HTTP::payload] $offset] - $offset}]
log local0. "Offset $offset length $length"
log local0. "Replacing [HTTP::payload $offset $length]"
log local0. [HTTP::payload]
HTTP::payload replace $offset $length {"SSN">--}
}
Now I get the following output:
Aug 20 07:17:49 local/tmm info tmm[5162]: Rule _xml_scrubber : Inside Request
Aug 20 07:17:49 local/tmm info tmm[5162]: Rule _xml_scrubber : Inside Request
Aug 20 07:17:49 local/tmm info tmm[5162]: Rule _xml_scrubber : Inside IF
Aug 20 07:17:50 local/tmm info tmm[5162]: Rule _xml_scrubber : Inside Request_data
Aug 20 07:17:50 local/tmm info tmm[5162]: Rule _xml_scrubber : Offset 1138 length 17
Aug 20 07:17:50 local/tmm info tmm[5162]: Rule _xml_scrubber : Replacing "SSN">555-55-5555
Aug 20 07:17:50 local/tmm info tmm[5162]: Rule _xml_scrubber : 91f0f42d-8529-4725-9429-9b2edcb92abaTa13oPint3rgrat10nabdd33e8-f7ef-4808-b06b-6d06d2309fdb25122cb16ddd9-3e71-4337-b593-cb9a8bb9c48e7de4511aa-e973-4ab6-a224-02a841
From looking at a packet capture the whole post is in one packet, but the output of the payload appears truncated. any advice?
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