Skip to content

Scope ONPRC billing run deletion to the current container#1767

Open
labkey-martyp wants to merge 2 commits into
release26.3-SNAPSHOTfrom
26.3_fb_onprc_billing_delete_container_scope
Open

Scope ONPRC billing run deletion to the current container#1767
labkey-martyp wants to merge 2 commits into
release26.3-SNAPSHOTfrom
26.3_fb_onprc_billing_delete_container_scope

Conversation

@labkey-martyp

Copy link
Copy Markdown
Contributor

Rationale

ONPRC_BillingManager.deleteBillingRuns built SimpleFilters over the raw onprc_billing tables (invoicedItems, invoiceRuns, miscCharges) from request-supplied primary keys with no container predicate, and the method received no Container. Since DeleteBillingPeriodAction's permission check is evaluated only against the current folder, a billing admin in one folder could delete or detach billing rows belonging to any other folder by POSTing arbitrary object IDs - a cross-container horizontal privilege-escalation bug. This change confines every operation to the caller's folder. This is the 26.3 port of #1759 (originally against release25.7-SNAPSHOT).

Related Pull Requests

Changes

  • Add a Container parameter to deleteBillingRuns and pass getContainer() from both DeleteBillingPeriodAction call sites.
  • Add integration test ONPRC_BillingManager.TestCase asserting a delete from one container cannot affect another, registered in ONPRC_BillingModule.getIntegrationTests().
  • Drop two unused row-count locals from the Table.delete calls.

Container filters added on

All tables are in the onprc_billing schema:

  • invoiceRuns - container filter on the PK->run-id lookup and on the final delete.
  • invoicedItems - the preview read and the delete both carry a direct container filter (SimpleFilter.createContainerFilter) plus an invoiceId restriction to the container-scoped run ids.
  • miscCharges - the read and the detaching Table.update are keyed off container-authorized run ids only; intentionally NOT container-scoped (source charges may live in satellite containers) but can only match runs the caller already owns.

deleteBillingRuns built SimpleFilters over the raw onprc_billing tables (invoicedItems, invoiceRuns, miscCharges) from request-supplied primary keys with no container predicate, and received no Container, so a billing admin in one folder could delete or detach billing rows in any other folder by POSTing arbitrary object IDs. Add a Container parameter and confine every read, delete, and update to the caller's folder: invoiceRuns and invoicedItems get a direct container filter, and miscCharges is keyed off the container-authorized run ids. Add ONPRC_BillingManager.TestCase covering cross-container isolation and register it in getIntegrationTests(). 26.3 port of #1759.
The Module interface changed getIntegrationTests() to return Set<Class<?>> instead of the raw Set<Class>, breaking the override in ONPRC_BillingModule. Update the override signature to match.
@brentlogan

Copy link
Copy Markdown
Collaborator

@labkey-martyp, Gary installed and checked the PR and it appears to run as expected. He's going to ask Sally, our finance person, to test it. Once we get approval, we'd still like to delay the squash and merge until after our month-end billing. Monday, July 6, would be a good day. Please let us know if this causes any issues. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants