Skip to content

Commit

Permalink
Minor tweaks to prevent issues at runtime, and simplify security targ…
Browse files Browse the repository at this point in the history
…ets to scan.
  • Loading branch information
charlieparkes committed Jul 1, 2020
1 parent 428a9a7 commit 0a6d001
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
3 changes: 0 additions & 3 deletions modules/python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ PYTHON := $(shell which python 2>/dev/null)

PYTHON_TARGETS_FIND_FLAGS=-name "*.py" -not -path "*/.venv/*" -not -path "*/$(BUILD_HARNESS_VENV_NAME)/*" -not -path "*/.tox/*" -not -path "*/.egg*" -not -path "*/frontend/*" -not -path "*/dist/*" -not -path "*/build/*"

PYTHON_LINT_TARGETS?=$(shell find . $(PYTHON_TARGETS_FIND_FLAGS))
PYTHON_SECURITY_TARGETS?=$(shell find . $(PYTHON_TARGETS_FIND_FLAGS) -not -path "*/tests/*")


.PHONY: python/check
python/check: ; $(call assert-set,PYTHON) && echo "Found python: $(PYTHON)"
Expand Down
28 changes: 15 additions & 13 deletions modules/python/Makefile.security
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
BANDIT=$(call which, bandit)
BANDIT_FLAGS=-ll -ii

PYTHON_SECURITY_TARGETS?=$(shell find . $(PYTHON_TARGETS_FIND_FLAGS) -not -path "*/tests/*")

.PHONY: python/security/targets
python/security/targets:

.PHONY: python/scan/targets
python/scan/targets:
@VAR=( $(PYTHON_SECURITY_TARGETS) ); echo "Discovered $${#VAR[@]} files:"
@echo "$$(echo $(PYTHON_SECURITY_TARGETS) | tr ' ' '\n')"

.PHONY: python/security/announce/%
python/security/announce/%:
@VAR=( $(PYTHON_SECURITY_TARGETS) ); echo "Checking $${#VAR[@]} files with $*..."

.PHONY: python/scan/announce/%
python/scan/announce/%:
@VAR=( $(PYTHON_SECURITY_TARGETS) ); echo "Scanning $${#VAR[@]} files with $*..."

.PHONY: python/security/bandit
python/security/bandit: bh/venv
.PHONY: python/bandit
## Scan python files for security vulnerabilities with bandit
python/bandit: bh/venv
$(call assert-set,BANDIT)
@$(MAKE) python/security/announce/bandit
@$(MAKE) python/scan/announce/bandit
@$(BANDIT) $(PYTHON_SECURITY_TARGETS) $(BANDIT_FLAGS)

.PHONY: python/security
python/security: python/security/targets python/security/bandit

.PHONY: python/scan
python/scan: python/security
## Scan python files for security vulnerabilities
python/scan: bh/venv
@$(MAKE) python/scan/targets python/bandit
@echo "Done."
5 changes: 4 additions & 1 deletion modules/python/Makefile.style
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ FLAKE8_FLAGS:=--select=B,C,E,F,W,T4,B9 --ignore=E203,E231,E266,E501,W503 --outpu
# W503: https://github.com/psf/black/pull/36
# E501: Let black handle line length

PYTHON_LINT_TARGETS?=$(shell find . $(PYTHON_TARGETS_FIND_FLAGS))

.PHONY: python/lint/targets
python/lint/targets:
@VAR=( $(PYTHON_LINT_TARGETS) ); echo "Discovered $${#VAR[@]} files:"
Expand Down Expand Up @@ -76,4 +78,5 @@ python/flake8: bh/venv

.PHONY: python/fmt
## Format python files
python/fmt: python/isort python/black python/autoflake
python/fmt: bh/venv
@$(MAKE) python/isort python/black python/autoflake

0 comments on commit 0a6d001

Please sign in to comment.