Web Application Firewall logs downloader.
Project description
Cloudflare Web Application Firewall downloader
A library, CLI, and docker image that downloads Cloudflare WAF logs for a specified zone_id and time frame.
Schema
See src/waf_logs/resources/db/ for a list of schemas that are auto-applied at start. This can be disabled by passing --ensure_schema False
.
Quickstart
The project is published to https://pypi.org/project/waf-downloader/. Install it via:
pip install waf-downloader
# or alternatively, directly from git
pip install "git+https://github.com/MihaiBojin/waf-downloader@main"
Build and run with Docker
Define secrets in an .env
file (do not quote values):
CLOUDFLARE_TOKEN=...
DB_CONN_STR=...
The Cloudflare token is required, but the connection string is optional. If skipped, it will result in logs being printed to stdout.
Build and run:
# Build
make docker
# Load all logs in zone, starting 5 minutes prior
make docker-run ARGS="--zone_id [CLOUDFLARE_ZONE_ID] --start_minutes_ago -5"
# And alternatively, only output the logs
make docker-run ARGS="--zone_id [CLOUDFLARE_ZONE_ID] --start_minutes_ago -5" 2>/dev/null
Publishing to PyPI
GitHub-based version publishing
The simplest way to publish a new version (if you have committer rights) is to tag a commit and push it to the repo:
# At a certain commit, ideally after merging a PR to main
git tag v0.1.x
git push origin v0.1.x
A GitHub Action will run, build the library and publish it to the PyPI repositories.
Manual publish
These steps can also be performed locally. For these commands to work, you will need to export two environment variables (or define them in .env
):
export TESTPYPI_PASSWORD=... # token for https://test.pypi.org/legacy/
export PYPI_PASSWORD=... # token for https://upload.pypi.org/legacy/
First, publish to the test repo and inspect the package:
make publish-test
If correct, distribute the wheel to the PyPI index:
make publish
Verify the distributed code
make publish-verify
Cloudflare WAF documentation
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
Built Distribution
Hashes for waf_downloader-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 005e2bcdff1559c2c3f271433c100b23a68748e19fc6e910aed6758b1b3cd5d6 |
|
MD5 | 747d9fff0082eca10645a0587b9cb160 |
|
BLAKE2b-256 | 06a8ea812509b2ed1fcfd00b199d18b905ad08b45ab3988eb46c7672fae9a725 |