Skip to content

Commit

Permalink
added semgrep extension support
Browse files Browse the repository at this point in the history
  • Loading branch information
ajinabraham committed May 15, 2021
1 parent 60fa5c1 commit 703af55
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libsast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
__title__ = 'libsast'
__authors__ = 'Ajin Abraham'
__copyright__ = 'Copyright 2020 Ajin Abraham, OpenSecurity'
__version__ = '1.4.2'
__version__ = '1.4.3'
__version_info__ = tuple(int(i) for i in __version__.split('.'))
__all__ = [
'Scanner',
Expand Down
11 changes: 10 additions & 1 deletion libsast/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ def __init__(self, options: dict, paths: list) -> None:
'ignore_paths': None,
'show_progress': False,
}
if options.get('sgrep_extensions'):
self.sgrep_extensions = options.get('sgrep_extensions')
else:
self.sgrep_extensions = []
if options.get('ignore_extensions'):
self.ignore_extensions = options.get('ignore_extensions')
else:
Expand Down Expand Up @@ -86,7 +90,12 @@ def validate_file(self, path):
ignore_paths = any(pp in path.as_posix() for pp in self.ignore_paths)
ignore_files = path.name in self.ignore_filenames
ignore_exts = path.suffix.lower() in self.ignore_extensions
if (ignore_paths or ignore_files or ignore_exts):
if self.sgrep_extensions:
valid_exts = path.suffix.lower() in self.sgrep_extensions
else:
# Do not use extension check when no extensions are supplied
valid_exts = True
if (ignore_paths or ignore_files or ignore_exts or not valid_exts):
return False
if not path.exists() or not path.is_file():
return False
Expand Down

0 comments on commit 703af55

Please sign in to comment.