Reusable Behave hooks for Selenium + OWASP ZAP integration.
Project description
behave-zap
behave-zap is a working Python library that integrates Behave and OWASP ZAP into a single, reusable web testing + DAST execution model.
It is designed for teams that want:
- Functional browser automation and security scanning in the same run
- Per-feature control of active scan targets
- A final consolidated ZAP report with all discovered alerts
- A CI-friendly flow with reference pipeline examples
Why this library
Security scanning is often bolted on after functional testing. behave-zap makes DAST a first-class part of your Behave lifecycle:
- Hook-based orchestration for
before_all,after_feature, andafter_all - Chrome-focused web automation primitives for page objects and driver setup
- Feature-level attack-surface segmentation through target mapping
- Final report generation after full test execution
Core architecture
behave_zap/hooks.py- Behave lifecycle integration
- ZAP initialization, passive/active scan orchestration, final reports
behave_zap/web.py- Chrome WebDriver creation
- Context + page-object base classes (
PageObject,Button,InputText, etc.)
test/environment.py- Thin project adapter that delegates to the library runner
Installation
Install as editable package in this repository:
pip install -e .
Install from a consumer project:
pip install behave-zap
Quick start
- Configure DAST in
test/conf/properties.cfg. - Define feature-specific active scan targets using
targets_<feature_file_name>. - Run ZAP in daemon mode.
- Execute Behave scenarios (optionally with
@dasttag). - Collect final reports from
test/output/zapreport-final.htmlandtest/output/zapreport-final.xml.
Feature-level target strategy
Active scan targets are configured per feature file:
targets_login=...targets_product=...targets_customer_feedback=...
If a feature has no targets_<feature_name> entry, active scan is skipped for that feature. This improves control of attack surface and reduces noisy scans.
CI and pipeline example
Reference workflow examples are provided as documentation (not active GitHub Actions):
docs/examples/github-workflows/ci_dast.yml
The pipeline example uses the testingsoul action created for this project to annotate PRs from ZAP results:
- https://github.com/testingsoul/zap-annotations
- https://github.com/marketplace/actions/zap-annotations
Documentation
- Test execution guide: docs/test.md
- Full library experience: docs/library-experience.md
Release and Publish
Best practice for public libraries is:
- Validate locally (
build+twine check). - Publish to TestPyPI.
- Create a GitHub Release tag.
- Publish to PyPI automatically from GitHub Actions (Trusted Publisher/OIDC recommended).
Release checklist
- Update version in
behave_zap/version.py. - Add release notes in
CHANGELOG.md. - Build and validate package:
python -m build python -m twine check dist/*
- Publish to TestPyPI and test install.
- Create git tag and GitHub Release (for example
v0.1.1). - Publish to PyPI.
Manual deploy script
Use:
./scripts/deploy.sh --testpypi
./scripts/deploy.sh --pypi
Script path:
scripts/deploy.sh
Automatic publish workflow (recommended)
Reference-only workflow example:
docs/examples/github-workflows/publish-pypi-release.yml
This workflow publishes when a GitHub Release is created.
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 behave_zap-0.1.0.tar.gz.
File metadata
- Download URL: behave_zap-0.1.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b99941fc23cbed19ab1d6f52cc17d6a3b18146c20316a24a65f32e55b9955e6
|
|
| MD5 |
acc0f61fc925df786630d51e151cf2c6
|
|
| BLAKE2b-256 |
631ad3290d0b4f395277291e1d52ac6f27dcf14c61cbc89e519ee2e9d5df02ab
|
Provenance
The following attestation bundles were made for behave_zap-0.1.0.tar.gz:
Publisher:
publish-pypi-release.yml on testingsoul/behave-zap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
behave_zap-0.1.0.tar.gz -
Subject digest:
1b99941fc23cbed19ab1d6f52cc17d6a3b18146c20316a24a65f32e55b9955e6 - Sigstore transparency entry: 1492569846
- Sigstore integration time:
-
Permalink:
testingsoul/behave-zap@65269eb495ba73131871969dc09c2222cd07afe7 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/testingsoul
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi-release.yml@65269eb495ba73131871969dc09c2222cd07afe7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file behave_zap-0.1.0-py3-none-any.whl.
File metadata
- Download URL: behave_zap-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6299e70438219bcb05a49ecb0ba42e799aa1428fbe99b4f1024cf5f0b37a93a
|
|
| MD5 |
3c0e41465eb480c9cc425e8fe33866bf
|
|
| BLAKE2b-256 |
8c8e028d76b34959cb8bd0fd1b2986bb4cbc9a90a597bba938fc527b2b85fe70
|
Provenance
The following attestation bundles were made for behave_zap-0.1.0-py3-none-any.whl:
Publisher:
publish-pypi-release.yml on testingsoul/behave-zap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
behave_zap-0.1.0-py3-none-any.whl -
Subject digest:
a6299e70438219bcb05a49ecb0ba42e799aa1428fbe99b4f1024cf5f0b37a93a - Sigstore transparency entry: 1492569970
- Sigstore integration time:
-
Permalink:
testingsoul/behave-zap@65269eb495ba73131871969dc09c2222cd07afe7 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/testingsoul
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi-release.yml@65269eb495ba73131871969dc09c2222cd07afe7 -
Trigger Event:
release
-
Statement type: