-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from juerkkil/major_refactor
restructure project for packaging
- Loading branch information
Showing
11 changed files
with
131 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
venv/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,63 @@ | ||
# securityheaders | ||
# 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.4. | ||
|
||
With minor modifications could be used as a library for other projects. | ||
|
||
## Installation | ||
|
||
The following assumes you have Python installed and command `python` refers to python version >= 3.4. | ||
|
||
### Run without installation | ||
|
||
1. Clone into repository | ||
2. Run `python -m secheaders` | ||
|
||
### Installation | ||
|
||
1. Clone into repository | ||
2. `python -m build` | ||
3. `pip install dist/secheaders-0.1.0-py3-none-any.whl` | ||
4. Run `secheaders --help` | ||
|
||
|
||
|
||
### Usage | ||
``` | ||
$ python securityheaders.py --help | ||
usage: securityheaders.py [-h] [--max-redirects N] URL | ||
$ secheaders --help | ||
usage: secheaders [-h] [--max-redirects N] [--no-check-certificate] URL | ||
Check HTTP security headers | ||
positional arguments: | ||
URL Target URL | ||
URL Target URL | ||
optional arguments: | ||
-h, --help show this help message and exit | ||
--max-redirects N Max redirects, set 0 to disable (default: 2) | ||
$ | ||
options: | ||
-h, --help show this help message and exit | ||
--max-redirects N Max redirects, set 0 to disable (default: 2) | ||
--no-check-certificate | ||
Do not verify TLS certificate chain (default: False) | ||
``` | ||
|
||
### Output | ||
|
||
### Example output | ||
``` | ||
$ python securityheaders.py --max-redirects 5 https://secfault.fi | ||
Header 'x-xss-protection' is missing ... [ WARN ] | ||
Header 'x-content-type-options' is missing ... [ WARN ] | ||
$ secheaders 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-powered-by' is missing ... [ OK ] | ||
Header 'x-frame-options' contains value 'DENY' ... [ OK ] | ||
Header 'strict-transport-security' contains value 'max-age=63072000' ... [ OK ] | ||
Header 'access-control-allow-origin' is missing ... [ OK ] | ||
Header 'server' contains value 'nginx/1.10.1' ... [ 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 ] | ||
Header 'server' contains value 'ECAcc (nyd/D187) ... [ WARN ] | ||
HTTPS supported ... [ OK ] | ||
HTTPS valid certificate ... [ OK ] | ||
HTTP -> HTTPS redirect ... [ OK ] | ||
$ | ||
HTTP -> HTTPS redirect ... [ WARN ] | ||
``` | ||
|
||
## Note | ||
|
||
The project renamed (2024-10-19) from **securityheaders** to **secheaders** to avoid confusion with PyPI package with similar name. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[build-system] | ||
requires = ["setuptools"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "secheaders" | ||
version = "0.1.0" | ||
requires-python = ">=3.4" | ||
authors = [ | ||
{name = "Jussi-Pekka Erkkilä", email = "[email protected]"}, | ||
] | ||
maintainers = [ | ||
{name = "Jussi-Pekka Erkkilä", email = "[email protected]"} | ||
] | ||
description = "Scan HTTP security headers" | ||
readme = "README.md" | ||
license = {file = "LICENSE"} | ||
keywords = ["web", "security"] | ||
classifiers = [ | ||
"Development Status :: 4 - Beta", | ||
"Environment :: Console", | ||
"Intended Audience :: Developers", | ||
"Intended Audience :: System Administrators", | ||
"License :: OSI Approved :: MIT License", | ||
"Programming Language :: Python", | ||
"Topic :: Security", | ||
] | ||
|
||
[project.scripts] | ||
secheaders = "secheaders.securityheaders:main" | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
if __name__ == "__main__": | ||
from .securityheaders import main | ||
main() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class SecurityHeadersException(Exception): | ||
pass | ||
|
||
|
||
class InvalidTargetURL(SecurityHeadersException): | ||
pass | ||
|
||
|
||
class UnableToConnect(SecurityHeadersException): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import setuptools | ||
|
||
setuptools.setup() |