require-sri
What it does
Section titled “What it does”Reports a <script src> and a <link rel="stylesheet" href> with no integrity attribute.
Why it matters
Section titled “Why it matters”A file loaded from a CDN or another server can change after the page was written, and the page then runs or applies the changed file without noticing.
To fix, add integrity with the hash of the file and crossorigin="anonymous".
Example
Section titled “Example”<!DOCTYPE html><title>x</title><script src="https://cdn.example/a.js"></script><script src="https://cdn.example/b.js" integrity="sha384-x" crossorigin="anonymous"></script><script src="a.js"></script><link rel="stylesheet" href="https://cdn.example/a.css"><link rel="stylesheet" href="a.css"><link rel="icon" href="https://cdn.example/a.png">Configuration
Section titled “Configuration”angular: lint: rules: require-sri: warn # off (default), warn, errorhtml: lint: rules: require-sri: warn # off (default), warn, errorsvelte: lint: rules: require-sri: warn # off (default), warn, errorvue: lint: rules: require-sri: warn # off (default), warn, errorSuppress one line with sudsy-disable-next-line require-sri in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| html-validate | require-sri |
partial | no target, include and exclude options |