You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Perl::Critic::Policy::ValuesAndExpressions::PreventSQLInjection should not trigger on either:
my$sth = $dbh->prepare(q[ UPDATE `my_table` SET `data` = ? WHERE `id` = ?]);
$sth->execute( $new_data, $id )
or confess( "Update my_table failed. ($DBI::errstr)" );
or:
$dbh->do(q[ UPDATE `my_table` SET `data` = ? WHERE `id` = ?], undef, $new_data, $id)
or confess( "Update my_table failed. ($DBI::errstr)" );
The attached test file (which has an additional .txt to get around GitHub brain-damage) will pass when Perl::Critic::Policy::ValuesAndExpressions::PreventSQLInjection correctly handles the above cases; said test file is released under the Artistic 2.0 license (https://opensource.org/licenses/Artistic-2.0).
The plugin indeed catches "Update my_table failed. ($DBI::errstr)" as a potential risk due to the use of update as the leading word in this string, the double-quoting, and the use of an interpolated variable.
I would be happy to take a pull request if you're interested in implementing this, it's a good feature idea. Please note that all contributions to this module must be under the same terms as Perl 5 itself.
Perl::Critic::Policy::ValuesAndExpressions::PreventSQLInjection
should not trigger on either:or:
The attached test file (which has an additional
.txt
to get around GitHub brain-damage) will pass whenPerl::Critic::Policy::ValuesAndExpressions::PreventSQLInjection
correctly handles the above cases; said test file is released under the Artistic 2.0 license (https://opensource.org/licenses/Artistic-2.0).test_PreventSQLInjection_flagging_valid_constructs.t.txt
The text was updated successfully, but these errors were encountered: