Commit 2fcd037
fix: OCI26ai sql query patches (#5046)
# What does this PR do?
<!-- Provide a short summary of what this PR does and why. Link to
relevant issues if applicable. -->
Parameterizes SQL queries to prevent injection in the sqlstore and OCI
providers.
- Replace manual string escaping (`replace("'", "''")`) with
parameterized bind variables in the authorized sqlstore's access control
WHERE
clause builder
- Fix SQL injection in OCI 26AI vector_io provider where `chunk_id`
values were directly concatenated into a `DELETE` query
- Add `where_sql_params` support to the `SqlStore` protocol and
SQLAlchemy implementation so raw SQL clauses can carry bound parameters
- Add a pre-commit hook to detect f-string interpolation in SQL
statements and prevent regressions
<!-- If resolving an issue, uncomment and update the line below -->
<!-- Closes #[issue-number] -->
Closes RHAIENG-3254
## Test Plan
<!-- Describe the tests you ran to verify your changes with result
summaries. *Provide clear instructions so the plan can be easily
re-executed.* -->
Existing unit tests pass (`test_authorized_sqlstore.py`,
`test_sqlstore.py` — 15/15)
Pre-commit hooks pass on all modified files
<!-- For API changes, include:
1. A testing script (Python, curl, etc.) that exercises the new/modified
endpoints
2. The output from running your script
Example:
```python
...
...
```
Output:
```
<paste actual output here>
```
-->
Signed-off-by: Doug Edgar <dedgar@redhat.com>
Co-authored-by: Charlie Doern <cdoern@redhat.com>1 parent 7fa5738 commit 2fcd037
5 files changed
Lines changed: 64 additions & 25 deletions
File tree
- src
- llama_stack_api/internal
- llama_stack
- core/storage/sqlstore
- providers/remote/vector_io/oci
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
224 | 251 | | |
225 | 252 | | |
226 | 253 | | |
| |||
Lines changed: 22 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
165 | 166 | | |
166 | 167 | | |
167 | 168 | | |
168 | | - | |
| 169 | + | |
169 | 170 | | |
170 | 171 | | |
171 | 172 | | |
172 | 173 | | |
| 174 | + | |
173 | 175 | | |
174 | 176 | | |
175 | 177 | | |
| |||
236 | 238 | | |
237 | 239 | | |
238 | 240 | | |
239 | | - | |
| 241 | + | |
240 | 242 | | |
241 | 243 | | |
| 244 | + | |
242 | 245 | | |
243 | 246 | | |
244 | 247 | | |
| |||
294 | 297 | | |
295 | 298 | | |
296 | 299 | | |
297 | | - | |
| 300 | + | |
298 | 301 | | |
299 | 302 | | |
| 303 | + | |
300 | 304 | | |
301 | 305 | | |
302 | 306 | | |
303 | 307 | | |
| 308 | + | |
304 | 309 | | |
305 | 310 | | |
306 | | - | |
307 | | - | |
308 | | - | |
| 311 | + | |
| 312 | + | |
309 | 313 | | |
310 | | - | |
311 | 314 | | |
312 | 315 | | |
313 | 316 | | |
314 | 317 | | |
315 | | - | |
316 | | - | |
317 | | - | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
318 | 321 | | |
319 | | - | |
| 322 | + | |
| 323 | + | |
320 | 324 | | |
321 | 325 | | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
| 326 | + | |
326 | 327 | | |
327 | | - | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
328 | 331 | | |
329 | 332 | | |
| 333 | + | |
330 | 334 | | |
331 | 335 | | |
332 | 336 | | |
333 | 337 | | |
334 | 338 | | |
335 | | - | |
336 | 339 | | |
337 | | - | |
| 340 | + | |
338 | 341 | | |
339 | | - | |
| 342 | + | |
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| 190 | + | |
190 | 191 | | |
191 | 192 | | |
192 | 193 | | |
| |||
200 | 201 | | |
201 | 202 | | |
202 | 203 | | |
203 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
204 | 208 | | |
205 | 209 | | |
206 | 210 | | |
| |||
287 | 291 | | |
288 | 292 | | |
289 | 293 | | |
| 294 | + | |
290 | 295 | | |
291 | 296 | | |
292 | | - | |
| 297 | + | |
293 | 298 | | |
294 | 299 | | |
295 | 300 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
428 | 432 | | |
429 | 433 | | |
430 | 434 | | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
| 435 | + | |
| 436 | + | |
435 | 437 | | |
436 | 438 | | |
437 | 439 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| 64 | + | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
| |||
0 commit comments