diff --git a/cachi2/core/package_managers/bundler/parser.py b/cachi2/core/package_managers/bundler/parser.py index fcea98b35..500e7e6f7 100644 --- a/cachi2/core/package_managers/bundler/parser.py +++ b/cachi2/core/package_managers/bundler/parser.py @@ -90,6 +90,13 @@ class GemPlatformSpecificDependency(GemDependency): platform: str + @property + def purl(self) -> str: + """Get PURL for this dependency.""" + qualifiers = {"platform": self.platform} + purl = PackageURL(type="gem", name=self.name, version=self.version, qualifiers=qualifiers) + return purl.to_string() + @property def remote_location(self) -> str: """Return remote location to download this gem from.""" diff --git a/tests/integration/test_data/bundler_everything_present/bom.json b/tests/integration/test_data/bundler_everything_present/bom.json index b89452a34..d15652fa9 100644 --- a/tests/integration/test_data/bundler_everything_present/bom.json +++ b/tests/integration/test_data/bundler_everything_present/bom.json @@ -397,7 +397,87 @@ "value": "cachi2" } ], - "purl": "pkg:gem/nokogiri@1.16.7", + "purl": "pkg:gem/nokogiri@1.16.7?platform=aarch64-linux", + "type": "library", + "version": "1.16.7" + }, + { + "name": "nokogiri", + "properties": [ + { + "name": "cachi2:bundler:package:binary", + "value": "true" + }, + { + "name": "cachi2:found_by", + "value": "cachi2" + } + ], + "purl": "pkg:gem/nokogiri@1.16.7?platform=arm-linux", + "type": "library", + "version": "1.16.7" + }, + { + "name": "nokogiri", + "properties": [ + { + "name": "cachi2:bundler:package:binary", + "value": "true" + }, + { + "name": "cachi2:found_by", + "value": "cachi2" + } + ], + "purl": "pkg:gem/nokogiri@1.16.7?platform=arm64-darwin", + "type": "library", + "version": "1.16.7" + }, + { + "name": "nokogiri", + "properties": [ + { + "name": "cachi2:bundler:package:binary", + "value": "true" + }, + { + "name": "cachi2:found_by", + "value": "cachi2" + } + ], + "purl": "pkg:gem/nokogiri@1.16.7?platform=x86-linux", + "type": "library", + "version": "1.16.7" + }, + { + "name": "nokogiri", + "properties": [ + { + "name": "cachi2:bundler:package:binary", + "value": "true" + }, + { + "name": "cachi2:found_by", + "value": "cachi2" + } + ], + "purl": "pkg:gem/nokogiri@1.16.7?platform=x86_64-darwin", + "type": "library", + "version": "1.16.7" + }, + { + "name": "nokogiri", + "properties": [ + { + "name": "cachi2:bundler:package:binary", + "value": "true" + }, + { + "name": "cachi2:found_by", + "value": "cachi2" + } + ], + "purl": "pkg:gem/nokogiri@1.16.7?platform=x86_64-linux", "type": "library", "version": "1.16.7" }, diff --git a/tests/integration/test_data/bundler_everything_present_except_gemspec/bom.json b/tests/integration/test_data/bundler_everything_present_except_gemspec/bom.json index 84d2dd914..a22209305 100644 --- a/tests/integration/test_data/bundler_everything_present_except_gemspec/bom.json +++ b/tests/integration/test_data/bundler_everything_present_except_gemspec/bom.json @@ -408,7 +408,87 @@ "value": "cachi2" } ], - "purl": "pkg:gem/nokogiri@1.16.7", + "purl": "pkg:gem/nokogiri@1.16.7?platform=aarch64-linux", + "type": "library", + "version": "1.16.7" + }, + { + "name": "nokogiri", + "properties": [ + { + "name": "cachi2:bundler:package:binary", + "value": "true" + }, + { + "name": "cachi2:found_by", + "value": "cachi2" + } + ], + "purl": "pkg:gem/nokogiri@1.16.7?platform=arm-linux", + "type": "library", + "version": "1.16.7" + }, + { + "name": "nokogiri", + "properties": [ + { + "name": "cachi2:bundler:package:binary", + "value": "true" + }, + { + "name": "cachi2:found_by", + "value": "cachi2" + } + ], + "purl": "pkg:gem/nokogiri@1.16.7?platform=arm64-darwin", + "type": "library", + "version": "1.16.7" + }, + { + "name": "nokogiri", + "properties": [ + { + "name": "cachi2:bundler:package:binary", + "value": "true" + }, + { + "name": "cachi2:found_by", + "value": "cachi2" + } + ], + "purl": "pkg:gem/nokogiri@1.16.7?platform=x86-linux", + "type": "library", + "version": "1.16.7" + }, + { + "name": "nokogiri", + "properties": [ + { + "name": "cachi2:bundler:package:binary", + "value": "true" + }, + { + "name": "cachi2:found_by", + "value": "cachi2" + } + ], + "purl": "pkg:gem/nokogiri@1.16.7?platform=x86_64-darwin", + "type": "library", + "version": "1.16.7" + }, + { + "name": "nokogiri", + "properties": [ + { + "name": "cachi2:bundler:package:binary", + "value": "true" + }, + { + "name": "cachi2:found_by", + "value": "cachi2" + } + ], + "purl": "pkg:gem/nokogiri@1.16.7?platform=x86_64-linux", "type": "library", "version": "1.16.7" }, diff --git a/tests/unit/package_managers/bundler/test_parser.py b/tests/unit/package_managers/bundler/test_parser.py index ae3e63dde..ee6a36142 100644 --- a/tests/unit/package_managers/bundler/test_parser.py +++ b/tests/unit/package_managers/bundler/test_parser.py @@ -318,6 +318,15 @@ def test_purls(rooted_tmp_path_repo: RootedPath) -> None: ), "pkg:gem/my-gem-dep@0.1.0", ), + ( + GemPlatformSpecificDependency( + name="my-platform-gem-dep", + version="0.1.0", + source="https://rubygems.org", + platform="x86_64_linux", + ), + "pkg:gem/my-platform-gem-dep@0.1.0?platform=x86_64_linux", + ), ( GitDependency( name="my-git-dep",