Skip to content

Commit 0646f9b

Browse files
committed
tox: Remove bandit skips, run via pre-commit
Most of these skips were unnecessary. The few that did generate warnings could be skipped. We also set 'skip_install' since there's no reason to build the package for linting purposes. Change-Id: I9644e5c19720b9c41c60e0a5882b7cd7f6a71f7b Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
1 parent 648d8df commit 0646f9b

12 files changed

Lines changed: 32 additions & 44 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ repos:
2626
rev: 1.7.8
2727
hooks:
2828
- id: bandit
29-
args: ['-x', 'tests', '-s', 'B105,B106,B107,B401,B404,B603,B606,B607,B110,B605,B101']
29+
args: ['-x', 'tests']
3030
- repo: https://opendev.org/openstack/hacking
3131
rev: 6.1.0
3232
hooks:

openstackclient/common/module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,6 @@ def take_action(self, parsed_args):
113113
data[k] = mods[k].__version__
114114
except Exception:
115115
# Catch all exceptions, just skip it
116-
pass
116+
pass # nosec: B110
117117

118118
return zip(*sorted(data.items()))

openstackclient/compute/v2/server.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2843,11 +2843,12 @@ def take_action(self, parsed_args):
28432843
# there are infra failures
28442844
if parsed_args.name_lookup_one_by_one or image_id:
28452845
for image_id in image_ids:
2846-
# "Image Name" is not crucial, so we swallow any exceptions
28472846
try:
28482847
images[image_id] = image_client.get_image(image_id)
28492848
except Exception:
2850-
pass
2849+
# retrieving image names is not crucial, so we swallow
2850+
# any exceptions
2851+
pass # nosec: B110
28512852
else:
28522853
try:
28532854
# some deployments can have *loads* of images so we only
@@ -2866,7 +2867,9 @@ def take_action(self, parsed_args):
28662867
for i in images_list:
28672868
images[i.id] = i
28682869
except Exception:
2869-
pass
2870+
# retrieving image names is not crucial, so we swallow any
2871+
# exceptions
2872+
pass # nosec: B110
28702873

28712874
# create a dict that maps flavor_id to flavor object, which is used
28722875
# to display the "Flavor Name" column. Note that 'flavor.id' is not
@@ -2878,21 +2881,23 @@ def take_action(self, parsed_args):
28782881
for s in data
28792882
if s.flavor and s.flavor.get('id')
28802883
):
2881-
# "Flavor Name" is not crucial, so we swallow any
2882-
# exceptions
28832884
try:
28842885
flavors[f_id] = compute_client.find_flavor(
28852886
f_id, ignore_missing=False
28862887
)
28872888
except Exception:
2888-
pass
2889+
# retrieving flavor names is not crucial, so we swallow
2890+
# any exceptions
2891+
pass # nosec: B110
28892892
else:
28902893
try:
28912894
flavors_list = compute_client.flavors(is_public=None)
28922895
for i in flavors_list:
28932896
flavors[i.id] = i
28942897
except Exception:
2895-
pass
2898+
# retrieving flavor names is not crucial, so we swallow any
2899+
# exceptions
2900+
pass # nosec: B110
28962901

28972902
# Populate image_name, image_id, flavor_name and flavor_id attributes
28982903
# of server objects so that we can display those columns.
@@ -4805,7 +4810,9 @@ def take_action(self, parsed_args):
48054810

48064811
cmd = ' '.join(['ssh', ip_address] + args)
48074812
LOG.debug("ssh command: {cmd}".format(cmd=cmd))
4808-
os.system(cmd)
4813+
# we intentionally pass through user-provided arguments and run this in
4814+
# the user's shell
4815+
os.system(cmd) # nosec: B605
48094816

48104817

48114818
class StartServer(command.Command):

openstackclient/compute/v2/usage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def _format_project(project):
182182
project_cache[p.id] = p
183183
except Exception:
184184
# Just forget it if there's any trouble
185-
pass
185+
pass # nosec: B110
186186

187187
if parsed_args.formatter == 'table' and len(usage_list) > 0:
188188
self.app.stdout.write(

openstackclient/identity/v2_0/user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def take_action(self, parsed_args):
252252
project_cache[p.id] = p
253253
except Exception:
254254
# Just forget it if there's any trouble
255-
pass
255+
pass # nosec: B110
256256
formatters['tenantId'] = functools.partial(
257257
ProjectColumn, project_cache=project_cache
258258
)

openstackclient/volume/v1/volume.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ def take_action(self, parsed_args):
424424
server_cache[s.id] = s
425425
except Exception:
426426
# Just forget it if there's any trouble
427-
pass
427+
pass # nosec: B110
428428
AttachmentsColumnWithCache = functools.partial(
429429
AttachmentsColumn, server_cache=server_cache
430430
)

openstackclient/volume/v1/volume_backup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def take_action(self, parsed_args):
217217
volume_cache[s.id] = s
218218
except Exception:
219219
# Just forget it if there's any trouble
220-
pass
220+
pass # nosec: B110
221221
VolumeIdColumnWithCache = functools.partial(
222222
VolumeIdColumn, volume_cache=volume_cache
223223
)

openstackclient/volume/v1/volume_snapshot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def take_action(self, parsed_args):
244244
volume_cache[s.id] = s
245245
except Exception:
246246
# Just forget it if there's any trouble
247-
pass
247+
pass # nosec: B110
248248
VolumeIdColumnWithCache = functools.partial(
249249
VolumeIdColumn, volume_cache=volume_cache
250250
)

openstackclient/volume/v2/volume.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ def take_action(self, parsed_args):
537537
server_cache[s.id] = s
538538
except Exception:
539539
# Just forget it if there's any trouble
540-
pass
540+
pass # nosec: B110
541541
AttachmentsColumnWithCache = functools.partial(
542542
AttachmentsColumn, server_cache=server_cache
543543
)

openstackclient/volume/v2/volume_backup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def take_action(self, parsed_args):
325325
volume_cache[s.id] = s
326326
except Exception:
327327
# Just forget it if there's any trouble
328-
pass
328+
pass # nosec: B110
329329

330330
_VolumeIdColumn = functools.partial(
331331
VolumeIdColumn, volume_cache=volume_cache

0 commit comments

Comments
 (0)