pre-commit: Bump versions and integrate bandit

Also remove the note about old pip's dependency resolver.

Change-Id: Ie835be50b9a5b1b054862c6fa904c701466952e6
This commit is contained in:
Takashi Kajinami 2024-03-29 11:20:22 +09:00
parent f2627a8975
commit d139433cc2
6 changed files with 10 additions and 25 deletions

View File

@ -1,15 +1,6 @@
# We from the Oslo project decided to pin repos based on the
# commit hash instead of the version tag to prevend arbitrary
# code from running in developer's machines. To update to a
# newer version, run `pre-commit autoupdate` and then replace
# the newer versions with their commit hash.
default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 9136088a246768144165fcc3ecc3d31bb686920a # v3.3.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
# Replaces or checks mixed line ending
@ -32,8 +23,13 @@ repos:
- id: flake8
name: flake8
additional_dependencies:
- hacking>=3.2.0,<3.3.0
- hacking>=6.1.0,<6.2.0
language: python
entry: flake8
files: '^.*\.py$'
exclude: '^(doc|releasenotes|tools)/.*$'
- repo: https://github.com/PyCQA/bandit
rev: 1.7.6
hooks:
- id: bandit
args: ['-x', 'tests', '--skip', 'B113']

View File

@ -172,7 +172,7 @@ def _format_rule_default_yaml(default, include_help=True, comment_rule=True,
:param add_deprecated_rules: Whether to add the deprecated rules in format
text.
:returns: A string containing a yaml representation of the RuleDefault
"""
""" # noqa: E501
text = ('"%(name)s": "%(check_str)s"\n' %
{'name': default.name,
'check_str': default.check_str})
@ -258,7 +258,7 @@ def _format_rule_default_json(default):
:param default: A policy.RuleDefault or policy.DocumentedRuleDefault object
:returns: A string containing a json representation of the RuleDefault
"""
""" # noqa: E501
return ('"%(name)s": "%(check_str)s"' %
{'name': default.name,
'check_str': default.check_str})

View File

@ -978,6 +978,6 @@ class ConvertJsonToYamlTestCase(base.PolicyBaseTestCase):
# or extra rules in policy file, it is strongly
# recommended to switch to new rules.
"deprecated_rule1_name": "rule:admin"
'''
''' # noqa: E501
self.assertIn(existing_deprecated_rule_with_warning,
converted_policy_data)

View File

@ -1,7 +1,3 @@
# 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.
requests>=2.14.2 # Apache-2.0
oslo.config>=6.0.0 # Apache-2.0
oslo.context>=2.22.0 # Apache-2.0

View File

@ -1,7 +1,3 @@
# 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.
oslotest>=3.2.0 # Apache-2.0
requests-mock>=1.2.0 # Apache-2.0
stestr>=2.0.0 # Apache-2.0

View File

@ -15,11 +15,8 @@ commands = stestr run --slowest {posargs}
[testenv:pep8]
deps =
pre-commit>=2.6.0 # MIT
bandit>=1.6.0,<1.7.0 # Apache-2.0
commands =
pre-commit run -a
# Run security linter
bandit -r oslo_policy tests -n5
[testenv:venv]
commands = {posargs}