Can't search for "Carole"

For requests or help with our API
Post Reply
graham_mueller
Posts: 46
Joined: Fri Jan 19, 2024 10:57 am

Can't search for "Carole"

Post by graham_mueller »

A weird, random thing we ran into today. A user searched for a patient named Carole...

Code: Select all

Query cannot contain "ROLE"
I thought surely I must have made a mistake somewhere and that it wasn't that, but searching "Caole" (or something real, like John) works fine.

This is from a call to the ShortQuery endpoint, the query is

Code: Select all

SELECT COUNT(*) as count
  FROM patient
 WHERE PatStatus NOT IN (3, 4)
   AND (
        CONCAT(TRIM(FName), ' ', TRIM(LName)) LIKE '%carole%'
            OR Email LIKE '%carole%'
            OR HmPhone LIKE '%carole%'
            OR WkPhone LIKE '%carole%'
            OR WirelessPhone LIKE '%carole%'
      )
SLeon
Posts: 605
Joined: Mon Mar 01, 2021 10:00 am

Re: Can't search for "Carole"

Post by SLeon »

Good morning. The Open Dental API screens all payload queries in Queries POST and Queries PUT ShortQuery request to be read-only (or on temp tables). It also screens out SQL actions that are inappropriate to perform via the API, such as the SLEEP command.

The reserved word "ROLE" is used to view, create, or revoke permissions for mysql users. Naturally, this is inappropriate to perform via the API. The word "ROLE" is used with the keywords "CREATE", "DROP", "SET", or "RESET". Because those keywords are allowed on temp tables, we added "ROLE" to our list of forbidden words. Additionally, it is designed this way because it can't effectively screen "CREATE ROLE" or "CREATE /*comment*/ ROLE" without looking for just "ROLE".
graham_mueller
Posts: 46
Joined: Fri Jan 19, 2024 10:57 am

Re: Can't search for "Carole"

Post by graham_mueller »

I understand the limitations of your query API, but if you're going to search for the text "role," could you at least make it "freestanding," prefixed by a non-word character or something sane to prevent this sort of failure? This behavior is different for (eg) SET, searching for a patient named Seth or Rosette does not have the same problem.
graham_mueller
Posts: 46
Joined: Fri Jan 19, 2024 10:57 am

Re: Can't search for "Carole"

Post by graham_mueller »

Heck, I can run that query with just the word CREATE, DROP, or SET and it works. It only fails with ROLE.
SLeon
Posts: 605
Joined: Mon Mar 01, 2021 10:00 am

Re: Can't search for "Carole"

Post by SLeon »

I realize failed to mention in my last post that I intended too further look into our screening logic to see what we can (safely) do. I will update this thread when I do. However, it is lower priority than API Feature Requests.
User avatar
jordansparks
Site Admin
Posts: 5776
Joined: Sun Jun 17, 2007 3:59 pm
Location: Salem, Oregon
Contact:

Re: Can't search for "Carole"

Post by jordansparks »

Our filter needs to be better. It should use regular expressions to ignore those keywords if present inside of quotes.
Jordan Sparks, DMD
http://www.opendental.com
graham_mueller
Posts: 46
Joined: Fri Jan 19, 2024 10:57 am

Re: Can't search for "Carole"

Post by graham_mueller »

An additional random word check that's failing-

Code: Select all

Query cannot contain "SLOW".
When searching for, eg, John Oslow.
justine
Posts: 354
Joined: Tue Dec 28, 2021 7:59 am

Re: Can't search for "Carole"

Post by justine »

graham_mueller wrote: Mon Jan 20, 2025 11:04 am An additional random word check that's failing-

Code: Select all

Query cannot contain "SLOW".
When searching for, eg, John Oslow.
Thanks for the heads up, this ShortQuery endpoint enhancement is coming up next. I have added 'John Oslow' to the job/unit test requirements.

Thanks!
RyanH
Posts: 69
Joined: Thu Dec 19, 2024 8:33 am

Re: Can't search for "Carole"

Post by RyanH »

Hello graham_mueller,

We have completed this feature request, and the implementation is live on our beta. The query screening algorithm has been enhanced to not falsely flag reserved or forbidden keywords if they are contained within other words. Your examples of “ROLE” in “Carole” or “SLOW” in “John Oslow” will now pass the screening.
graham_mueller
Posts: 46
Joined: Fri Jan 19, 2024 10:57 am

Re: Can't search for "Carole"

Post by graham_mueller »

Hi all,

As of Februrary, this was listed as in beta, I assume at some point after it was promoted. We are still encountering the issue, though. Search was again, for Carole.

ETA: This log is from 2025-07-26T00:48:28.709790318Z
Attachments
Screenshot 2025-07-29 at 11.06.53 AM.png
Screenshot 2025-07-29 at 11.06.53 AM.png (22.97 KiB) Viewed 48005 times
justine
Posts: 354
Joined: Tue Dec 28, 2021 7:59 am

Re: Can't search for "Carole"

Post by justine »

graham_mueller wrote: Tue Jul 29, 2025 8:07 am Hi all,

As of Februrary, this was listed as in beta, I assume at some point after it was promoted. We are still encountering the issue, though. Search was again, for Carole.

ETA: This log is from 2025-07-26T00:48:28.709790318Z
Good morning graham_mueller,

Enhanced queries screening was implemented in version 24.4.23. What version are you on? What does the exact query you are running look like?

Thanks!
graham_mueller
Posts: 46
Joined: Fri Jan 19, 2024 10:57 am

Re: Can't search for "Carole"

Post by graham_mueller »

Ah, I had thought this filtering was done in the OpenDental central API layer. I am not sure what that clinic is using, but presumably lower. I guess we'll have to add a workaround for any clients that are below that.
Post Reply