Skip to content

Commit

Permalink
Add support for wildcard file names
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinas authored Sep 19, 2024
1 parent 09165d6 commit 6b7e741
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libsast/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
InvalidPathError,
)

from fnmatch import (
fnmatch,
)


class Scanner:
def __init__(self, options: dict, paths: list) -> None:
Expand Down Expand Up @@ -85,7 +89,7 @@ def validate_file(self, path):
"""Check if we should scan the file."""
ignore_paths = any(
Path(pp).as_posix() in path.as_posix() for pp in self.ignore_paths)
ignore_files = path.name in self.ignore_filenames
ignore_files = any(fnmatch(path.name, ignore_filename) for ignore_filename in self.ignore_filenames)
ignore_exts = path.suffix.lower() in self.ignore_extensions
if (ignore_paths or ignore_files or ignore_exts):
return False
Expand Down

0 comments on commit 6b7e741

Please sign in to comment.