Skip to content

Script integrity and schedules

A CSP controls where scripts come from. It does not tell you when an approved script changes. The Script integrity tab of Security > CSP records the scripts that the site runs and reports each change.

  1. Open Security > CSP > Script integrity.
  2. Select Run the first check. You can leave the page while the check runs.

The check loads the Base URL of the site and records:

  • Script inventory: every script the page loads, with its hash and its execution order.
  • Network tracking: the requests that scripts send to other domains.

The first completed check is the baseline. Later checks are compared with it.

Each later check reports the scripts that were Added, Removed or Changed against the baseline, with a Severity: high, medium, low or none.

A change is not always a problem. A release of your site changes its scripts. Examine each change:

  • If you expect the change, select Set as baseline on the check. Later checks are then compared with this check.
  • If you do not expect the change, find where the script comes from before you do anything else. A changed third-party script is a supply chain risk.

Some scripts change often, for example a tag manager. Add the host to Dynamic domains, with an optional path pattern and a reason. A change to a script from a dynamic domain does not raise the severity of a check.

Suspicious activity detected lists the scripts that send data to other domains, with the target domain and the script that started the request. Approve an activity that you expect. It then shows in Approved activity and is not reported as suspicious again. Remove the approval to get the report back.

  • Subresource integrity gives an integrity value for each external script. Use the value in the integrity attribute of a <script> tag for a script whose content does not change.
  • Security sinks lists calls that run text as code, such as eval() and new Function().

The Schedules tab runs scans on their own. Results show in the History tab.

  1. Select Create schedule.
  2. Enter a Name (optional).
  3. Select the Scan type:
    • CSP validation checks the pages against the deployed policy.
    • Script integrity compares the scripts with the baseline.
  4. Select the Frequency: Daily, Weekly, Monthly or Custom (cron). Daily, weekly and monthly runs start at 02:00 in the timezone of the schedule. A cron expression has five fields, and the runs must be at least one hour apart.
  5. Select the Timezone.
  6. Save the schedule.

Use the actions of a schedule to run it now, edit it or delete it. Turn off Enabled to keep a schedule without runs.

Quant disables a schedule after 5 failures one after the other, and shows Stopped after 5 failures. Find the cause in History, correct it, then enable the schedule again.

A good start is one daily Script integrity schedule and one weekly CSP validation schedule. Set up an alert channel so that someone sees the results.