# Rules (/en/docs/platform/features/pci-dss/scripts/rules)



A rule decides every script whose URL matches its pattern, so you do not review them one by one. Write rules for the providers you already trust, the scripts you never want on a payment page, and the software your visitors bring with them. What is left is your review list.

Requires the website **Manager** role to add, edit or delete a rule. Every role can read the list.

## The three actions [#the-three-actions]

| Action                                | What happens to matching scripts                                                                            | Use it for                                                                                                       |
| ------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| **Approve matching scripts**          | Approved with the rule's justification. They stay approved even when their content changes.                 | Your own scripts and providers you have already vetted, such as your payment provider                            |
| **Reject matching scripts**           | Rejected with the rule's reason. They stay listed until they stop loading.                                  | Scripts that must never run on a payment page, such as an ad network                                             |
| **Put matching scripts out of scope** | Out of scope with the rule's reason. They leave the review list, the review progress and the script alerts. | Software a visitor's browser adds to the page, which your site never asked for, such as a page translation proxy |

Rejecting a script does not stop it from loading. Remove it from the page or block it in your Content Security Policy, then check that it no longer appears.

<Callout type="warn" title="Keep approve and out of scope patterns narrow">
  A wide pattern decides scripts nobody reviewed, including one an attacker adds to your payment page. An out of scope script raises no alert and never waits for review, so a pattern that covers too much hides it.

  Before you write the pattern, ask: would the page load this script for a visitor on a clean browser? If yes, it is your script and it belongs in the review, not out of scope.
</Callout>

## Add a rule [#add-a-rule]

1. Open **PCI DSS** > **Scripts** and the **Rules** tab.
2. Select **Add rule**.
3. Fill in the fields and select **Add rule**.

| Field                           | What to enter                                                                                                                               |
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| **What the rule does**          | **Approve matching scripts**, **Reject matching scripts** or **Put matching scripts out of scope**                                          |
| **Script URL pattern**          | The URLs the rule covers, with `*` as the wildcard, for example `https://js.stripe.com/*`                                                   |
| **Justification** or **Reason** | Required. **Justification** for an approve rule, **Reason** for the other two. It is recorded on every matching script, for your assessor.  |
| **Name**                        | A label for the list, such as `Approved payment provider`                                                                                   |
| **Tags**                        | Optional. Applied to every script the rule matches. For more information, refer to [Tags](/en/docs/platform/features/pci-dss/scripts/tags). |

{/* SCREENSHOT: img/pci-dss/rule-form.webp | Add rule dialog, "Approve matching scripts" selected, name, pattern, justification and tags filled */}

Write the text for someone who does not know your site. A useful justification says what the script does and who approved it: `Stripe.js tokenizes card fields for checkout. Vendor reviewed by the payments team.` A useful reason says why the script does not belong: `Injected by a page translation proxy on the visitor's device, not loaded by our pages.` A word like `ok` or `noise` tells an assessor nothing.

Each pattern holds one rule. If another rule of the website already has the pattern, edit that rule instead.

## Patterns [#patterns]

A pattern matches the whole script URL, from the scheme to the end. `*` stands for any characters, slashes included.

| Pattern                                 | Matches                                              |
| --------------------------------------- | ---------------------------------------------------- |
| `https://js.stripe.com/*`               | Every script served from `js.stripe.com`             |
| `https://*.stripe.com/*`                | Every script served from a subdomain of `stripe.com` |
| `https://www.example.com/assets/app.js` | That one script only                                 |
| `stripe.com`                            | Nothing, because it is not a whole URL               |

When a script matches more than one rule, only the first one decides it, whatever its action. Avoid patterns that overlap.

An older rule may use a regular expression, and its pattern field is then labelled **Regex**. To move it to a wildcard pattern, add a new rule that uses `*` and delete the old one.

## What a rule decides, and what it does not [#what-a-rule-decides-and-what-it-does-not]

* **A rule never changes a decision a person made.** A script someone approved, rejected or put out of scope keeps that decision, whatever rule matches it later. A person can still change a decision a rule made.
* **A rule also decides scripts already listed.** Saving a rule refreshes the inventory, and the rule decides the matching scripts nobody has decided yet, not only new ones. Write your rules first, then review what is left.
* **A change is decided the same way.** A script a rule decided keeps that decision when its content changes. A script a person approved goes back to **Needs review** when its content changes, even if a rule covers its URL: a rule never approves content nobody has read.
* **Editing a rule applies to what it decides next.** Scripts it already decided keep their decision until their content changes or someone reviews them.

A script decided by a rule says so in its history, as **Approved by a rule**, **Rejected by a rule** or **Put out of scope by a rule**, with the rule's name. For more information, refer to [Review scripts](/en/docs/platform/features/pci-dss/scripts/review-scripts).

## Turn off or delete a rule [#turn-off-or-delete-a-rule]

Turn a rule off with its **Enabled** switch, or delete it from its row menu. Either way:

* Decisions the rule already made stay as they are, in the inventory and in each script's history.
* New scripts matching it wait for a decision.

To undo what a rule decided, open each script it decided and make the decision yourself.

## In the evidence [#in-the-evidence]

Each month's evidence lists the rules enabled at the end of the month, with what each one matches, its action, its text and the scripts it decided. A disabled rule decides nothing, so it is not listed. For more information, refer to [Evidence](/en/docs/platform/features/pci-dss/evidence).

## Next steps [#next-steps]

* [Review scripts](/en/docs/platform/features/pci-dss/scripts/review-scripts)
* [Tags](/en/docs/platform/features/pci-dss/scripts/tags)
* [Evidence](/en/docs/platform/features/pci-dss/evidence)
