Skip to content

Commit 35e0aed

Browse files
committed
added bandit
1 parent 9bac1d3 commit 35e0aed

File tree

9 files changed

+66
-16
lines changed

9 files changed

+66
-16
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ info:
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 secure
1515

1616
coverage:
1717
@pytest --cov --cov-report=html -vvv
@@ -25,3 +25,6 @@ pylint:
2525
black:
2626
@black hooks/
2727
@black tests/
28+
29+
secure:
30+
@bandit -c pyproject.toml -r .

cookiecutter.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"https"
4444
],
4545
"__template_repo": "https://github.com/btr1975/cookiecutter-python-library",
46-
"__template_version": "1.0.15",
46+
"__template_version": "1.0.16",
4747
"_new_lines": "\n",
4848
"_copy_without_render": [
4949
".github"

make.bat

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ 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 .
1213
GOTO END
1314
)
1415

@@ -33,6 +34,11 @@ IF "%1" == "black" (
3334
GOTO END
3435
)
3536

37+
IF "%1" == "secure" (
38+
bandit -c pyproject.toml -r .
39+
GOTO END
40+
)
41+
3642
@ECHO make options
3743
@ECHO coverage To run coverage and display ASCII and output to htmlcov
3844
@ECHO black To format the code with black

pyproject.toml

Lines changed: 8 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ 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

requirements.txt

Lines changed: 1 addition & 1 deletion
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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Makefile for project needs
22
# Author: Ben Trachtenberg
3-
# Version: 1.0.8
3+
# Version: 1.0.9
44
#
55

66
.PHONY: all info build build-container coverage format pylint pytest start-container stop-container remove-container \
@@ -12,6 +12,7 @@ info:
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 " format To format the code with black"
1718
@echo " pylint To run pylint"
@@ -21,7 +22,7 @@ info:
2122
@echo " remove-container To remove the container"
2223
{% if cookiecutter.library_documents_location == 'github-pages' %} @echo " gh-pages To create the GitHub pages"{% endif %}
2324

24-
all: coverage format pylint check-vuln
25+
all: format pylint coverage check-security check-vuln
2526

2627
build:
2728
@python -m build
@@ -80,3 +81,6 @@ remove-container:
8081

8182
check-vuln:
8283
@pip-audit -r requirements.txt
84+
85+
check-security:
86+
@bandit -c pyproject.toml -r .
Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,87 @@
11
@ECHO OFF
22
REM Makefile for project needs
33
REM Author: Ben Trachtenberg
4-
REM Version: 1.0.7
4+
REM Version: 1.0.8
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.__library_name}}/
1015
black tests/
1116
pylint {{cookiecutter.__library_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.__library_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" == "format" (
43+
IF "%option%" == "format" (
3744
black {{cookiecutter.__library_name}}/
3845
black tests/
3946
GOTO END
4047
)
4148

42-
IF "%1" == "check-vuln" (
49+
IF "%option%" == "check-vuln" (
4350
pip-audit -r requirements.txt
4451
GOTO END
4552
)
4653

54+
IF "%option%" == "check-security" (
55+
bandit -c pyproject.toml -r .
56+
GOTO END
57+
)
58+
4759
{% if cookiecutter.library_documents_location == 'github-pages' %}
48-
IF "%1" == "gh-pages" (
60+
IF "%option%" == "gh-pages" (
4961
rmdir /s /q docs\source\code
5062
sphinx-apidoc -o ./docs/source/code ./{{cookiecutter.__library_name}}
5163
sphinx-build ./docs ./docs/gh-pages
5264
GOTO END
5365
)
5466
{% endif %}
5567

68+
:OPTIONS
5669
@ECHO make options
5770
@ECHO all To run coverage, format, pylint, and check-vuln
5871
@ECHO build To build a distribution
5972
@ECHO coverage To run coverage and display ASCII and output to htmlcov
6073
@ECHO check-vuln To check for vulnerabilities in the dependencies
74+
@ECHO check-security To check for vulnerabilities in the code
6175
@ECHO format To format the code with black
6276
@ECHO pylint To run pylint
6377
@ECHO pytest To run pytest with verbose option
6478
{% if cookiecutter.library_documents_location == 'github-pages' %}@ECHO gh-pages To create the GitHub pages{% endif %}
79+
GOTO END
80+
81+
:BAD_OPTIONS
82+
@ECHO Argument is missing
83+
@ECHO Usage: make.bat option
84+
@ECHO.
85+
GOTO OPTIONS
6586

6687
:END

{{cookiecutter.git_repo_name}}/pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,10 @@ fail-under = 9.9
102102

103103
[tool.black]
104104
line-length = 120
105+
106+
[tool.bandit]
107+
exclude_dirs = [
108+
"tests",
109+
"venv",
110+
"docs"
111+
]

0 commit comments

Comments
 (0)