Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
15 changes: 15 additions & 0 deletions cycode/cli/code_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,17 @@ def _get_package_name(detection) -> str:
return f'{package_name}@{package_version}'


def _is_file_relevant_for_sca_scan(filename):
split_path = filename.split('/')

# if any path key contains any excluded path
if any([i in SCA_EXCLUDED_PATHS for i in split_path]):
logger.debug("file is irrelevant because it is from node_modules\'s inner path, %s",
{'filename': filename})
return False
return True


def _is_relevant_file_to_scan(scan_type: str, filename: str) -> bool:
if _is_subpath_of_cycode_configuration_folder(filename):
logger.debug("file is irrelevant because it is in cycode configuration directory, %s",
Expand All @@ -755,6 +766,10 @@ def _is_relevant_file_to_scan(scan_type: str, filename: str) -> bool:
logger.debug("file is irrelevant because its exceeded max size limit, %s",
{'filename': filename})
return False

if scan_type == SCA_SCAN_TYPE and not _is_file_relevant_for_sca_scan(filename):
return False

return True


Expand Down
4 changes: 4 additions & 0 deletions cycode/cli/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
'pipfile', 'pipfile.lock', 'requirements.txt', 'setup.py'
]

SCA_EXCLUDED_PATHS = [
'node_modules'
]

PROJECT_FILES_BY_ECOSYSTEM_MAP = {
"crates": ["Cargo.lock", "Cargo.toml"],
"composer": ["composer.json", "composer.lock"],
Expand Down
162 changes: 162 additions & 0 deletions tests/cli/data/node_modules/ms/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions tests/cli/data/node_modules/ms/license.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions tests/cli/data/node_modules/ms/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions tests/cli/data/node_modules/ms/readme.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
Loading