Skip to content

Commit 5f874a5

Browse files
CM-51659 - Add customization of timeouts for dependency trees (SCA restore) (#333)
1 parent 8241439 commit 5f874a5

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

cycode/cli/files_collector/sca/maven/restore_gradle_dependencies.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
BUILD_GRADLE_FILE_NAME = 'build.gradle'
1313
BUILD_GRADLE_KTS_FILE_NAME = 'build.gradle.kts'
1414
BUILD_GRADLE_DEP_TREE_FILE_NAME = 'gradle-dependencies-generated.txt'
15-
BUILD_GRADLE_ALL_PROJECTS_TIMEOUT = 180
1615
BUILD_GRADLE_ALL_PROJECTS_COMMAND = ['gradle', 'projects']
1716
ALL_PROJECTS_REGEX = r"[+-]{3} Project '(.*?)'"
1817

@@ -48,7 +47,7 @@ def get_working_directory(self, document: Document) -> Optional[str]:
4847
def get_all_projects(self) -> set[str]:
4948
output = shell(
5049
command=BUILD_GRADLE_ALL_PROJECTS_COMMAND,
51-
timeout=BUILD_GRADLE_ALL_PROJECTS_TIMEOUT,
50+
timeout=self.command_timeout,
5251
working_directory=get_path_from_context(self.ctx),
5352
)
5453
if not output:

cycode/cli/files_collector/sca/sca_file_collector.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from typing import TYPE_CHECKING, Optional
23

34
import typer
@@ -122,14 +123,15 @@ def _try_restore_dependencies(
122123

123124

124125
def _get_restore_handlers(ctx: typer.Context, is_git_diff: bool) -> list[BaseRestoreDependencies]:
126+
build_dep_tree_timeout = int(os.getenv('CYCODE_BUILD_DEP_TREE_TIMEOUT_SECONDS', BUILD_DEP_TREE_TIMEOUT))
125127
return [
126-
RestoreGradleDependencies(ctx, is_git_diff, BUILD_DEP_TREE_TIMEOUT),
127-
RestoreMavenDependencies(ctx, is_git_diff, BUILD_DEP_TREE_TIMEOUT),
128-
RestoreSbtDependencies(ctx, is_git_diff, BUILD_DEP_TREE_TIMEOUT),
129-
RestoreGoDependencies(ctx, is_git_diff, BUILD_DEP_TREE_TIMEOUT),
130-
RestoreNugetDependencies(ctx, is_git_diff, BUILD_DEP_TREE_TIMEOUT),
131-
RestoreNpmDependencies(ctx, is_git_diff, BUILD_DEP_TREE_TIMEOUT),
132-
RestoreRubyDependencies(ctx, is_git_diff, BUILD_DEP_TREE_TIMEOUT),
128+
RestoreGradleDependencies(ctx, is_git_diff, build_dep_tree_timeout),
129+
RestoreMavenDependencies(ctx, is_git_diff, build_dep_tree_timeout),
130+
RestoreSbtDependencies(ctx, is_git_diff, build_dep_tree_timeout),
131+
RestoreGoDependencies(ctx, is_git_diff, build_dep_tree_timeout),
132+
RestoreNugetDependencies(ctx, is_git_diff, build_dep_tree_timeout),
133+
RestoreNpmDependencies(ctx, is_git_diff, build_dep_tree_timeout),
134+
RestoreRubyDependencies(ctx, is_git_diff, build_dep_tree_timeout),
133135
]
134136

135137

0 commit comments

Comments
 (0)