Forum Discussion

TJ_Vreugdenhil's avatar
Oct 02, 2012

iRule syntax issue

I have tried to validate the iRule below, but it errors with:

 

[braces are required around the expression][when HTTP_RESPONSE {

 

 

Cookie Management Verification

 

when HTTP_RESPONSE {

 

if {[HTTP::cookie count] > 0} {

 

set maxCookieSize [class match -value "CookieMaxSize" equals COOKIE_INFO_LIST]

 

foreach cookie_name [HTTP::cookie names] {

 

if {![class match $cookie_name equals MASTER_COOKIE_JAR_LIST]}{

 

log local0.info "INVALID SET-COOKIE DETECTED – Cookie:$cookie_name"

 

}

 

set cookieSize [string length [HTTP::cookie $cookie_name]]

 

if [ $cookieSize > $maxCookieSize ] {

 

log local0.info "INVALID SET-COOKIE SIZE – $cookieSize for Cookie:$cookie_name"

 

}

 

}

 

}

 

}

 

3 Replies

  • I had to retype it from scratch to get it to behave and only alert on the DataGroup Names.

     
    when HTTP_RESPONSE {
    if { [HTTP::cookie count] > 0 } {
    set maxCookieSize [class match -value "CookieMaxSize" equals COOKIE_INFO_LIST]
    foreach cookie_name [HTTP::cookie names] {
    if { ![class match $cookie_name equals MASTER_COOKIE_JAR_LIST] } {
    log local0. "INVALID SET-COOKIE DETECTED - Cookie: $cookie_name"
    }
    set cookieSize [string length [HTTP::cookie $cookie_name]]
    if { $cookieSize > $maxCookieSize } {
    log local0. "INVALID SET-COOKIE Size - $cookieSize for Cookie:$cookie_name"
    }
    }
    }
    }
    
  • I see what was wrong now, incorrect brackets here:

     

    [ $cookieSize > $maxCookieSize ]

     

    should be { }