Skip to content

Commit 0d0f495

Browse files
authored
Merge pull request #192 from sw360/190-determine-rust-dependencies
Determine rust dependencies
2 parents ff3244f + 85d2014 commit 0d0f495

File tree

16 files changed

+3124
-12
lines changed

16 files changed

+3124
-12
lines changed

ChangeLog.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55

66
# CaPyCli - Clearing Automation Python Command Line Tool for SW360
77

8-
## 2.10.0.dev2
8+
## 2.10.0
99

1010
* Have `bom bompackage` as a separate command and have the advanced folder structure
1111
based on SHA1 hashes.
12+
* CaPyCLI now supports SBOM generation for Rust projects with the `getdependencies rust`
13+
command.
1214

1315
## 2.10.0.dev1
1416

capycli/dependencies/handle_dependencies.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -------------------------------------------------------------------------------
2-
# Copyright (c) 2019-23 Siemens
2+
# Copyright (c) 2019-2025 Siemens
33
# All Rights Reserved.
44
55
#
@@ -14,6 +14,7 @@
1414
import capycli.dependencies.maven_pom
1515
import capycli.dependencies.nuget
1616
import capycli.dependencies.python
17+
import capycli.dependencies.rust
1718
from capycli.common.print import print_red
1819
from capycli.main.result_codes import ResultCode
1920

@@ -34,6 +35,7 @@ def run_dependency_command(args: Any) -> None:
3435
print(" Javascript determine dependencies for a JavaScript project")
3536
print(" MavenPom determine dependencies for a Java/Maven project using the pom.xml file")
3637
print(" MavenList determine dependencies for a Java/Maven project using a Maven command")
38+
print(" Rust determine dependencies for a Rust project")
3739
return
3840

3941
subcommand = args.command[1].lower()
@@ -67,5 +69,11 @@ def run_dependency_command(args: Any) -> None:
6769
app5.run(args)
6870
return
6971

72+
if subcommand == "rust":
73+
"""Determine Rust components/dependencies for a given project"""
74+
app6 = capycli.dependencies.rust.GetRustDependencies()
75+
app6.run(args)
76+
return
77+
7078
print_red("Unknown sub-command: " + subcommand)
7179
sys.exit(ResultCode.RESULT_COMMAND_ERROR)

capycli/dependencies/python.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,8 @@ def sbom_from_uv_lock_file(self, filename: str, search_meta_data: bool, package_
779779

780780
return sbom
781781

782-
def check_meta_data(self, sbom: Bom) -> bool:
782+
@staticmethod
783+
def check_meta_data(sbom: Bom, verbose: bool) -> bool:
783784
"""
784785
Check whether all required meta-data is available.
785786
@@ -790,37 +791,37 @@ def check_meta_data(self, sbom: Bom) -> bool:
790791
bool: True if all required meta-data is available; otherwise False.
791792
"""
792793

793-
if self.verbose:
794+
if verbose:
794795
print_text("\nChecking meta-data:")
795796

796797
result = True
797798
cxcomp: Component
798799
for cxcomp in sbom.components:
799-
if self.verbose:
800+
if verbose:
800801
print_text(f" {cxcomp.name}, {cxcomp.version}")
801802

802803
if not cxcomp.purl:
803804
result = False
804-
if self.verbose:
805+
if verbose:
805806
print_yellow(" package-url missing")
806807

807808
homepage = CycloneDxSupport.get_ext_ref_website(cxcomp)
808809
if not homepage:
809810
result = False
810-
if self.verbose:
811+
if verbose:
811812
print_yellow(" Homepage missing")
812813

813814
if not cxcomp.licenses:
814-
if self.verbose:
815+
if verbose:
815816
LOG.debug(" License missing")
816817
elif len(cxcomp.licenses) == 0:
817-
if self.verbose:
818+
if verbose:
818819
LOG.debug(" License missing")
819820

820821
src_url = CycloneDxSupport.get_ext_ref_source_url(cxcomp)
821822
if not src_url:
822823
result = False
823-
if self.verbose:
824+
if verbose:
824825
print_yellow(" Source code URL missing")
825826

826827
return result
@@ -884,7 +885,7 @@ def run(self, args: Any) -> None:
884885
print_text("Formatting package list...")
885886
sbom = self.convert_package_list(package_list, args.search_meta_data, args.package_source)
886887

887-
self.check_meta_data(sbom)
888+
GetPythonDependencies.check_meta_data(sbom, self.verbose)
888889

889890
if self.verbose:
890891
print()

0 commit comments

Comments
 (0)