Bugzilla – Attachment 169376 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.05.x] Bug 37018: Clarify operators
2305x-Bug-37018-Clarify-operators.patch (text/plain), 3.31 KB, created by
Tomás Cohen Arazi (tcohen)
on 2024-07-22 19:12:08 UTC
(
hide
)
Description:
[23.05.x] Bug 37018: Clarify operators
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2024-07-22 19:12:08 UTC
Size:
3.31 KB
patch
obsolete
>From 4d630fcac802d67f539494e0273c3a71ee5325c9 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 10 Jul 2024 09:39:33 +0100 >Subject: [PATCH] [23.05.x] Bug 37018: Clarify operators > >This patch clarifies the list of operators both in the validate routine >and in the swagger descrption block where we document this feature for >the end user. > >JD amended patch: tidy > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > Koha/REST/Plugin/Query.pm | 3 ++- > api/v1/swagger/swagger.yaml | 16 +++++++++++++++- > 2 files changed, 17 insertions(+), 2 deletions(-) > >diff --git a/Koha/REST/Plugin/Query.pm b/Koha/REST/Plugin/Query.pm >index 5718ec8ac25..ae4edac15c5 100644 >--- a/Koha/REST/Plugin/Query.pm >+++ b/Koha/REST/Plugin/Query.pm >@@ -512,7 +512,8 @@ sub _parse_dbic_query { > sub _validate_operator { > my ($operator) = @_; > my %allowed_operators = >- map { $_ => 1 } qw(= != < > <= >= like -not_like -in -ident -bool -not_bool -or -like -not -and -regexp); >+ map { $_ => 1 } >+ qw(= != < > <= >= -in -ident -bool -not_bool -or like -like -not_like -between -not_between -not -and -regexp); > Koha::Exceptions::REST::Query::InvalidOperator->throw( operator => $operator ) > unless exists $allowed_operators{$operator}; > return; >diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml >index db7c4bb0a75..d54b10b3c9c 100644 >--- a/api/v1/swagger/swagger.yaml >+++ b/api/v1/swagger/swagger.yaml >@@ -729,13 +729,27 @@ info: > We can refine that with more complex matching clauses by nesting a the clause into the > object; `{ "fieldname": { "clause": "value" } }`. > >- Available matching clauses include `>`, `<`, `>=`, `<=`, `-like`, and `-not_like`. >+ Available matching clauses include `=`, `!=`, `<`, `>`, `<=`, `>=` and `-not`. We also support `-like` >+ and `-not_like` string comparisons with `%` used to denote wildcards, thus you can pass >+ `{ "fieldname": { "-like": "value%" } }` to do a 'starts with' string match for example. > > We can filter on multiple fields by adding them to the JSON respresentation. Adding at `HASH` > level will result in an "AND" query, whilst combinding them in an `ARRAY` will result in an > "OR" query: `{ "field1": "value2", "field2": "value2" }` will filter the response to only those > results with both field1 containing value2 AND field2 containing value2 for example. > >+ There is a collection of special operators also available to you, including: >+ >+ * `-in` - Expects an array of values to perform an OR match against >+ * `-not_in` - Expects an array of values to perform a NOR match against >+ * `-between` - Expects two values which the value of the field is expected to fall between >+ * `-not_between` - Expects two values which the value of the field is expected to fall outside of >+ * `-ident` - Expects a second field name to match the two field values against >+ * `-regexp` - Expects a perl compatible regular expression for which the value should match >+ >+ Logic and nesting is also supported and you may use `-and` and `-or` to change the logic of an ARRAY >+ or HASH as described above. >+ > Additionally, if you are requesting related data be embedded into the response one can query > on the related data using dot notation in the field names. > >-- >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