Bugzilla – Attachment 167691 Details for
Bug 37018
SQL injection using q under api/
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37018: (follow-up) stop the execution when invalid query
Bug-37018-follow-up-stop-the-execution-when-invali.patch (text/plain), 2.82 KB, created by
Hammat wele
on 2024-06-13 16:32:22 UTC
(
hide
)
Description:
Bug 37018: (follow-up) stop the execution when invalid query
Filename:
MIME Type:
Creator:
Hammat wele
Created:
2024-06-13 16:32:22 UTC
Size:
2.82 KB
patch
obsolete
>From a37cb589c443b4184104b133b681933f60a97835 Mon Sep 17 00:00:00 2001 >From: Hammat Wele <hammat.wele@inlibro.com> >Date: Thu, 13 Jun 2024 16:31:50 +0000 >Subject: [PATCH] Bug 37018: (follow-up) stop the execution when invalid query > >prove t/Koha/REST/Plugin/Query.t should return OK, returning 400 when invalid operator is found >--- > Koha/REST/Plugin/Query.pm | 5 +++-- > t/Koha/REST/Plugin/Query.t | 25 ++++++++++++++++++------- > 2 files changed, 21 insertions(+), 9 deletions(-) > >diff --git a/Koha/REST/Plugin/Query.pm b/Koha/REST/Plugin/Query.pm >index a4160ac7d2..becc5419ef 100644 >--- a/Koha/REST/Plugin/Query.pm >+++ b/Koha/REST/Plugin/Query.pm >@@ -199,14 +199,15 @@ Validate operators in the passed query. > $app->helper( > 'dbic_validate_operators' => sub { > my ( $c, $args ) = @_; >- return try { >+ try { > _validate_query( $args->{filtered_params} ); > } catch { > if ( blessed $_ && $_->isa('Koha::Exceptions::BadParameter') ) { >- return $c->render( >+ $c->render( > status => 400, > json => { error => $_->error } > ); >+ Koha::Exceptions::BadParameter->throw( $_->error ); > } > }; > } >diff --git a/t/Koha/REST/Plugin/Query.t b/t/Koha/REST/Plugin/Query.t >index 477df53dc5..55385ac237 100755 >--- a/t/Koha/REST/Plugin/Query.t >+++ b/t/Koha/REST/Plugin/Query.t >@@ -207,13 +207,21 @@ get '/build_query' => sub { > }; > > get '/dbic_validate_operators' => sub { >- my ( $c, $args ) = @_; >+ my ( $c ) = @_; > >- my $query = $c->req->json->{q}; >+ try { >+ my $query = $c->req->json->{q}; > >- $c->dbic_validate_operators({ filtered_params => $query }); >+ $c->dbic_validate_operators({ filtered_params => $query }); > >- $c->render( json => { filtered_params => $query }, status => 200 ); >+ $c->render( json => { filtered_params => $query }, status => 200 ); >+ } >+ catch { >+ $c->render( >+ status => 400, >+ json => { error => "$_" } >+ ); >+ }; > }; > > get '/stash_embed' => sub { >@@ -646,7 +654,7 @@ subtest 'dbic_extended_attributes_join() tests' => sub { > }; > > subtest 'dbic_validate_operators' => sub { >- plan tests => 16; >+ plan tests => 17; > > my $t = Test::Mojo->new; > >@@ -680,6 +688,9 @@ subtest 'dbic_validate_operators' => sub { > > # Invalid queries > $q = [ { "-and" => [ [ { "biblio_id" => { "like(sleep(1/100000))or" => "%a%" } } ] ] } ]; >- $t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(400); >- >+ $t->get_ok( '/dbic_validate_operators' => json => { q => $q } ) >+ ->status_is(400) >+ ->json_is( '/error' => >+ qq{Exception 'Koha::Exceptions::BadParameter' thrown 'Invalid operator in query: like(sleep(1/100000))or'\n} >+ ); > }; >-- >2.34.1
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 37018
:
167440
|
167441
|
167442
|
167446
|
167447
|
167448
|
167449
|
167603
|
167672
|
167691
|
167772
|
168458
|
168582
|
168583
|
168584
|
168585
|
168586
|
168587
|
168616
|
168617
|
168618
|
168619
|
168620
|
168621
|
168622
|
168624
|
168626
|
168627
|
168628
|
168629
|
168630
|
168631
|
168632
|
168633
|
168634
|
168635
|
168654
|
168655
|
168656
|
168657
|
168658
|
168659
|
168660
|
168661
|
168662
|
168695
|
168696
|
168697
|
168698
|
168699
|
168700
|
168701
|
168702
|
168703
|
168704
|
168786
|
168787
|
168788
|
168789
|
168790
|
168791
|
168792
|
168793
|
168794
|
168795
|
169309
|
169337
|
169338
|
169339
|
169340
|
169341
|
169342
|
169343
|
169344
|
169345
|
169346
|
169368
|
169369
|
169370
|
169371
|
169372
|
169373
|
169374
|
169375
|
169376
|
169377
|
169378
|
169414
|
169832
|
169833
|
169834
|
169835
|
169836
|
169837
|
169838
|
169839
|
169840
|
169841