Forum Discussion

Abu_Bakar_Afzal's avatar
Abu_Bakar_Afzal
Icon for Altostratus rankAltostratus
May 18, 2022

iRule with regex to allow illegal URL entry on ASM as string will change everytime.

How to write an iRule for ASM to allow a URL having a string which is everytime different. Like example.com/233.a7e26a504b20a18a6675.js  a7e26a504b20a18a6675 will be changed everytime. Below is the rule where I write an expression to allow but i am not sure about it will pass or still prompt illegal URL. I cannot test in production environment.

when HTTP_REQUEST {
if { [HTTP::path] matches_regex {233\.\w{20}\.js} } then { pool HTTP_Pool}
}

 

  • You can test your regex with something like regex101.com, so you can see that your Regex will work, but in this case this iRule has nothing to do with ASM (it is an LTM iRule). If you need to create an ASM policy to only allow URLs in this specific format you can use wildcard URL, but beware that wildcard entities in ASM do not support full Regex language and have a limited syntax (described here: https://support.f5.com/csp/article/K8623)