-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
14 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
from kubernetes.client import Configuration | ||
from kubernetes.dynamic import DynamicClient, exceptions, resource | ||
from ruamel.yaml import YAML | ||
from packageurl import PackageURL | ||
|
||
from artcommonlib.exectools import limit_concurrency | ||
from doozerlib import constants | ||
|
@@ -261,11 +262,18 @@ async def _get_for_arch(arch): | |
sbom_contents = json.loads(stdout) | ||
source_rpms = set() | ||
for x in sbom_contents["components"]: | ||
if x["bom-ref"].startswith("pkg:rpm"): | ||
for i in x["properties"]: | ||
if i["name"] == "syft:metadata:sourceRpm": | ||
source_rpms.add(i["value"].rstrip(".src.rpm")) | ||
break | ||
# sbom uses purl or package-url convention https://github.com/package-url/purl-spec | ||
# example: pkg:rpm/rhel/[email protected]?arch=x86_64&upstream=coreutils-8.32-35.el9.src.rpm&distro=rhel-9.4 | ||
# https://github.com/package-url/packageurl-python does not support purl schemes other than "pkg" | ||
# so filter them out | ||
if x["purl"].startswith("pkg:"): | ||
purl = PackageURL.from_string(x["purl"]) | ||
# right now, we only care about rpms | ||
if purl.type == "rpm": | ||
# get the source rpm | ||
source_rpm = purl.qualifiers.get("upstream", None) | ||
if source_rpm: | ||
source_rpms.add(source_rpm.rstrip(".src.rpm")) | ||
return source_rpms | ||
|
||
results = await asyncio.gather(*(_get_for_arch(arch) for arch in arches)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters