Mojolicious::Plugin::FormValidatorLazy - FormValidatorLazy
plugin form_validator_lazy => { namespace => 'form_validator_lazy', action => ['/receptor1'], blackhole => sub { my ($c, $error) = @_; app->log($error); $c->res->code(400); $c->render(text => 'An error occured'); }, };
This software is considered to be alpha quality and isn't recommended for regular usage.
Mojolicious::Plugin::FormValidatorLazy is a Mojolicious plugin for validating post data with auto-generated validation rules out of original forms. It analizes the HTML forms before sending them to client, generate the schema, inject it into original forms within a hidden fields so the plugin can detect the schema when a post request comes.
The plugin detects following error for now.
The form fields represented by name attribute are all white listed and post data injected unknown fields are blocked.
Selectable values of checkboxes, radio buttons and select options are white listed and unknow values are blocked.
The plugin also detects characteristics of tag types. Such as unchecked checkboxes don't appear to data(not required), radio buttons can't be null only when default value is offered(not null), and so on.
Hidden typed input can't be ommited(required) and the value takes only one option. the plugin blocks values against the schema.
Values violating of maxlength are blocked.
HTML5 supports some validation attributes such as [required], [pattern=*], [type=number], [min=*], [max=*]. The plugin detects them and block violations.
This also detects CSRF.
Run t/test_app.pl and try to attack the forms.
./t/test_app.pl daemon
Generates a schema strings of form structure for each forms in mojo response and inject them into itself.
my $injected = inject($html, $charset, ['/path1', '/path2'], $token_key, $session_id);
Sugama Keita, <sugama@jamadam.com>
Copyright (C) Sugama Keita.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Mojolicious::Plugin::FormValidatorLazy, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::FormValidatorLazy
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::FormValidatorLazy
For more information on module installation, please visit the detailed CPAN module installation guide.