|
|
@ -62,6 +62,7 @@ class SlitherCore(Context): |
|
|
|
# Multiple time the same result, so we remove duplicates |
|
|
|
# Multiple time the same result, so we remove duplicates |
|
|
|
self._currently_seen_resuts: Set[str] = set() |
|
|
|
self._currently_seen_resuts: Set[str] = set() |
|
|
|
self._paths_to_filter: Set[str] = set() |
|
|
|
self._paths_to_filter: Set[str] = set() |
|
|
|
|
|
|
|
self._paths_to_include: Set[str] = set() |
|
|
|
|
|
|
|
|
|
|
|
self._crytic_compile: Optional[CryticCompile] = None |
|
|
|
self._crytic_compile: Optional[CryticCompile] = None |
|
|
|
|
|
|
|
|
|
|
@ -411,25 +412,29 @@ class SlitherCore(Context): |
|
|
|
if "source_mapping" in elem |
|
|
|
if "source_mapping" in elem |
|
|
|
] |
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
# Use POSIX-style paths so that filter_paths works across different |
|
|
|
# Use POSIX-style paths so that filter_paths|include_paths works across different |
|
|
|
# OSes. Convert to a list so elements don't get consumed and are lost |
|
|
|
# OSes. Convert to a list so elements don't get consumed and are lost |
|
|
|
# while evaluating the first pattern |
|
|
|
# while evaluating the first pattern |
|
|
|
source_mapping_elements = list( |
|
|
|
source_mapping_elements = list( |
|
|
|
map(lambda x: pathlib.Path(x).resolve().as_posix() if x else x, source_mapping_elements) |
|
|
|
map(lambda x: pathlib.Path(x).resolve().as_posix() if x else x, source_mapping_elements) |
|
|
|
) |
|
|
|
) |
|
|
|
matching = False |
|
|
|
(matching, paths, msg_err) = ( |
|
|
|
|
|
|
|
(True, self._paths_to_include, "--include-paths") |
|
|
|
|
|
|
|
if self._paths_to_include |
|
|
|
|
|
|
|
else (False, self._paths_to_filter, "--filter-paths") |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
for path in self._paths_to_filter: |
|
|
|
for path in paths: |
|
|
|
try: |
|
|
|
try: |
|
|
|
if any( |
|
|
|
if any( |
|
|
|
bool(re.search(_relative_path_format(path), src_mapping)) |
|
|
|
bool(re.search(_relative_path_format(path), src_mapping)) |
|
|
|
for src_mapping in source_mapping_elements |
|
|
|
for src_mapping in source_mapping_elements |
|
|
|
): |
|
|
|
): |
|
|
|
matching = True |
|
|
|
matching = not matching |
|
|
|
break |
|
|
|
break |
|
|
|
except re.error: |
|
|
|
except re.error: |
|
|
|
logger.error( |
|
|
|
logger.error( |
|
|
|
f"Incorrect regular expression for --filter-paths {path}." |
|
|
|
f"Incorrect regular expression for {msg_err} {path}." |
|
|
|
"\nSlither supports the Python re format" |
|
|
|
"\nSlither supports the Python re format" |
|
|
|
": https://docs.python.org/3/library/re.html" |
|
|
|
": https://docs.python.org/3/library/re.html" |
|
|
|
) |
|
|
|
) |
|
|
@ -500,6 +505,13 @@ class SlitherCore(Context): |
|
|
|
""" |
|
|
|
""" |
|
|
|
self._paths_to_filter.add(path) |
|
|
|
self._paths_to_filter.add(path) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def add_path_to_include(self, path: str): |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
Add path to include |
|
|
|
|
|
|
|
Path are used through direct comparison (no regex) |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
self._paths_to_include.add(path) |
|
|
|
|
|
|
|
|
|
|
|
# endregion |
|
|
|
# endregion |
|
|
|
################################################################################### |
|
|
|
################################################################################### |
|
|
|
################################################################################### |
|
|
|
################################################################################### |
|
|
|