Forum Discussion
Need help with proc irule
Hi,
I'm new to iRule, but have decent scripting skills with Perl. As explained in the below link, i tried the first example. When i try to save my iRule, I get the below exception. Note: My BigIP Version is 11.4. Any help is much appreciated. https://devcentral.f5.com/articles/getting-started-with-irules-procedures.UvuktfldWht
Thanks, Gopi
Exception caught in LocalLB::urn:iControl:LocalLB/Rule::create() Exception: Common::OperationFailed primary_error_code : 17236305 (0x01070151) secondary_error_code : 0 error_string : 01070151:3: Rule [/Common/gp_temp_proc] error: /Common/gp_temp_proc:1: error: [undefined procedure: rule][rule encodeHTML { proc html_encode { str } { set encoded "" foreach char [split $str ""] { switch $char { "<" { append encoded "<" } ">" { append encoded ">" } "'" { append encoded "'" } {"} { append encoded """ } "&" { append encoded "&" } default { append encoded $char } } } return $encoded } when RULE_INIT { iRule that calls the html_encode proc: set raw {some xss: < script > and sqli: ' or 1==1 "}
log local0. "HTML encoded: [call html_encode $raw]" } }]
2 Replies
- Kevin_Stewart
Employee
Jason is showing you what the iRule looks like in the config file. The "rule encodeHTML }" at the top, and the final closing curly brace are part of the rule definition. So to simulate what he's done, create a new rule called "encodeHTML" and start the proc with the "proc" command:
proc html_encode { str } { set encoded "" foreach char [split $str ""] { switch $char { "<" { append encoded "<" } ">" { append encoded ">" } "'" { append encoded "'" } {"} { append encoded """ } "&" { append encoded "&" } default { append encoded $char } } } return $encoded } - gprabhu_133561
Nimbostratus
Hi Kevin,
Thanks, i was able to save my first proc in irule.
-Gopi
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