forked from OWASP/pytm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (46 loc) · 1.59 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
CWD := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
DOCKER_IMG := pytm
ifeq ($(USE_DOCKER),true)
SHELL=docker
.SHELLFLAGS=run -u $$(id -u) -v $(CWD):/usr/src/app --rm $(DOCKER_IMG):latest -c
endif
ifndef PLANTUML_PATH
export PLANTUML_PATH = ./plantuml.jar
endif
models := tm.py
libs := $(wildcard pytm/*.py) $(wildcard pytm/threatlib/*.json) $(wildcard pytm/images/*)
all: clean
all: $(models:.py=/report.html) $(models:.py=/dfd.png) $(models:.py=/seq.png) docs/pytm/index.html
docs/pytm/index.html: $(wildcard pytm/*.py)
PYTHONPATH=. pdoc --html --force --output-dir docs pytm
docs/threats.md: $(wildcard pytm/threatlib/*.json)
printf "# Threat database\n" > $@
jq -r ".[] | \"$$(cat docs/threats.jq)\"" $< >> $@
clean:
rm -rf dist/* build/* $(models:.py=/*)
tm:
mkdir -p tm
%/dfd.png: %.py tm $(libs)
./$< --dfd | dot -Tpng -o $@
%/seq.png: %.py tm $(libs)
./$< --seq | java -Djava.awt.headless=true -jar $$PLANTUML_PATH -tpng -pipe > $@
%/report.html: %.py tm $(libs) docs/template.md docs/Stylesheet.css
./$< --report docs/template.md | pandoc -f markdown -t html > $@
dfd: $(models:.py=/dfd.png)
seq: $(models:.py=/seq.png)
report: $(models:.py=/report.html) seq dfd
.PHONY: test
test:
@python3 -m unittest
.PHONY: describe
describe:
./tm.py --describe "TM Element Boundary ExternalEntity Actor Lambda Server Process SetOfProcesses Datastore Dataflow"
.PHONY: image
image:
docker build -t $(DOCKER_IMG) .
.PHONY: docs
docs: docs/pytm/index.html docs/threats.md
.PHONY: fmt
fmt:
black $(wildcard pytm/*.py) $(wildcard tests/*.py) $(wildcard *.py)