Skip to content

Commit 05c66bc

Browse files
committed
CM-53944-Fixed comment
1 parent 36797b8 commit 05c66bc

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

cycode/cli/files_collector/file_excluder.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ def apply_scan_config(self, scan_type: str, scan_config: 'models.ScanConfigurati
6969
if scan_config.scannable_extensions:
7070
self._scannable_extensions[scan_type] = tuple(scan_config.scannable_extensions)
7171

72+
def _is_file_prefix_supported(self, scan_type: str, file_path: str):
73+
path = Path(file_path)
74+
file_name = path.name.lower()
75+
scannable_prefixes = self._scannable_prefixes.get(scan_type)
76+
if scannable_prefixes:
77+
return file_name.startswith(scannable_prefixes)
78+
7279
def _is_file_extension_supported(self, scan_type: str, filename: str) -> bool:
7380
filename = filename.lower()
7481

@@ -80,10 +87,6 @@ def _is_file_extension_supported(self, scan_type: str, filename: str) -> bool:
8087
if non_scannable_extensions:
8188
return not filename.endswith(non_scannable_extensions)
8289

83-
scannable_prefixes = self._scannable_prefixes.get(scan_type)
84-
if scannable_prefixes:
85-
return filename.startswith(scannable_prefixes)
86-
8790
return True
8891

8992
def _is_relevant_file_to_scan_common(self, scan_type: str, filename: str) -> bool:
@@ -99,8 +102,10 @@ def _is_relevant_file_to_scan_common(self, scan_type: str, filename: str) -> boo
99102
'The document is irrelevant because its path is in the ignore paths list, %s', {'filename': filename}
100103
)
101104
return False
105+
if self._is_file_prefix_supported(scan_type, filename):
106+
return True
102107

103-
if self._should_check_if_extensions_are_supported(scan_type, filename):
108+
if not self._is_file_extension_supported(scan_type, filename):
104109
logger.debug(
105110
'The document is irrelevant because its extension is not supported, %s',
106111
{'scan_type': scan_type, 'filename': filename},
@@ -109,10 +114,6 @@ def _is_relevant_file_to_scan_common(self, scan_type: str, filename: str) -> boo
109114

110115
return True
111116

112-
# We don't want to check for IAC scans, the extensions is handled internally
113-
def _should_check_if_extensions_are_supported(self, scan_type: str, filename: str) -> bool:
114-
return scan_type != consts.IAC_SCAN_TYPE and not self._is_file_extension_supported(scan_type, filename)
115-
116117
def _is_relevant_file_to_scan(self, scan_type: str, filename: str) -> bool:
117118
if not self._is_relevant_file_to_scan_common(scan_type, filename):
118119
return False

0 commit comments

Comments
 (0)