a linter and pre-commit hook to check SRI-hashes in HTML files
Project description
sri-checker
A code formatter to add double indentation to function and method definitions.
Installation
pip install sri-checker
usage
usage: sri-checker [-h] [filenames ...]
positional arguments:
filenames
options:
-h, --help show this help message and exit
pre-commit hook
See pre-commit for instructions
Sample .pre-commit-config.yaml
:
- repo: https://github.com/jkittner/sri-checker
rev: 0.1.0
hooks:
- id: sri-checker
If you are using public CDNs in any of your html-files and pre-commit.ci, you have to add this section to your .pre-commit-config.yaml
since there is no access to the internet during setup or runtime in pre-commit.ci
ci:
skip: [sri-checker]
Example
With an html-file base.html
:
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL"
crossorigin="anonymous"
/>
sri-checker base.html
This will return an error end exit with 1
.
t.html:1 SRI-hash incorrect
expected: sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN
got: sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL
Contents can also be passed via stdin:
cat t.html | sri-checker -
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sri_checker-0.1.0.tar.gz
(3.9 kB
view hashes)
Built Distribution
Close
Hashes for sri_checker-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f960bb3410c6f48f0dbf00f5ed49fe410e711d38e343c3344f6c669d9ec17471 |
|
MD5 | d1e653e7141ef2db03678769fcbd4fd7 |
|
BLAKE2b-256 | 085a278ee22e60637083e6b1aba959e0fd0f3d8d9615892e3ed645267634a6d0 |