Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework GitPython dependency to be an extra for bandit-baseline #1099

Merged
merged 1 commit into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion bandit/cli/baseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
import sys
import tempfile

import git
try:
import git
except ImportError:
git = None

bandit_args = sys.argv[1:]
baseline_tmp_file = "_bandit_baseline_run.json_"
Expand Down Expand Up @@ -198,6 +201,11 @@ def initialize():
report_fname = f"{report_basename}.{output_format}"

# #################### Check Requirements #################################
if git is None:
LOG.error("Git not available, reinstall with baseline extra")
valid = False
return (None, None, None)

try:
repo = git.Repo(os.getcwd())

Expand Down
7 changes: 7 additions & 0 deletions doc/source/start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ If you want to include TOML support, install it with the `toml` extras:

pip install bandit[toml]

If you want to use the bandit-baseline CLI, install it with the `baseline`
extras:

.. code-block:: console

pip install bandit[baseline]

Run Bandit:

.. code-block:: console
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
GitPython>=3.1.30 # BSD License (3 clause)
PyYAML>=5.3.1 # MIT
stevedore>=1.20.0 # Apache-2.0
colorama>=0.3.9;platform_system=="Windows" # BSD License (3 clause)
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ yaml =
PyYAML
toml =
tomli>=1.1.0; python_version < "3.11"
baseline =
GitPython>=3.1.30

[entry_points]
console_scripts =
Expand Down
1 change: 0 additions & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ flake8>=4.0.0 # Apache-2.0
stestr>=2.5.0 # Apache-2.0
testscenarios>=0.5.0 # Apache-2.0/BSD
testtools>=2.3.0 # MIT
tomli>=1.1.0;python_version<"3.11" # MIT
beautifulsoup4>=4.8.0 # MIT
pylint==1.9.4 # GPLv2
5 changes: 4 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ setenv =
deps =
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
extras =
yaml
toml
baseline
commands =
find bandit -type f -name "*.pyc" -delete
stestr run {posargs}
Expand All @@ -34,7 +38,6 @@ commands = flake8 {posargs} bandit
bandit-baseline -r bandit -ll -ii

[testenv:pep8]
skip_install = true
ignore_errors = true
deps = {[testenv]deps}
.
Expand Down