Forum Discussion
input validation
Hi all,
I'm wondering that there are no useful search results for input validation of user-input in irules. I want to do a simple task:
when HTTP_REQUEST {
set cookie [HTTP::cookie id]
}
I do some additional tasks (log, fill tables, ...) with $cookie, but prior to this I want to proper validate the input from HTTP::cookie and I'm not sure how to do that in a right way.
Thanks for your suggestions, Philipp
2 Replies
- Arie
Altostratus
Are you asking how to read (and validate) values from a cookie that is sent by the client?
- Kevin_Stewart
Employee
Here's just one way to do it:
when HTTP_REQUEST { if { ( [HTTP::cookie exists MYCOOKIE] ) and ( [HTTP::cookie value MYCOOKIE] matches_regex {\d{6}-[0-9A-F]{8}\d{8}} ) } { log local0. "match" } else { log local0. "not match" } }The matches_regex {\d{6}-[0-9A-F]{8}\d{8}} function would validate any value that starts with 6 digits, then a hyphen, then 8 hexadecimal values (0-9A-F), and followed by 6 digits.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com