Commit edeea84
committed
fix(reports): owner-gate the saved-report schedule routes (#2980)
`unscheduleReport` and `listSchedules` took the caller context as `_context`
and never consulted it, querying under the RLS-bypassing system context. Any
authenticated caller could delete another owner's report schedule (a cross-owner
destructive write) or list another owner's schedules (leaking recipients + cron)
by supplying an id, even though the sibling read/run/delete routes are all
owner-isolated.
Both now resolve the schedule's parent report and require the caller to own it,
mirroring the sibling routes:
- unscheduleReport: loads the schedule, then its report, and deletes only when
canAccessReport holds; a cross-owner attempt throws REPORT_NOT_FOUND
(mapped to 404 in the REST layer — deny-as-404, anti-enumeration), while a
genuinely-absent schedule stays idempotent. Create was already gated via
getReport, so only the delete/list doors were open.
- listSchedules: returns an empty list to any non-system caller who cannot
access the report it is scoped to — the same non-leaking posture as
listReports. The scheduler's system context still sees every schedule.
Tests: 5 new owner-gate cases in report-service.test.ts (cross-owner delete
denied + schedule survives, unknown-id idempotent, cross-owner list empty,
system context still lists). No authoring-surface or metadata change.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L8aEBrJVxRnA5XVRkeVft91 parent b3efeb7 commit edeea84
4 files changed
Lines changed: 88 additions & 2 deletions
File tree
- .changeset
- packages
- plugins/plugin-reports/src
- rest/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
443 | 443 | | |
444 | 444 | | |
445 | 445 | | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
446 | 474 | | |
447 | 475 | | |
448 | 476 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
315 | 323 | | |
316 | 324 | | |
317 | 325 | | |
| |||
532 | 540 | | |
533 | 541 | | |
534 | 542 | | |
535 | | - | |
| 543 | + | |
536 | 544 | | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
537 | 555 | | |
538 | 556 | | |
539 | 557 | | |
540 | 558 | | |
541 | 559 | | |
542 | | - | |
| 560 | + | |
543 | 561 | | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
544 | 571 | | |
545 | 572 | | |
546 | 573 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8451 | 8451 | | |
8452 | 8452 | | |
8453 | 8453 | | |
| 8454 | + | |
8454 | 8455 | | |
8455 | 8456 | | |
8456 | 8457 | | |
| |||
0 commit comments