Skip to content

Conversation

@mshafer-NI
Copy link
Collaborator

Add bandit as a provided tool.

While bandit takes multiple "-c file" parameters, it only uses the latter...
So, to provide a global default (that says it's ok to assert in tests, and to skip a lot of non-python folders), AND support for a using project to provide config in their pyproject.toml, this is setup to load the vendored-config file, and merge in data from pyproject.toml and store the result in a temp file.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2024

Thank you for contributing! 👋

black = ">=23.1"
bandit = [
{version=">=1.5,<1.7", extras=["toml"], python="^3.7,<3.8"},
{version=">=1.7.9", extras=["toml"], python="^3.8"},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bandit 1.8.6 requires Python >= 3.9

Comment on lines +73 to +75
if key in target and isinstance(value, list):
_logger.debug("Merging %s: %s", key, value)
target[key].extend(value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, this allows projects to extend exclude_dirs.

_lint.lint_bandit(
qs_or_vs=_qs_or_vs(obj["VERBOSITY"]),
pyproject_config=pyproj_bandit_config,
file_or_dir=file_or_dir or [pathlib.Path.cwd()],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, there is an optional targets key in the config file.

I think defaulting to . and supporting excludes is probably enough for most projects, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants