Skip to content

Commit f352f6f

Browse files
CM-55749-Add scan entrypoint marker file
1 parent b3f7f9d commit f352f6f

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

cycode/cli/apps/scan/code_scanner.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import time
23
from platform import platform
34
from typing import TYPE_CHECKING, Callable, Optional
@@ -30,6 +31,7 @@
3031
)
3132
from cycode.cyclient.models import ZippedFileScanResult
3233
from cycode.logger import get_logger
34+
from cycode.cli.utils.path_utils import get_path_by_os, get_absolute_path
3335

3436
if TYPE_CHECKING:
3537
from cycode.cli.files_collector.models.in_memory_zip import InMemoryZip
@@ -53,6 +55,19 @@ def scan_disk_files(ctx: typer.Context, paths: tuple[str, ...]) -> None:
5355
paths,
5456
is_cycodeignore_allowed=is_cycodeignore_allowed_by_scan_config(ctx),
5557
)
58+
59+
# Add entrypoint.cycode file at each root path to mark the scan root
60+
for root_path in paths:
61+
absolute_root_path = get_absolute_path(root_path)
62+
entrypoint_path = get_path_by_os(os.path.join(absolute_root_path, consts.CYCODE_ENTRYPOINT_FILENAME))
63+
entrypoint_document = Document(
64+
entrypoint_path,
65+
'', # Empty file content
66+
is_git_diff_format=False,
67+
absolute_path=entrypoint_path,
68+
)
69+
documents.append(entrypoint_document)
70+
5671
add_sca_dependencies_tree_documents_if_needed(ctx, scan_type, documents)
5772
scan_documents(ctx, documents, get_scan_parameters(ctx, paths))
5873
except Exception as e:

cycode/cli/consts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
IAC_SCAN_SUPPORTED_FILE_PREFIXES = ('dockerfile', 'containerfile')
1919

2020
CYCODEIGNORE_FILENAME = '.cycodeignore'
21+
CYCODE_ENTRYPOINT_FILENAME = 'entrypoint.cycode'
2122

2223
SECRET_SCAN_FILE_EXTENSIONS_TO_IGNORE = (
2324
'.DS_Store',

0 commit comments

Comments
 (0)