CentralCSP
APIInventory Rules

Create an inventory rule

Adds a rule so scripts from a known vendor are decided without being reviewed one by one. The rule applies straight away to every script nobody has decided yet, and never changes a decision a person made. An exclude rule removes matching scripts from PCI scope, the compliance figures and script alerts, so keep its pattern narrow. A website can have up to 200 rules.

Requires the manager role on the website and the compliance plan feature.

POST
/v1/workspaces/{workspaceId}/websites/{websiteId}/compliance/rules

Authorization

headerAuthorizationBearer <JWT>

An OpenID Connect access token from signing in to CentralCSP, acting as the signed-in user.

Path Parameters

workspaceId*string

The workspace's id.

websiteId*string

The website's id.

Request Body

application/json
  1. body
name*string

Display name for the rule.

Length1 <= length <= 255
urlPattern*string

Pattern to match script URLs against.

Length1 <= length <= 1024
patternType?PatternType

How urlPattern is read. glob uses * wildcards and is the default. regex is a regular expression; one with too many unbounded repetitions is rejected.

Value in"glob""regex"
action?RuleAction

What happens to a script the rule matches. justify (the default) records it as reviewed and allowed. reject records it as unauthorized, a finding that stays in the inventory until the script stops loading. exclude takes it out of PCI scope, the compliance figures and script alerts; use it only for scripts a visitor's own software injects, such as a browser extension. No rule overrides a decision a person made.

Value in"justify""reject""exclude"
justification*string

Applied to every script the pattern matches: the justification on a justify rule, the reason on a reject or exclude one.

Length1 <= length <= 4096
tagIds?array<string>

Tags to apply to every script this rule matches.

Itemsitems <= 50
enabled?boolean

Defaults to true.

sortOrder?|

Rules are tried from the lowest value up, and the first match wins. Put the most specific rules first.

Range0 <= value

Response Body

A rule that decides matching scripts automatically: justifying them, rejecting them, or excluding them from PCI scope.

application/json
  1. response
id*string
workspaceId*string
websiteId*string
name*string

Display name.

urlPattern*string

Pattern matched against the script URL.

patternType*PatternType

How urlPattern is read. glob uses * wildcards and is the default. regex is a regular expression; one with too many unbounded repetitions is rejected.

Value in"glob""regex"
action*RuleAction

What happens to a script the rule matches. justify (the default) records it as reviewed and allowed. reject records it as unauthorized, a finding that stays in the inventory until the script stops loading. exclude takes it out of PCI scope, the compliance figures and script alerts; use it only for scripts a visitor's own software injects, such as a browser extension. No rule overrides a decision a person made.

Value in"justify""reject""exclude"
justification*string

Applied to every script this rule matches: the justification on a justify rule, the reason on a reject or exclude one.

tagIds*array<string>

Tags applied to matching scripts.

enabled*boolean

A disabled rule matches nothing.

sortOrder*|

Rules are tried from the lowest value up, and the first match wins. Put the most specific rules first.

Range0 <= value
createdAt*string
Formatdate-time
updatedAt*string
Formatdate-time
Example Request
curl -X POST 'https://api.centralcsp.com/v1/workspaces/01936b7a-6f2e-7c31-9a4d-2f8e1c5b7d90/websites/01936b7a-6f2e-7c31-9a4d-2f8e1c5b7d90/compliance/rules' \  -H 'Content-Type: application/json' \  -d '{  "name": "Stripe",  "urlPattern": "https://*.stripe.com/*",  "justification": "Stripe payment scripts, approved vendor."}'
Example Response
{  "id": "string",  "workspaceId": "string",  "websiteId": "string",  "name": "Stripe",  "urlPattern": "https://*.stripe.com/*",  "patternType": "glob",  "action": "justify",  "justification": "string",  "tagIds": [    "string"  ],  "enabled": true,  "sortOrder": 0,  "createdAt": "2019-08-24T14:15:22Z",  "updatedAt": "2019-08-24T14:15:22Z"}