Bugzilla – Attachment 169338 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]
[23.11.x] Bug 37018: Unit tests
2311x-Bug-37018-Unit-tests.patch (text/plain), 2.80 KB, created by
Tomás Cohen Arazi (tcohen)
on 2024-07-22 18:36:10 UTC
(
hide
)
Description:
[23.11.x] Bug 37018: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2024-07-22 18:36:10 UTC
Size:
2.80 KB
patch
obsolete
>From dbfb16865bd3c3631a2174730da68da1071a42bb Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 5 Jun 2024 14:19:06 +0100 >Subject: [PATCH] [23.11.x] Bug 37018: Unit tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > t/Koha/REST/Plugin/Query.t | 54 +++++++++++++++++++++++++++++++++++++- > 1 file changed, 53 insertions(+), 1 deletion(-) > >diff --git a/t/Koha/REST/Plugin/Query.t b/t/Koha/REST/Plugin/Query.t >index 4087feaba14..a36971eb13f 100755 >--- a/t/Koha/REST/Plugin/Query.t >+++ b/t/Koha/REST/Plugin/Query.t >@@ -206,6 +206,19 @@ get '/build_query' => sub { > }; > }; > >+get '/dbic_validate_operators' => sub { >+ my ( $c, $args ) = @_; >+ >+ my $query = $c->req->json->{q}; >+ >+ return try { >+ $c->dbic_validate_operators( { filtered_params => $query } ); >+ $c->render( json => { filtered_params => $query }, status => 200 ); >+ } catch { >+ return $c->render( json => { filtered_params => $query }, status => 400 ); >+ }; >+}; >+ > get '/stash_embed' => sub { > my $c = shift; > >@@ -294,7 +307,7 @@ sub to_model { > > # The tests > >-use Test::More tests => 7; >+use Test::More tests => 8; > use Test::Mojo; > > subtest 'extract_reserved_params() tests' => sub { >@@ -543,3 +556,42 @@ subtest 'stash_overrides() tests' => sub { > ->json_is( {} ); # x-koha-ovverride not passed is skipped > > }; >+ >+subtest 'dbic_validate_operators' => sub { >+ plan tests => 16; >+ >+ my $t = Test::Mojo->new; >+ >+ # Valid queries >+ my $q = {}; >+ $t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(200); >+ >+ $q = []; >+ $t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(200); >+ >+ $q = { >+ firstname => 'Bilbo', >+ lastname => 'Baggins' >+ }; >+ $t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(200); >+ >+ $q = { >+ firstname => undef, >+ lastname => 'Baggins' >+ }; >+ $t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(200); >+ >+ $q = { lastname => [ 'Gaggins', 'Gamgee' ] }; >+ $t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(200); >+ >+ $q = { lastname => { '!=' => [ 'Gaggins', 'Gamgee' ] } }; >+ $t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(200); >+ >+ $q = { status => { '!=', 'completed', -not_like => 'pending%' } }; >+ $t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(200); >+ >+ # Invalid queries >+ $q = [ { "-and" => [ [ { "biblio_id" => { "like(sleep(1/100000))or" => "%a%" } } ] ] } ]; >+ $t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(400); >+ >+}; >-- >2.45.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 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