Skip to content

Docs

How to test your app's business logic for holes

Business logic is the set of rules your app runs on: a customer sees only their own orders, only a manager approves a refund, a discount works once. Automated scanners look for known kinds of bugs; they usually do not know your rules, so they usually cannot tell you when one is broken. You test a rule by having a regular user try to break it.

1. Write the rules down

Ask your coding agent, in your repository:

List every rule this app enforces about who can see, change, approve, pay for or delete what, and every number that must add up. One line each, in plain words, with the file and line that enforces it, or “nothing enforces this”. Do not change any code.

Correct the list yourself. A rule you expected that is missing from it is your first finding.

2. Try to break each rule as a regular user

Do this on a copy of the app with its own test database, never the live app: several of these attempts create orders, change stock or send emails. On the live app, only try the first row (reading A's records as B), with test accounts you made for this. Never use real customers' accounts.

RuleHow a test user tries to break it
Users see only their own recordsAs user B, open, list, export and search for user A's records.
Users change only their own recordsAs B, edit or delete A's record by putting its id in the address or the request.
Only an admin is an adminAs a regular user, add role or isAdmin to a profile update, or open admin pages by address.
Steps happen in orderApprove your own request, skip the payment step, or reuse a one-time discount or invite link.
Numbers stay trueSend a negative quantity, a changed price or a total the app should compute itself.
Limits holdGo past a plan's limit, or act on a record after your access was removed.

Many of these need the request, not the screen: the screen hides a button, the server still accepts the call. In the browser's developer tools, the Network tab shows each request; your coding agent can replay one with a changed id or field on the copy.

3. Write down what broke, with proof

4. Fix, then break it again

Related: can one user see another user's data? and checking after every deploy.

What Pariter does

Pariter checks every change to your code against your app's business rules and tells you and your coding agent when one breaks. The rulebook and the self-check are free now, with no account: pariter.ai/docs/rulebook.md. The independent check on every push runs through Pariter's connector (add it): one proof alert is free, and the check on every push is not on sale yet. Leave your email and your app's address to hear when it is.