Scan HTTP security headers
Project description
secheaders
Python script to check HTTP security headers
Same functionality as securityheaders.io but as Python script. Also checks some server/version headers. Written and tested using Python 3.8.
With minor modifications could be used as a library for other projects.
NOTE: The project renamed (2024-10-19) from securityheaders to secheaders to avoid confusion with PyPI package with similar name.
Installation
The following assumes you have Python installed and command python refers to python version >= 3.8.
Install
$ pip install secheaders
Building and running locally
- Clone into repository
python -m buildpip install dist/secheaders-0.2.0-py3-none-any.whl- Run
secheaders --help
Running from source without installation
- Clone into repository
- Run
python -m secheaders
Usage
usage: secheaders [-h] [--target-list FILE] [--max-redirects N] [--insecure] [--file FILE] [--json] [--no-color] [--verbose] [URL]
Scan HTTP security headers
positional arguments:
URL Target URL (default: None)
options:
-h, --help show this help message and exit
--target-list FILE Read multiple target URLs from a file and scan them all (default: None)
--max-redirects N Max redirects, set 0 to disable (default: 2)
--insecure Do not verify TLS certificate chain (default: False)
--file FILE, -f FILE Read the headers from file or stdin rather than fetching from URL (default: None)
--json JSON output instead of text (default: False)
--no-color Do not output colors in terminal (default: False)
--verbose, -v Verbose output (default: False)
Example output
$ secheaders example.com
Scanning target https://example.com ...
Header 'x-frame-options' is missing [ WARN ]
Header 'strict-transport-security' is missing [ WARN ]
Header 'content-security-policy' is missing [ WARN ]
Header 'x-content-type-options' is missing [ WARN ]
Header 'x-xss-protection' is missing [ OK ]
Header 'referrer-policy' is missing [ WARN ]
Header 'permissions-policy' is missing [ WARN ]
server: ECAcc (nyd/D191) [ WARN ]
HTTPS supported [ OK ]
HTTPS valid certificate [ OK ]
HTTP -> HTTPS automatic redirect [ WARN ]
Design principles
The following design principles have been considered:
- Simplicity of the codebase.
- The code should be easy to understand and follow without in-depth Python knowledge.
- Avoidance of external dependencies.
- The Python Standard Libary provides enough tools and libraries for quite many use cases.
- Unix philosophy in general
- "Do one thing and do it well"
These are not rules set in stone, but should be revisited when doing big design choices.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file secheaders-0.2.0.tar.gz.
File metadata
- Download URL: secheaders-0.2.0.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d28a0132e546268dae4999378e9d6838bb085224de7234444ac4c09fe4dd8c72
|
|
| MD5 |
59b21d9247ef47e990c6452066984883
|
|
| BLAKE2b-256 |
ef979fdd9f0296c06cb12c7976bbf24084daf13d8d760705cf922a7bb701cb8d
|
Provenance
The following attestation bundles were made for secheaders-0.2.0.tar.gz:
Publisher:
python-publish.yml on juerkkil/secheaders
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
secheaders-0.2.0.tar.gz -
Subject digest:
d28a0132e546268dae4999378e9d6838bb085224de7234444ac4c09fe4dd8c72 - Sigstore transparency entry: 349559178
- Sigstore integration time:
-
Permalink:
juerkkil/secheaders@c036d5506c4f300f58beb660990df391ffea6739 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/juerkkil
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@c036d5506c4f300f58beb660990df391ffea6739 -
Trigger Event:
release
-
Statement type:
File details
Details for the file secheaders-0.2.0-py3-none-any.whl.
File metadata
- Download URL: secheaders-0.2.0-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d46ca3d77e33d8541699a81627e140be9261979920309d21fa4abd41d19df5fe
|
|
| MD5 |
a8f1b478a422d200f61a74edb3c061f5
|
|
| BLAKE2b-256 |
cc646ab5b1041cc7fc3515d1d6ff1554e3317a93bd0c1bcff8874de5b9b2ca6f
|
Provenance
The following attestation bundles were made for secheaders-0.2.0-py3-none-any.whl:
Publisher:
python-publish.yml on juerkkil/secheaders
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
secheaders-0.2.0-py3-none-any.whl -
Subject digest:
d46ca3d77e33d8541699a81627e140be9261979920309d21fa4abd41d19df5fe - Sigstore transparency entry: 349559196
- Sigstore integration time:
-
Permalink:
juerkkil/secheaders@c036d5506c4f300f58beb660990df391ffea6739 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/juerkkil
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@c036d5506c4f300f58beb660990df391ffea6739 -
Trigger Event:
release
-
Statement type: