Skip to content

Commit 5e9883d

Browse files
committed
CM-55551 CLI SCA Scan Fails to Detect Indirect Dependencies Due to PNPM Lock File Handling
1 parent 6c8ebdf commit 5e9883d

File tree

8 files changed

+21
-19
lines changed

8 files changed

+21
-19
lines changed

cycode/cli/files_collector/sca/base_restore_dependencies.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ def build_dep_tree_path(path: str, generated_file_name: str) -> str:
1414

1515

1616
def execute_commands(
17-
commands: list[list[str]],
18-
timeout: int,
19-
output_file_path: Optional[str] = None,
20-
working_directory: Optional[str] = None,
17+
commands: list[list[str]],
18+
timeout: int,
19+
output_file_path: Optional[str] = None,
20+
working_directory: Optional[str] = None,
2121
) -> Optional[str]:
2222
try:
2323
outputs = []
@@ -40,7 +40,7 @@ def execute_commands(
4040

4141
class BaseRestoreDependencies(ABC):
4242
def __init__(
43-
self, ctx: typer.Context, is_git_diff: bool, command_timeout: int, create_output_file_manually: bool = False
43+
self, ctx: typer.Context, is_git_diff: bool, command_timeout: int, create_output_file_manually: bool = False
4444
) -> None:
4545
self.ctx = ctx
4646
self.is_git_diff = is_git_diff
@@ -57,9 +57,11 @@ def get_manifest_file_path(self, document: Document) -> str:
5757

5858
def try_restore_dependencies(self, document: Document) -> Optional[Document]:
5959
manifest_file_path = self.get_manifest_file_path(document)
60-
restore_file_paths = [build_dep_tree_path(document.absolute_path, restore_file_path_item) for restore_file_path_item in self.get_lock_file_names()]
60+
restore_file_paths = [build_dep_tree_path(document.absolute_path, restore_file_path_item) for
61+
restore_file_path_item in self.get_lock_file_names()]
6162
restore_file_path = self.get_any_restore_file_already_exist(restore_file_paths)
62-
relative_restore_file_path = build_dep_tree_path(document.path, self.get_restored_lock_file_name(restore_file_path))
63+
relative_restore_file_path = build_dep_tree_path(document.path,
64+
self.get_restored_lock_file_name(restore_file_path))
6365

6466
if self.verify_lockfile_missing(restore_file_path):
6567
output = execute_commands(
@@ -76,16 +78,16 @@ def try_restore_dependencies(self, document: Document) -> Optional[Document]:
7678

7779
def get_working_directory(self, document: Document) -> Optional[str]:
7880
return os.path.dirname(document.absolute_path)
79-
81+
8082
def get_restored_lock_file_name(self, restore_file_path: str) -> str:
8183
return self.get_lock_file_name()
82-
84+
8385
@staticmethod
8486
def get_any_restore_file_already_exist(restore_file_paths: list[str]) -> Optional[str]:
8587
for restore_file_path in restore_file_paths:
8688
if os.path.isfile(restore_file_path):
8789
return restore_file_path
88-
90+
8991
return None
9092

9193
@staticmethod
@@ -103,7 +105,7 @@ def get_commands(self, manifest_file_path: str) -> list[list[str]]:
103105
@abstractmethod
104106
def get_lock_file_name(self) -> str:
105107
pass
106-
108+
107109
@abstractmethod
108110
def get_lock_file_names(self) -> list[str]:
109111
pass

cycode/cli/files_collector/sca/go/restore_go_dependencies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ def get_commands(self, manifest_file_path: str) -> list[list[str]]:
4343

4444
def get_lock_file_name(self) -> str:
4545
return GO_RESTORE_FILE_NAME
46-
46+
4747
def get_lock_file_names(self) -> str:
4848
return [self.get_lock_file_name()]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def get_commands(self, manifest_file_path: str) -> list[list[str]]:
4040

4141
def get_lock_file_name(self) -> str:
4242
return BUILD_GRADLE_DEP_TREE_FILE_NAME
43-
43+
4444
def get_lock_file_names(self) -> str:
4545
return [self.get_lock_file_name()]
4646

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def get_commands(self, manifest_file_path: str) -> list[list[str]]:
3333

3434
def get_lock_file_name(self) -> str:
3535
return join_paths('target', MAVEN_CYCLONE_DEP_TREE_FILE_NAME)
36-
36+
3737
def get_lock_file_names(self) -> str:
3838
return [self.get_lock_file_name()]
3939

cycode/cli/files_collector/sca/npm/restore_npm_dependencies.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ def get_commands(self, manifest_file_path: str) -> list[list[str]]:
3535
'--no-audit',
3636
]
3737
]
38-
38+
3939
def get_restored_lock_file_name(self, restore_file_path: str) -> str:
4040
return NPM_LOCK_FILE_NAME if restore_file_path is None else os.path.basename(restore_file_path)
4141

4242
def get_lock_file_name(self) -> str:
4343
return NPM_LOCK_FILE_NAME
44-
44+
4545
def get_lock_file_names(self) -> str:
4646
return NPM_LOCK_FILE_NAMES
4747

cycode/cli/files_collector/sca/nuget/restore_nuget_dependencies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ def get_commands(self, manifest_file_path: str) -> list[list[str]]:
1919

2020
def get_lock_file_name(self) -> str:
2121
return NUGET_LOCK_FILE_NAME
22-
22+
2323
def get_lock_file_names(self) -> str:
2424
return [self.get_lock_file_name()]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ def get_commands(self, manifest_file_path: str) -> list[list[str]]:
1414

1515
def get_lock_file_name(self) -> str:
1616
return RUBY_LOCK_FILE_NAME
17-
17+
1818
def get_lock_file_names(self) -> str:
1919
return [self.get_lock_file_name()]

cycode/cli/files_collector/sca/sbt/restore_sbt_dependencies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ def get_commands(self, manifest_file_path: str) -> list[list[str]]:
1414

1515
def get_lock_file_name(self) -> str:
1616
return SBT_LOCK_FILE_NAME
17-
17+
1818
def get_lock_file_names(self) -> str:
1919
return [self.get_lock_file_name()]

0 commit comments

Comments
 (0)