Forum Discussion

chris_p_clark_1's avatar
chris_p_clark_1
Icon for Nimbostratus rankNimbostratus
Apr 13, 2017

Set HTTP::header when ASM_REQUEST_DONE

I want to set a header within the ASM_REQUEST_DONE event. I have the logic to do what I need but it does not set the header. There are examples on this site of people doing it but it does not work for me, any thoughts. ASM 11.6.0

when ASM_REQUEST_DONE {

foreach {viol} [ASM::violation names] {
  log local0. "Violation is $viol"
  if {$viol eq "VIOLATION_HTTP_SANITY_CHECK_FAILED"} {
      log local0. "Yep, found VIOLATION_HTTP"
      HTTP::header insert "WAF VIOLATION_HTTP"
    } 
}

}

  • Hi, you could try something like this:

    when ASM_REQUEST_DONE {
        if { [ASM::status] ne "clear" } {
            foreach {viol} [ASM::violation names] {
              log local0. "Violation is $viol"
              if {$viol eq "VIOLATION_HTTP_SANITY_CHECK_FAILED"} {
                  log local0. "Yep, found VIOLATION_HTTP"
                    set violation_http_found 1
                } 
            }
        }
    }
    when HTTP_RESPONSE_RELEASE {
        if { [info exists violation_http_found] } {
            HTTP::header insert WAF VIOLATION_HTTP
            unset violation_http_found
        }
    }
    

    Regards.