Bugzilla – Attachment 171125 Details for
Bug 36598
Add CSRF protection to Mojolicious apps
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36598: (QA follow-up): tidy up code
Bug-36598-QA-follow-up-tidy-up-code.patch (text/plain), 4.52 KB, created by
Marcel de Rooy
on 2024-09-06 07:40:36 UTC
(
hide
)
Description:
Bug 36598: (QA follow-up): tidy up code
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2024-09-06 07:40:36 UTC
Size:
4.52 KB
patch
obsolete
>From 7d48af568f103731dc504bb1fc1f6b3093022631 Mon Sep 17 00:00:00 2001 >From: Victor Grousset/tuxayo <victor@tuxayo.net> >Date: Tue, 14 May 2024 20:39:00 +0200 >Subject: [PATCH] Bug 36598: (QA follow-up): tidy up code >Content-Type: text/plain; charset=utf-8 > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/App/Plugin/CSRF.pm | 8 ++++++-- > t/db_dependent/mojo/csrf.t | 24 ++++++++++++++++-------- > 2 files changed, 22 insertions(+), 10 deletions(-) > >diff --git a/Koha/App/Plugin/CSRF.pm b/Koha/App/Plugin/CSRF.pm >index 5e487fb097..9a38c84afa 100644 >--- a/Koha/App/Plugin/CSRF.pm >+++ b/Koha/App/Plugin/CSRF.pm >@@ -75,12 +75,16 @@ sub register { > if ( $method eq 'GET' || $method eq 'HEAD' || $method eq 'OPTIONS' || $method eq 'TRACE' ) { > my $op = $c->req->param('op'); > if ( $op && $op =~ /^cud-/ ) { >- return $c->reply->exception('Incorrect use of a safe HTTP method with an `op` parameter that starts with "cud-"')->rendered(400); >+ return $c->reply->exception( >+ 'Incorrect use of a safe HTTP method with an `op` parameter that starts with "cud-"') >+ ->rendered(400); > } > } else { > my $op = $c->req->param('op'); > if ( $op && $op !~ /^cud-/ ) { >- return $c->reply->exception('Incorrect use of an unsafe HTTP method with an `op` parameter that does not start with "cud-"')->rendered(400); >+ return $c->reply->exception( >+ 'Incorrect use of an unsafe HTTP method with an `op` parameter that does not start with "cud-"') >+ ->rendered(400); > } > > if ( $c->cookie('CGISESSID') && !$self->is_csrf_valid( $c->req ) ) { >diff --git a/t/db_dependent/mojo/csrf.t b/t/db_dependent/mojo/csrf.t >index 70ee65a812..511cf1a7ff 100755 >--- a/t/db_dependent/mojo/csrf.t >+++ b/t/db_dependent/mojo/csrf.t >@@ -43,15 +43,19 @@ subtest 'CSRF - Intranet' => sub { > subtest 'GETting what should be POSTed should fail' => sub { > plan tests => 3; > >- $t->get_ok('/cgi-bin/koha/mainpage.pl?op=cud-login')->status_is(400) >- ->content_like( qr/Incorrect use of a safe HTTP method with an `op` parameter that starts with "cud-"/, 'Body contains correct error message' ); >+ $t->get_ok('/cgi-bin/koha/mainpage.pl?op=cud-login')->status_is(400)->content_like( >+ qr/Incorrect use of a safe HTTP method with an `op` parameter that starts with "cud-"/, >+ 'Body contains correct error message' >+ ); > }; > > subtest 'POSTing what should be GET should fail' => sub { > plan tests => 3; > >- $t->post_ok('/cgi-bin/koha/mainpage.pl?op=login')->status_is(400) >- ->content_like( qr/Incorrect use of an unsafe HTTP method with an `op` parameter that does not start with "cud-"/, 'Body contains correct error message' ); >+ $t->post_ok('/cgi-bin/koha/mainpage.pl?op=login')->status_is(400)->content_like( >+ qr/Incorrect use of an unsafe HTTP method with an `op` parameter that does not start with "cud-"/, >+ 'Body contains correct error message' >+ ); > }; > }; > >@@ -91,14 +95,18 @@ subtest 'CSRF - OPAC' => sub { > subtest 'GETting what should be POSTed should fail' => sub { > plan tests => 3; > >- $t->get_ok('/cgi-bin/koha/opac-user.pl?op=cud-login')->status_is(400) >- ->content_like( qr/Incorrect use of a safe HTTP method with an `op` parameter that starts with "cud-"/, 'Body contains correct error message' ); >+ $t->get_ok('/cgi-bin/koha/opac-user.pl?op=cud-login')->status_is(400)->content_like( >+ qr/Incorrect use of a safe HTTP method with an `op` parameter that starts with "cud-"/, >+ 'Body contains correct error message' >+ ); > }; > > subtest 'POSTing what should be GET should fail' => sub { > plan tests => 3; > >- $t->post_ok('/cgi-bin/koha/opac-user.pl?op=login')->status_is(400) >- ->content_like( qr/Incorrect use of an unsafe HTTP method with an `op` parameter that does not start with "cud-"/, 'Body contains correct error message' ); >+ $t->post_ok('/cgi-bin/koha/opac-user.pl?op=login')->status_is(400)->content_like( >+ qr/Incorrect use of an unsafe HTTP method with an `op` parameter that does not start with "cud-"/, >+ 'Body contains correct error message' >+ ); > }; > }; >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36598
:
164847
|
164848
|
164870
|
165075
|
165076
|
166094
|
166634
|
166673
|
166675
|
166727
|
166728
|
166729
|
166730
|
166731
|
166732
|
166733
|
171119
|
171120
|
171121
|
171122
|
171123
|
171124
| 171125