Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for wildcard file names #46

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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