FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

CM-65436: add SAST fallback ignore-extensions list by mateusz-sterczewski · Pull Request #473 · cycodehq/cycode-cli · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
24 changes: 24 additions & 0 deletions cycode/cli/consts.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,30 @@
'.iso',
)

# Fallback block-list used for SAST only when the server does not return scannable extensions
# (e.g. when the customer has custom rules, any text file is scannable). These are non-source
# data formats that can slip past binary detection (the EICAR test file and ClamAV signature
# databases are plain ASCII) and may be quarantined by object-storage antivirus after upload.
SAST_SCAN_FILE_EXTENSIONS_TO_IGNORE = (
'.bin',
'.cvd',
'.cld',
'.cud',
'.hdb',
'.hsb',
'.mdb',
'.msb',
'.ndb',
'.ndu',
'.ldb',
'.ldu',
'.idb',
'.fp',
'.sfp',
'.ign',
'.ign2',
)

SCA_CONFIGURATION_SCAN_SUPPORTED_FILES = ( # keep in lowercase
'cargo.lock',
'cargo.toml',
Expand Down
8 changes: 8 additions & 0 deletions cycode/cli/files_collector/file_excluder.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ def __init__(self) -> None:
}
self._non_scannable_extensions: dict[str, tuple[str, ...]] = {
consts.SECRET_SCAN_TYPE: consts.SECRET_SCAN_FILE_EXTENSIONS_TO_IGNORE,
consts.SAST_SCAN_TYPE: consts.SAST_SCAN_FILE_EXTENSIONS_TO_IGNORE,
}
# Tracks scan types for which the SAST fallback log has already been emitted (log once, not per file)
self._logged_sast_fallback = False

def apply_scan_config(self, scan_type: str, scan_config: 'models.ScanConfiguration') -> None:
if scan_config.scannable_extensions:
Expand All @@ -86,6 +89,11 @@ def _is_file_extension_supported(self, scan_type: str, filename: str) -> bool:

non_scannable_extensions = self._non_scannable_extensions.get(scan_type)
if non_scannable_extensions:
# For SAST, reaching the block-list means the server returned no scannable extensions
# (e.g. custom rules, or no remote config). Log once so this is diagnosable.
if scan_type == consts.SAST_SCAN_TYPE and not self._logged_sast_fallback:
self._logged_sast_fallback = True
logger.debug('No scannable extensions provided for SAST; falling back to the built-in ignore list')
return not filename.endswith(non_scannable_extensions)

return True
Expand Down
Loading

Back | FazBrowse Home | New Git URL