Skip to content

Commit a57ba40

Browse files
authored
Revert "CM-68872: gate secret-scan async (presigned) flow behind CYCO… (#497)
1 parent 815461f commit a57ba40

8 files changed

Lines changed: 11 additions & 87 deletions

File tree

cycode/cli/consts.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,13 @@
222222
FILE_MAX_SIZE_LIMIT_IN_BYTES = 5000000
223223

224224
PRESIGNED_LINK_UPLOADED_ZIP_MAX_SIZE_LIMIT_IN_BYTES = 5 * 1024 * 1024 * 1024 # 5 GB (S3 presigned POST limit)
225-
PRESIGNED_UPLOAD_SCAN_TYPES = {SAST_SCAN_TYPE}
226-
# Secret scans use the previous (batched / API-upload) flow by default. The presigned S3 async flow is
227-
# opt-in via the SECRET_SCAN_ASYNC_ENV_VAR_NAME env var; see should_use_presigned_upload.
228-
SECRET_SCAN_ASYNC_ENV_VAR_NAME = 'CYCODE_SECRET_SCAN_ASYNC'
225+
PRESIGNED_UPLOAD_SCAN_TYPES = {SAST_SCAN_TYPE, SECRET_SCAN_TYPE}
229226

230227
DEFAULT_ZIP_MAX_SIZE_LIMIT_IN_BYTES = 20 * 1024 * 1024
231228
ZIP_MAX_SIZE_LIMIT_IN_BYTES = {
232229
SCA_SCAN_TYPE: 200 * 1024 * 1024,
233230
SAST_SCAN_TYPE: PRESIGNED_LINK_UPLOADED_ZIP_MAX_SIZE_LIMIT_IN_BYTES,
231+
SECRET_SCAN_TYPE: PRESIGNED_LINK_UPLOADED_ZIP_MAX_SIZE_LIMIT_IN_BYTES,
234232
}
235233

236234
# scan in batches

cycode/cli/files_collector/zip_documents.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,13 @@
66
from cycode.cli.exceptions import custom_exceptions
77
from cycode.cli.files_collector.models.in_memory_zip import InMemoryZip
88
from cycode.cli.models import Document
9-
from cycode.cli.utils.scan_utils import should_use_presigned_upload
109
from cycode.logger import get_logger
1110

1211
logger = get_logger('ZIP')
1312

1413

1514
def _validate_zip_file_size(scan_type: str, zip_file_size: int) -> None:
16-
if should_use_presigned_upload(scan_type):
17-
max_size_limit = consts.PRESIGNED_LINK_UPLOADED_ZIP_MAX_SIZE_LIMIT_IN_BYTES
18-
else:
19-
max_size_limit = consts.ZIP_MAX_SIZE_LIMIT_IN_BYTES.get(scan_type, consts.DEFAULT_ZIP_MAX_SIZE_LIMIT_IN_BYTES)
15+
max_size_limit = consts.ZIP_MAX_SIZE_LIMIT_IN_BYTES.get(scan_type, consts.DEFAULT_ZIP_MAX_SIZE_LIMIT_IN_BYTES)
2016
if zip_file_size > max_size_limit:
2117
raise custom_exceptions.ZipTooLargeError(max_size_limit)
2218

cycode/cli/utils/scan_utils.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
from cycode.cli import consts
99
from cycode.cli.cli_types import SeverityOption
10-
from cycode.config import parse_bool
1110

1211
if TYPE_CHECKING:
1312
from cycode.cli.models import LocalScanResult
@@ -34,11 +33,7 @@ def is_cycodeignore_allowed_by_scan_config(ctx: typer.Context) -> bool:
3433

3534

3635
def should_use_presigned_upload(scan_type: str) -> bool:
37-
if scan_type in consts.PRESIGNED_UPLOAD_SCAN_TYPES:
38-
return True
39-
if scan_type == consts.SECRET_SCAN_TYPE:
40-
return parse_bool(os.getenv(consts.SECRET_SCAN_ASYNC_ENV_VAR_NAME))
41-
return False
36+
return scan_type in consts.PRESIGNED_UPLOAD_SCAN_TYPES
4237

4338

4439
def generate_unique_scan_id() -> UUID:

cycode/config.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,11 @@ def get_val_as_string(key: str) -> str:
1919
return configuration.get(key)
2020

2121

22-
_TRUTHY_STRING_VALUES = {'true', '1', 'yes', 'y', 'on', 'enabled'}
23-
24-
25-
def parse_bool(value: Optional[str]) -> bool:
26-
return value is not None and value.lower() in _TRUTHY_STRING_VALUES
27-
28-
2922
def get_val_as_bool(key: str, default: bool = False) -> bool:
3023
if key not in configuration:
3124
return default
3225

33-
return parse_bool(configuration[key])
26+
return configuration[key].lower() in {'true', '1', 'yes', 'y', 'on', 'enabled'}
3427

3528

3629
def get_val_as_int(key: str) -> Optional[int]:

tests/cli/commands/scan/test_code_scanner.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,14 @@ def test_entrypoint_cycode_not_added_for_single_file(
168168

169169

170170
@pytest.mark.parametrize(
171-
('scan_type', 'command_scan_type', 'sync_option', 'secret_async_env', 'expect_presigned'),
171+
('scan_type', 'command_scan_type', 'sync_option', 'expect_presigned'),
172172
[
173173
# SAST keeps uploading directly to S3 via a presigned URL (regression guard for the new sync gate).
174-
(consts.SAST_SCAN_TYPE, 'path', False, False, True),
175-
# Secret scans use the previous batched flow by default (presigned async is opt-in).
176-
(consts.SECRET_SCAN_TYPE, 'path', False, False, False),
177-
# With CYCODE_SECRET_SCAN_ASYNC enabled, secret scans upload as a single file directly to S3.
178-
(consts.SECRET_SCAN_TYPE, 'path', False, True, True),
179-
# A --sync secret scan must stay on the batched inline path even when async is enabled.
180-
(consts.SECRET_SCAN_TYPE, 'path', True, True, False),
174+
(consts.SAST_SCAN_TYPE, 'path', False, True),
175+
# Async secret scans now upload as a single file directly to S3 via a presigned URL.
176+
(consts.SECRET_SCAN_TYPE, 'path', False, True),
177+
# A --sync secret scan must stay on the batched inline path and never build one giant zip.
178+
(consts.SECRET_SCAN_TYPE, 'path', True, False),
181179
],
182180
)
183181
@patch('cycode.cli.apps.scan.code_scanner.print_local_scan_results')
@@ -194,13 +192,8 @@ def test_scan_documents_routes_upload_by_scan_type_and_sync(
194192
scan_type: str,
195193
command_scan_type: str,
196194
sync_option: bool,
197-
secret_async_env: bool,
198195
expect_presigned: bool,
199-
monkeypatch: pytest.MonkeyPatch,
200196
) -> None:
201-
if secret_async_env:
202-
monkeypatch.setenv(consts.SECRET_SCAN_ASYNC_ENV_VAR_NAME, 'true')
203-
204197
mock_presigned_upload.return_value = ([], [])
205198
mock_batched_scan.return_value = ([], [])
206199

tests/cli/commands/scan/test_commit_range_scanner.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from unittest.mock import MagicMock, Mock, patch
22

3-
import pytest
4-
53
from cycode.cli import consts
64
from cycode.cli.apps.scan.commit_range_scanner import _scan_commit_range_documents
75
from cycode.cli.exceptions import custom_exceptions
@@ -27,10 +25,7 @@ def test_commit_range_scan_falls_back_to_api_when_presigned_upload_raises_wrappe
2725
mock_print: Mock,
2826
mock_handle_exception: Mock,
2927
mock_report_status: Mock,
30-
monkeypatch: pytest.MonkeyPatch,
3128
) -> None:
32-
# Secret uses the presigned flow only when async is opted in.
33-
monkeypatch.setenv(consts.SECRET_SCAN_ASYNC_ENV_VAR_NAME, 'true')
3429
# SlowUploadConnectionError is a CycodeError, not a requests.RequestException — the presigned
3530
# commit-range fallback must still catch it and retry via the Cycode API.
3631
mock_v4_async.side_effect = custom_exceptions.SlowUploadConnectionError

tests/cli/utils/__init__.py

Whitespace-only changes.

tests/cli/utils/test_scan_utils.py

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)