Skip to main content

a linter and pre-commit hook to check SRI-hashes in HTML files

Project description

ci pre-commit.ci status

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.1
  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.

base.html:1 SRI-hash incorrect
expected: sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN
got: sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL

Contents can also be passed via stdin:

cat base.html | sri-checker -

Project details


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.1.tar.gz (4.1 kB view hashes)

Uploaded Source

Built Distribution

sri_checker-0.1.1-py2.py3-none-any.whl (4.4 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page