Commit Graph
47 Commits
Author SHA1 Message Date
Herculino Trotta 039ad225d3 test(rules): cover object-level authorization for transaction rules
Regression tests for GHSA-83g9-vjqf-2j5q, one per endpoint the advisory
named plus the delete and view paths found alongside them: a non-owner
gets 403 on every mutation of a public or shared rule, and the object is
asserted unchanged afterwards.

Also covers the parts that are easy to regress in the other direction:
shared users keep read access, a shared user deleting only revokes their
own access, unowned rules stay claimable, and children of invisible rules
answer 404 rather than 403.

SharedObjectPredicateParityTests asserts is_visible_to agrees with
SharedObjectManager across every owner/visibility/shared combination.
The manager builds a Q and the predicate tests an instance, so they
cannot share an implementation and can otherwise drift apart.
2026-09-01 21:43:13 -03:00
Herculino Trotta 18d4ab7d11 fix(rules): enforce object-level authorization on rule endpoints
SharedObjectManager scopes querysets to what a user may see, which
includes other people's public and shared-with-them objects. Several
mutating rule endpoints treated that visibility as permission to write.

Generalise get_owned_object_or_403 into get_shared_object_or_error, which
takes an explicit access level instead of inferring one:

- READ requires the object to be visible; denial is 404 so the response
  does not confirm that an id exists.
- EDIT requires ownership; denial is 403, but only after the visibility
  check, so 403 never leaks the existence of an invisible object. This
  matters for TransactionRuleAction, whose manager is unscoped.

The previous owner_path resolved to a User and discarded the object, so
it could not express visibility at all. via= now points at the governing
SharedObject and is resolved with a plain getattr, so an unresolvable
path raises instead of silently granting access.

is_visible_to/is_editable_by replace is_accessible_by, which was never
called and tested visibility == "shared", a value that does not exist in
Visibility.

Also fixes two further holes in the same module:

- transaction_rule_delete fell through to delete() whenever the caller
  was not in shared_with, so any user could delete a public rule. Now
  only the owner deletes; a shared user revokes their own access.
- transaction_rule_view was read-only but is now explicitly READ, so
  rules shared with a user stay viewable.

The activate/deactivate control is hidden for rules the user does not
own, instead of rendering a button that always fails.

Refs GHSA-83g9-vjqf-2j5q
2026-09-01 21:25:46 -03:00
Moshe Levi 68a9286ce5 Fix BOLA on transaction-rule endpoints via get_owned_object_or_403
Add apps.common.functions.get_owned_object_or_403, an ownership-enforcing
variant of get_object_or_404, and apply it across every rules handler that
resolved a TransactionRule / (UpdateOrCreate)TransactionRuleAction from a URL id
without an owner check. Mirrors the check in transaction_rule_edit
(obj.owner and obj.owner != request.user); objects with no owner remain
accessible, preserving existing behaviour. Nested ownership (actions owned via
their parent rule) is handled with owner_path='rule.owner'.
2026-08-31 20:14:40 +03:00
Herculino Trotta d72ff3cdf5 fix(rules): allow category expressions to clear categories 2026-05-02 16:16:27 -03:00
Herculino Trotta 67f79effab feat: improve text for rules 2025-12-14 11:43:52 -03:00
Herculino Trotta c168886968 feat: improve text for rules 2025-12-14 11:42:51 -03:00
Herculino Trotta 0b0d760bab feat: guess what, more changes 2025-11-11 20:21:01 -03:00
Herculino Trotta cd54df6f2d feat: more changes and fixes 2025-11-08 14:06:01 -03:00
Herculino Trotta a63367a772 feat: first batch of work 2025-11-01 03:15:44 -03:00
Herculino Trotta 1fa7985b01 fix(rules:dry-run): current_user getting overwritten and delete on synchronous call 2025-09-14 01:37:03 -03:00
Herculino Trotta 9eb1818a20 feat(rules): expose if the transaction is recurring/installment 2025-09-14 01:18:08 -03:00
Herculino Trotta 2a463c63b8 fix(rules:dry-run): Edit/Update transaction not showing message when transaction can't be found 2025-09-14 00:41:04 -03:00
Herculino Trotta efe020efb3 fix(rules): duplicating transactions when ran outside of test mode 2025-09-07 22:14:40 -03:00
Herculino Trotta 8c133f92ce fix(rules): add .exclude() to transactions() function 2025-09-07 21:30:03 -03:00
Herculino Trotta f3c9d8faea feat(rules): add .exclude() to transactions() function 2025-09-07 21:24:53 -03:00
Herculino Trotta 8f5204a17b feat(rules): add .exclude() to transactions() function 2025-09-07 20:41:09 -03:00
Herculino Trotta 2235bdeabb changes 2025-09-02 23:17:04 -03:00
Herculino Trotta d724300513 changes 2025-09-02 15:54:45 -03:00
Herculino Trotta eacafa1def changes 2025-09-02 09:47:35 -03:00
Herculino Trotta c738f5ee29 changes 2025-09-02 09:47:27 -03:00
Herculino Trotta 72904266bf feat(rules): add optional rules ordering 2025-08-31 09:06:48 -03:00
Herculino Trotta 670bee4325 feat(rules): add rule function to fetch transactions totals and balance 2025-08-30 15:36:07 -03:00
Herculino Trotta 5b6c123fa1 refactor: properly name shareable objects generic fields 2025-07-27 23:19:39 -03:00
Herculino Trotta 47d34f3c27 feat(app): add a demo mode 2025-03-31 02:14:00 -03:00
Herculino Trotta f6f06f4d65 feat(rules): trigger transaction rules on delete 2025-03-09 01:54:03 -03:00
Herculino Trotta 17697dc565 fix(rules): unable to save 2025-03-09 01:26:42 -03:00
Herculino Trotta 020dd74f80 feat: multi tenancy support 2025-03-08 12:03:17 -03:00
Herculino Trotta 0f60f8d486 fix(rules): Update or Create Transaction rule unable to match againt dates and other types 2025-02-25 10:48:43 -03:00
Herculino Trotta 865618e054 feat(dca): link transactions to DCA 2025-02-15 00:41:06 -03:00
Herculino Trotta f3bcef534e feat(internal): trigger rules on bulk actions 2025-02-14 00:34:51 -03:00
Herculino Trotta 7c9697f683 locale: update locales 2025-02-09 17:30:39 -03:00
Herculino Trotta 942154480e feat(rules): add Update or Create Transaction action 2025-02-08 04:17:28 -03:00
Herculino Trotta 467131d9f1 feat(rules): add Update or Create Transaction action 2025-02-08 04:16:28 -03:00
Herculino Trotta 852ffd5634 feat: cleanup and format logs 2025-02-07 11:31:14 -03:00
Herculino Trotta d030f9686b refactor: add end slashes for some urls without 2025-01-24 22:55:36 -03:00
Herculino Trotta 97465c07fe fix: import preset not working behind nginx due to long url/csrf missing 2025-01-24 16:06:47 -03:00
Herculino Trotta 4b8051cca2 refactor(rules): rename TransactionRuleAction related_name from "action" to "transaction_actions" 2024-12-27 02:10:09 -03:00
Herculino Trotta b148a89dc6 feat(tasks): add error logging 2024-12-15 10:06:31 -03:00
Herculino Trotta 2382abf3c0 feat: add Transaction Entity 2024-11-30 17:12:35 -03:00
Herculino Trotta da10f461a6 refactor: drop toast(s) custom event as toasts listen to updated now 2024-11-30 00:35:20 -03:00
Herculino Trotta 26646ad851 refactor: remove debug print 2024-11-03 22:12:25 -03:00
Herculino Trotta 698fb88568 feat: add is_asset_account and is_archived_account to rule eval 2024-10-27 21:55:15 -03:00
Herculino Trotta 9f371c2693 fix: rename rule eval relative_delta to relativedelta to match real function 2024-10-27 15:42:26 -03:00
Herculino Trotta 79e97e7a76 fix: unable to update TransactionRuleAction 2024-10-27 15:38:47 -03:00
Herculino Trotta d47db1248e feat: add notes to Tranfer, Recurring and Installment 2024-10-24 16:13:37 -03:00
Herculino Trotta 344b404184 feat: make TransactionRuleAction field and value unique together 2024-10-23 22:49:10 -03:00
Herculino Trotta b9a9e279dc feat: add rules for transactions 2024-10-23 00:39:14 -03:00