Skip to content

Commit 0ede84d

Browse files
committed
fix: correct no-prefix no-suffix exclude for top-level dirs
Resolves PyCQA#975
1 parent f1a3295 commit 0ede84d

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

bandit/core/manager.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,6 @@ def discover_files(self, targets, recursive=False, excluded_paths=""):
216216
# if there are command line provided exclusions add them to the list
217217
if excluded_paths:
218218
for path in excluded_paths.split(","):
219-
if os.path.isdir(path):
220-
path = os.path.join(path, "*")
221-
222219
excluded_path_globs.append(path)
223220

224221
# build list of files we will analyze

tests/unit/core/test_manager.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,25 +255,25 @@ def test_discover_files_exclude_dir(self, isdir):
255255
self.assertEqual(["./x/y.py"], self.manager.excluded_files)
256256

257257
# Test exclude dir without wildcard
258-
isdir.side_effect = [True, False]
258+
isdir.side_effect = [False]
259259
self.manager.discover_files(["./x/y.py"], True, "./x/")
260260
self.assertEqual([], self.manager.files_list)
261261
self.assertEqual(["./x/y.py"], self.manager.excluded_files)
262262

263263
# Test exclude dir without wildcard or trailing slash
264-
isdir.side_effect = [True, False]
264+
isdir.side_effect = [False]
265265
self.manager.discover_files(["./x/y.py"], True, "./x")
266266
self.assertEqual([], self.manager.files_list)
267267
self.assertEqual(["./x/y.py"], self.manager.excluded_files)
268268

269269
# Test exclude top-level dir without prefix or suffix
270-
isdir.side_effect = [True, False]
270+
isdir.side_effect = [False]
271271
self.manager.discover_files(["./x/y/z.py"], True, "x")
272272
self.assertEqual([], self.manager.files_list)
273273
self.assertEqual(["./x/y/z.py"], self.manager.excluded_files)
274274

275275
# Test exclude lower-level dir without prefix or suffix
276-
isdir.side_effect = [False, False]
276+
isdir.side_effect = [False]
277277
self.manager.discover_files(["./x/y/z.py"], True, "y")
278278
self.assertEqual([], self.manager.files_list)
279279
self.assertEqual(["./x/y/z.py"], self.manager.excluded_files)

0 commit comments

Comments
 (0)