Skip to content

Commit 008441a

Browse files
committed
Handle the docker type for dependencies
Signed-off-by: tdruez <[email protected]>
1 parent bdddec1 commit 008441a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

scanpipe/pipes/ort.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,27 @@ def to_file(self, filepath):
117117
Path(filepath).write_text(self.to_yaml(), encoding="utf-8")
118118

119119

120+
def get_ort_project_type(project):
121+
"""
122+
Determine the ORT project type based on the project's input sources.
123+
124+
Currently, this function checks whether any of the project's
125+
input download URLs start with "docker://".
126+
If at least one Docker URL is found, it returns "docker".
127+
"""
128+
inputs_url = project.inputsources.values_list("download_url", flat=True)
129+
if any(url.startswith("docker://") for url in inputs_url):
130+
return "docker"
131+
132+
120133
def to_ort_package_list_yml(project):
121134
"""Convert a project object into a YAML string in the ORT package list format."""
135+
project_type = get_ort_project_type(project)
136+
122137
dependencies = []
123138
for package in project.discoveredpackages.all():
124139
dependency = Dependency(
125-
id=f"{package.type}::{package.name}:{package.version}",
140+
id=f"{project_type or package.type}::{package.name}:{package.version}",
126141
purl=package.purl,
127142
sourceArtifact=SourceArtifact(url=package.download_url),
128143
declaredLicenses=[package.get_declared_license_expression_spdx()],

0 commit comments

Comments
 (0)