adtree-viz
Project description
adtree-viz
Intro
An Attack-Defense Tree modelling lib that allows user to model attack-defense scenarios using an internal DSL.
Project inspired by https://github.com/hyakuhei/attackTrees and https://github.com/tahti/ADTool2.
The main goals are:
- add support for AND nodes
- be able to break down a large tree into multiple subtrees.
- keep it simple, only Attack and Defense nodes
Usage
Requirements:
Graphviz
Python 3.9
Install the library
pip install adtree-viz
Quick start
from adtree.models import Attack, Defence, AndGate
from adtree.renderer import Renderer
from adtree.themes import RedBlueFillTheme
root_node = Attack("the goal", [
Attack("path1", [
Defence("defend path1", [
Attack("path1 defence defeated")
])
]),
Attack("path2", [
Attack("path2.1"),
AndGate([
Attack("path3.1"),
Attack("path3.2"),
]),
]),
])
theme = RedBlueFillTheme()
renderer = Renderer(theme=theme, output_format="png", view=True)
renderer.render(root_node=root_node, filename="my-adtree")
The above should produce an attack-defence tree like this:
Development
Create a venv
python3.9 -m venv venv
Activate
. venv/bin/activate
Install deps
pip install -r requirements.txt
Run tests
PYTHONPATH=src python -m pytest
Release to Github and PyPi
Create tag and push
./release.sh
Manually build and release
Run the below to generate a distributable archive:
python3 -m build
The adtree-viz-x.xx.x.tar.gz
archive can be found in the dist
folder.
Deploy to PyPi
python3 -m twine upload -r pypi dist/*
# Use __token__ as username
# Use PyPi API TOKEN as password
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
adtree-viz-0.0.7.tar.gz
(7.6 kB
view hashes)
Built Distribution
Close
Hashes for adtree_viz-0.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2416b3165282da6edd1d7a11b6fc58406cd31b0c22cadf95efa678852f776f4e |
|
MD5 | 0fb3392252187b6ae45f0af03dfb2454 |
|
BLAKE2b-256 | 2012815bf07d18a157869e01a6f321816f473c2598c0acb8afad5d1edce1fc94 |