For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Abe_11636's avatar
Abe_11636
Icon for Cirrus rankCirrus
Feb 04, 2016

BrowserMetrix JavaScript snippet using F5 BIG-IP appliances

Hello,

On of my app needs the following> The VIP serves many applications. How do we set so one 1 app get this injection. i.e /newapp

The irule for this vip would be: when RULE_INIT { set static::jscript { } }

when HTTP_REQUEST { Disable the stream filter by default STREAM::disable set uri [string tolower [HTTP::uri]] }

when HTTP_RESPONSE { if { [HTTP::status] == 200 } { if {[HTTP::header value Content-Type] contains "text"} { set stream_find "" set stream_find_lower "" set stream_repl "" set insertJscript 1

         Do not allow the Javascript insertion if the pages end with the following
        switch -glob $uri { 
            "*.ashx*" - 
            "*.asmx*" - 
            "*.axd*" - 
            "*.js*" { 
                set insertJscript 0 
            }
            default {
                if { [HTTP::payload] contains "META HTTP-EQUIV=\"Refresh\""} { 
                    set insertJscript 0 
                }
            }
        }

        if {$insertJscript == 1} { 
            append stream_repl $static::jscript
            append stream_expression "@$stream_find@$stream_repl$stream_find@" 
            append stream_expression "@$stream_find_lower@$stream_repl$stream_find_lower@" 

            STREAM::expression $stream_expression 
            STREAM::enable 
        }
    }
}

}

No RepliesBe the first to reply