Skip to main content

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

integration

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, and after_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

  1. Configure DAST in test/conf/properties.cfg.
  2. Define feature-specific active scan targets using targets_<feature_file_name>.
  3. Run ZAP in daemon mode.
  4. Execute Behave scenarios (optionally with @dast tag).
  5. Collect final reports from test/output/zapreport-final.html and test/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:

Documentation

Release and Publish

Best practice for public libraries is:

  1. Validate locally (build + twine check).
  2. Publish to TestPyPI.
  3. Create a GitHub Release tag.
  4. Publish to PyPI automatically from GitHub Actions (Trusted Publisher/OIDC recommended).

Release checklist

  1. Update version in behave_zap/version.py.
  2. Add release notes in CHANGELOG.md.
  3. Build and validate package:
    python -m build
    python -m twine check dist/*
    
  4. Publish to TestPyPI and test install.
  5. Create git tag and GitHub Release (for example v0.1.1).
  6. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

behave_zap-0.1.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

behave_zap-0.1.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

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

Hashes for behave_zap-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1b99941fc23cbed19ab1d6f52cc17d6a3b18146c20316a24a65f32e55b9955e6
MD5 acc0f61fc925df786630d51e151cf2c6
BLAKE2b-256 631ad3290d0b4f395277291e1d52ac6f27dcf14c61cbc89e519ee2e9d5df02ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for behave_zap-0.1.0.tar.gz:

Publisher: publish-pypi-release.yml on testingsoul/behave-zap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for behave_zap-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6299e70438219bcb05a49ecb0ba42e799aa1428fbe99b4f1024cf5f0b37a93a
MD5 3c0e41465eb480c9cc425e8fe33866bf
BLAKE2b-256 8c8e028d76b34959cb8bd0fd1b2986bb4cbc9a90a597bba938fc527b2b85fe70

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page