Forum Discussion

john_waterworth's avatar
john_waterworth
Icon for Nimbostratus rankNimbostratus
Oct 14, 2014

after upgrading from 11.2 to 11.6 getting the following warning

/Common/Defend-epweb-v3:57: warning: [use curly braces to avoid double substitution][0x[substr $ip 6 2]] /Common/Defend-epweb-v3:57: warning: [use curly braces to avoid double substitution][0x[substr $ip 4 2]] /Common/Defend-epweb-v3:57: warning: [use curly braces to avoid double substitution][0x[substr $ip 2 2]] /Common/Defend-epweb-v3:57: warning: [use curly braces to avoid double substitution][0x[substr $ip 0 2]] /Common/Defend-epweb-v3:57: warning: [use curly braces to avoid double substitution][0x[substr $port 2 2][substr $port 0 2]]

 

Here is the iRule

 

when HTTP_REQUEST {

 

Check for requests that have both "sid=" and "vid=" in the query string if {([URI::query [HTTP::uri] sid] ne "") && ([URI::query [HTTP::uri] vid] ne "")} { Create the session-table key for counting repeated requests. set key "S=[URI::query [HTTP::uri] sid]&V=[URI::query [HTTP::uri] vid]&B=[HTTP::method]&U=[HTTP::path]" When the pageturnandrenewal transaction is seen, include the "thePageNum" parameter if present. if {([HTTP::path] contains "ebookViewer/pageturnandrenewal") && ([URI::query [HTTP::uri] thePageNum] ne "")} { set key "$key&P=[URI::query [HTTP::uri] thePageNum]" }

 

set value [table incr $key]
 If the entry is new, set its lifetime.
if {$value == 1} {
  table lifetime $key $defend_error_lifetime
  table timeout $key indefinite
}

 Check for the looping condition.
if {$value > $defend_error_threshold} {

  If a key is determined to be looping, extend its lifetime so we continue to reject it.
  table lifetime $key $defend_failure_lifetime
  table timeout $key indefinite

   Log messages periodically.
  if {(($value - $defend_error_threshold) % $defend_log_interval) == 1} {
     URL encode the User-Agent value because it can have spaces in it.
    set user_agent [URI::encode [HTTP::header user-agent]]
    set url "http://[HTTP::host][HTTP::uri]"

     Make sure that the user_agent and referer fields are not null,
     so each log entry has the same number of space-delimited fields.
    if {$user_agent eq ""} {
      set user_agent "-"
    }
    set referer [HTTP::header referer]
    if {$referer eq ""} {
      set referer "-"
    }

    set server "-"
    set pool [LB::server pool]
    set index [string last / [LB::server pool]]

    if {$index != -1} {
        catch {set length [scan {[scan [string length [LB::server pool]] %i] - [scan $index %i]} %i]}
        catch {set pool [string tolower "[substr [LB::server pool] [incr index] $length]"]}
    }

    foreach cookie [HTTP::cookie names] {
        if {([string equal "[string tolower $cookie]" "bigipserver$pool"]) || 
        ([string equal "[string tolower $cookie]" usenide])} {
            catch {scan [HTTP::cookie $cookie] {%[^\.].%d.%d} ip port unused}
            catch {set ip [format %08x $ip]}
            catch {set port [format %04x $port]}
            if {[catch {set server "[expr 0x[substr $ip 6 2]].[expr 0x[substr $ip 4 2]].[expr 0x[substr $ip 2 2]].[expr 0x[substr $ip 0 2]]:[string trimleft [expr 0x[substr $port 2 2][substr $port 0 2]] 0]"}]} {
                set server "-"
            }
      }
    }

    log local0. "Loop: Value=$value Client=[IP::client_addr] Method=[HTTP::method] Server=$server Agent=$user_agent URL=$url Referer=$referer"
  }
Text of the response. 
set response_content "
    Error
    
    A System Problem has Occurred.
    Error Code = F1310015
    Data = [URI::query [HTTP::uri] sid]
    
    "

 if {$defend_do_turnaways} {
                  HTTP::respond $defend_response_status_code \
                  content $response_content \
                  content-length [string length $response_content] \
                  content-type $defend_response_content_type
  }
}

} }