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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

File details

Details for the file sri_checker-0.1.1.tar.gz.

File metadata

  • Download URL: sri_checker-0.1.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for sri_checker-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7200b0ab2c018920585a4e4a8de3e8680e9dc619dd26cee5575355557a4f71a4
MD5 43e093e555d129578be565322068e022
BLAKE2b-256 767db46351f0aa82caaa19e79416f1ae9ba54c5839781141dbf5c9c780be8586

See more details on using hashes here.

File details

Details for the file sri_checker-0.1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for sri_checker-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f3fed7dbdd7bcb6570ad9c8f4ad3ac5dddf3385852ca8bd66bfb97e5ace0bc19
MD5 6cca935a5f14c4173752f22069e6f173
BLAKE2b-256 2384ef1ff02ebd016bd0775ef6a7c8fba820d8693ed5a81f9eeedf2285ec313e

See more details on using hashes here.

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