Skip to content

Commit e5047af

Browse files
committed
added bandit
1 parent 3396ac8 commit e5047af

10 files changed

+87
-26
lines changed

Makefile

+8-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
# Version: 1.0.0
44
#
55

6-
.PHONY: all info coverage pytest black
6+
.PHONY: all info coverage pytest black security
77

88
info:
99
@echo "make options"
1010
@echo " black To format code with black"
1111
@echo " coverage To run coverage and display ASCII and output to htmlcov"
1212
@echo " pytest To run pytest with verbose option"
1313

14-
all: coverage black pylint
14+
all: black pylint coverage security vulnerabilities
1515

1616
coverage:
1717
@pytest --cov --cov-report=html -vvv
@@ -25,3 +25,9 @@ pylint:
2525
black:
2626
@black hooks/
2727
@black tests/
28+
29+
security:
30+
@bandit -c pyproject.toml -r .
31+
32+
vulnerabilities:
33+
@pip-audit -r requirements.txt

cookiecutter.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"https"
4444
],
4545
"__template_repo": "https://github.com/btr1975/cookiecutter-python-fastapi-openapi",
46-
"__template_version": "1.0.12",
46+
"__template_version": "1.0.13",
4747
"_new_lines": "\n",
4848
"_copy_without_render": [
4949
"{{cookiecutter.__app_name}}/templates",

make.bat

+13-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ REM Version: 1.0.0
55
REM
66

77
IF "%1" == "all" (
8-
pytest --cov --cov-report=html -vvv
98
black hooks\
109
black tests\
1110
pylint hooks\
11+
pytest --cov --cov-report=html -vvv
12+
bandit -c pyproject.toml -r .
13+
pip-audit -r requirements.txt
1214
GOTO END
1315
)
1416

@@ -33,6 +35,16 @@ IF "%1" == "black" (
3335
GOTO END
3436
)
3537

38+
IF "%1" == "security" (
39+
bandit -c pyproject.toml -r .
40+
GOTO END
41+
)
42+
43+
IF "%1" == "vulnerabilities" (
44+
pip-audit -r requirements.txt
45+
GOTO END
46+
)
47+
3648
@ECHO make options
3749
@ECHO coverage To run coverage and display ASCII and output to htmlcov
3850
@ECHO black To format the code with black

pyproject.toml

+8
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,11 @@ fail-under = 9.9
2727

2828
[tool.black]
2929
line-length = 120
30+
31+
[tool.bandit]
32+
exclude_dirs = [
33+
"tests",
34+
"venv",
35+
"docs",
36+
"{{cookiecutter.git_repo_name}}",
37+
]

requirements-dev.txt

+2
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ pytest-cookies~=0.7.0
44
pylint~=3.0.2
55
pip-audit~=2.7.3
66
black~=24.10.0
7+
bandit~=1.8.3
8+
pip-audit~=2.7.3

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cookiecutter~=2.5.0
1+
cookiecutter~=2.6.0

{{cookiecutter.git_repo_name}}/Makefile

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
#
55

66
.PHONY: all info build build-container coverage format pylint pytest gh-pages build dev-run start-container \
7-
stop-container remove-container check-vuln
7+
stop-container remove-container check-vuln check-security
88

99
info:
1010
@echo "make options"
1111
@echo " all To run coverage, format, pylint, and check-vuln"
1212
@echo " build To build a distribution"
1313
@echo " build-container To build a container image"
1414
@echo " check-vuln To check for vulnerabilities in the dependencies"
15+
@echo " check-security To check for vulnerabilities in the code"
1516
@echo " coverage To run coverage and display ASCII and output to htmlcov"
1617
@echo " dev-run To run the app"
1718
@echo " format To format the code with black"
@@ -22,7 +23,7 @@ info:
2223
@echo " remove-container To remove the container"
2324
{% if cookiecutter.app_documents_location == 'github-pages' %} @echo " gh-pages To create the GitHub pages"{% endif %}
2425

25-
all: coverage format pylint check-vuln
26+
all: format pylint coverage check-security check-vuln
2627

2728
build:
2829
@python -m build
@@ -84,3 +85,6 @@ remove-container:
8485

8586
check-vuln:
8687
@pip-audit -r requirements.txt
88+
89+
check-security:
90+
@bandit -c pyproject.toml -r .
+40-19
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,93 @@
11
@ECHO OFF
22
REM Makefile for project needs
33
REM Author: Ben Trachtenberg
4-
REM Version: 1.0.6
4+
REM Version: 1.0.7
55
REM
66

7-
IF "%1" == "all" (
8-
pytest --cov --cov-report=html -vvv
7+
SET option=%1
8+
9+
IF "%option%" == "" (
10+
GOTO BAD_OPTIONS
11+
)
12+
13+
IF "%option%" == "all" (
914
black {{cookiecutter.__app_name}}/
1015
black tests/
1116
pylint {{cookiecutter.__app_name}}\
17+
pytest --cov --cov-report=html -vvv
18+
bandit -c pyproject.toml -r .
1219
pip-audit -r requirements.txt
1320
GOTO END
1421
)
1522

16-
IF "%1" == "build" (
23+
IF "%option%" == "build" (
1724
python -m build
1825
GOTO END
1926
)
2027

21-
IF "%1" == "coverage" (
28+
IF "%option%" == "coverage" (
2229
pytest --cov --cov-report=html -vvv
2330
GOTO END
2431
)
2532

26-
IF "%1" == "pylint" (
33+
IF "%option%" == "pylint" (
2734
pylint {{cookiecutter.__app_name}}\
2835
GOTO END
2936
)
3037

31-
IF "%1" == "pytest" (
38+
IF "%option%" == "pytest" (
3239
pytest --cov -vvv
3340
GOTO END
3441
)
3542

36-
IF "%1" == "dev-run" (
43+
IF "%option%" == "dev-run" (
3744
python -c "from {{cookiecutter.__app_name}} import cli;cli()" start -p 8080 -r
3845
GOTO END
3946
)
4047

41-
IF "%1" == "format" (
48+
IF "%option%" == "format" (
4249
black {{cookiecutter.__app_name}}/
4350
black tests/
4451
GOTO END
4552
)
4653

47-
IF "%1" == "check-vuln" (
54+
IF "%option%" == "check-vuln" (
4855
pip-audit -r requirements.txt
4956
GOTO END
5057
)
5158

59+
IF "%option%" == "check-security" (
60+
bandit -c pyproject.toml -r .
61+
GOTO END
62+
)
63+
5264
{% if cookiecutter.app_documents_location == 'github-pages' %}
53-
IF "%1" == "gh-pages" (
65+
IF "%option%" == "gh-pages" (
5466
rmdir /s /q docs\source\code
5567
sphinx-apidoc -o ./docs/source/code ./{{cookiecutter.__app_name}}
5668
sphinx-build ./docs ./docs/gh-pages
5769
GOTO END
5870
)
5971
{% endif %}
6072

73+
:OPTIONS
6174
@ECHO make options
62-
@ECHO all To run coverage, format, pylint, and check-vuln
63-
@ECHO build To build a distribution
64-
@ECHO check-vuln To check for vulnerabilities
65-
@ECHO coverage To run coverage and display ASCII and output to htmlcov
66-
@ECHO dev-run To run the app
67-
@ECHO format To format the code with black
68-
@ECHO pylint To run pylint
69-
@ECHO pytest To run pytest with verbose option
75+
@ECHO all To run coverage, format, pylint, and check-vuln
76+
@ECHO build To build a distribution
77+
@ECHO coverage To run coverage and display ASCII and output to htmlcov
78+
@ECHO dev-run To run the app
79+
@ECHO check-vuln To check for vulnerabilities in the dependencies
80+
@ECHO check-security To check for vulnerabilities in the code
81+
@ECHO format To format the code with black
82+
@ECHO pylint To run pylint
83+
@ECHO pytest To run pytest with verbose option
7084
{% if cookiecutter.app_documents_location == 'github-pages' %}@ECHO gh-pages To create the GitHub pages{% endif %}
85+
GOTO END
86+
87+
:BAD_OPTIONS
88+
@ECHO Argument is missing
89+
@ECHO Usage: make.bat option
90+
@ECHO.
91+
GOTO OPTIONS
7192

7293
:END

{{cookiecutter.git_repo_name}}/pyproject.toml

+7
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,10 @@ fail-under = 9.9
100100

101101
[tool.black]
102102
line-length = 120
103+
104+
[tool.bandit]
105+
exclude_dirs = [
106+
"tests",
107+
"venv",
108+
"docs",
109+
]

{{cookiecutter.git_repo_name}}/requirements-dev.txt

+1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ sphinx_rtd_theme
1414
sphinxcontrib-mermaid
1515
httpx
1616
twine
17+
bandit
1718
{% if cookiecutter.use_requests == 'y' %}requests-mock{% endif %}

0 commit comments

Comments
 (0)