DOCKER_ARGS ?=
W3AF_COMMAND ?=
LIGHTHOUSE_COMMAND ?=
LIGHTHOUSE_URL ?=

image-w3af:
	docker build \
		--build-arg=HTTP_PROXY=$(HTTP_PROXY) \
		--build-arg=HTTPS_PROXY=$(HTTPS_PROXY) \
		--build-arg=http_proxy=$(http_proxy) \
		--build-arg=https_proxy=$(https_proxy) \
		-t jenkins-w3af \
		./resources/com/cadoles/w3af

interactive-w3af:
	$(MAKE) W3AF_COMMAND="/bin/sh" w3af

audit-w3af:
	$(MAKE) W3AF_COMMAND="/usr/local/bin/run-audit" w3af

w3af:
	docker run \
		-it --rm \
		--net host \
		-v "$(PWD)/resources/com/cadoles/w3af/audit.w3af.tmpl:/home/w3af/w3af/audit.w3af.tmpl:ro" \
		$(DOCKER_ARGS) \
		jenkins-w3af:latest \
		$(W3AF_COMMAND)

image-lighthouse:
	docker build \
		--build-arg=HTTP_PROXY=$(HTTP_PROXY) \
		--build-arg=HTTPS_PROXY=$(HTTPS_PROXY) \
		--build-arg=http_proxy=$(http_proxy) \
		--build-arg=https_proxy=$(https_proxy) \
		-t jenkins-lighthouse \
		./resources/com/cadoles/lighthouse

interactive-lighthouse:
	$(MAKE) LIGHTHOUSE_COMMAND="/bin/sh" lighthouse

audit-lighthouse:
	$(MAKE) LIGHTHOUSE_COMMAND="/usr/local/bin/run-audit" lighthouse

lighthouse:
	mkdir -p "$(PWD)/data/lighthouse/reports"
	docker run \
		-it --rm \
		--net host \
		--cap-add=SYS_ADMIN \
		-e HTTP_PROXY=$(HTTP_PROXY) \
		-e HTTPS_PROXY=$(HTTPS_PROXY) \
		-e http_proxy=$(http_proxy) \
		-e https_proxy=$(https_proxy) \
		-e LIGHTHOUSE_URL=$(LIGHTHOUSE_URL) \
		-u $(shell id -u $(USER)):$(shell id -g $(USER)) \
		-v "$(PWD)/data/lighthouse/reports:/home/lighthouse/reports" \
		$(DOCKER_ARGS) \
		jenkins-lighthouse:latest \
		$(LIGHTHOUSE_COMMAND)

.PHONY: image-w3af image-lighthouse