Skip to content

Commit ebb8634

Browse files
authored
CM-42089 - Implement Ruby restore support for SCA (#271)
1 parent c8f9b12 commit ebb8634

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

cycode/cli/files_collector/sca/ruby/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import os
2+
from typing import List, Optional
3+
4+
from cycode.cli.files_collector.sca.base_restore_dependencies import BaseRestoreDependencies
5+
from cycode.cli.models import Document
6+
7+
RUBY_PROJECT_FILE_EXTENSIONS = ['Gemfile']
8+
RUBY_LOCK_FILE_NAME = 'Gemfile.lock'
9+
10+
11+
class RestoreRubyDependencies(BaseRestoreDependencies):
12+
def is_project(self, document: Document) -> bool:
13+
return any(document.path.endswith(ext) for ext in RUBY_PROJECT_FILE_EXTENSIONS)
14+
15+
def get_commands(self, manifest_file_path: str) -> List[List[str]]:
16+
return [['bundle', '--quiet']]
17+
18+
def get_lock_file_name(self) -> str:
19+
return RUBY_LOCK_FILE_NAME
20+
21+
def verify_restore_file_already_exist(self, restore_file_path: str) -> bool:
22+
return os.path.isfile(restore_file_path)
23+
24+
def get_working_directory(self, document: Document) -> Optional[str]:
25+
return os.path.dirname(document.absolute_path)

cycode/cli/files_collector/sca/sca_code_scanner.py

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from cycode.cli.files_collector.sca.maven.restore_maven_dependencies import RestoreMavenDependencies
1111
from cycode.cli.files_collector.sca.npm.restore_npm_dependencies import RestoreNpmDependencies
1212
from cycode.cli.files_collector.sca.nuget.restore_nuget_dependencies import RestoreNugetDependencies
13+
from cycode.cli.files_collector.sca.ruby.restore_ruby_dependencies import RestoreRubyDependencies
1314
from cycode.cli.files_collector.sca.sbt.restore_sbt_dependencies import RestoreSbtDependencies
1415
from cycode.cli.models import Document
1516
from cycode.cli.utils.git_proxy import git_proxy
@@ -138,6 +139,7 @@ def restore_handlers(context: click.Context, is_git_diff: bool) -> List[BaseRest
138139
RestoreGoDependencies(context, is_git_diff, BUILD_DEP_TREE_TIMEOUT),
139140
RestoreNugetDependencies(context, is_git_diff, BUILD_DEP_TREE_TIMEOUT),
140141
RestoreNpmDependencies(context, is_git_diff, BUILD_DEP_TREE_TIMEOUT),
142+
RestoreRubyDependencies(context, is_git_diff, BUILD_DEP_TREE_TIMEOUT),
141143
]
142144

143145

0 commit comments

Comments
 (0)