From: "'Clara Kowalsky' via isar-users" <isar-users@googlegroups.com>
To: isar-users@googlegroups.com
Cc: jan.kiszka@siemens.com, Clara Kowalsky <clara.kowalsky@siemens.com>
Subject: [PATCH 2/2] container_fetcher: Verify that tag and digest match
Date: Wed, 25 Jun 2025 15:54:42 +0200 [thread overview]
Message-ID: <20250625135442.1420977-2-clara.kowalsky@siemens.com> (raw)
In-Reply-To: <20250625135442.1420977-1-clara.kowalsky@siemens.com>
If a tag and digest are specified for a container image in the SRC_URI,
the tag is ignored until now and the container image with the matching
digest is fetched.
With this change, the container image is fetched based on the specified
tag and it is checked whether the digest matches. If not, an error is
thrown.
Signed-off-by: Clara Kowalsky <clara.kowalsky@siemens.com>
---
meta/lib/container_fetcher.py | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/meta/lib/container_fetcher.py b/meta/lib/container_fetcher.py
index 16467abb..75366988 100644
--- a/meta/lib/container_fetcher.py
+++ b/meta/lib/container_fetcher.py
@@ -11,6 +11,7 @@ from bb.fetch2 import FetchMethod
from bb.fetch2 import logger
from bb.fetch2 import MissingChecksumEvent
from bb.fetch2 import NoChecksumError
+from bb.fetch2 import ChecksumError
from bb.fetch2 import runfetchcmd
class Container(FetchMethod):
@@ -47,6 +48,22 @@ class Container(FetchMethod):
def download(self, ud, d):
tarball = ud.localfile[:-len('.zst')]
with tempfile.TemporaryDirectory(dir=d.getVar('DL_DIR')) as tmpdir:
+ # If both tag and digest are provided, verify they match
+ if ud.digest and ud.tag != "latest":
+ inspect_output = runfetchcmd(f"skopeo inspect docker://{ud.container_name}:{ud.tag}", d, True)
+ actual_digest = json.loads(inspect_output)["Digest"]
+ if actual_digest != ud.digest:
+ messages = []
+ messages.append(f"Checksum mismatch for {ud.container_name}:{ud.tag}")
+ messages.append("If this change is expected (e.g. you have upgraded " \
+ "to a new version without updating the checksums) " \
+ "then you can use these lines within the recipe:")
+ messages.append(f'SRC_URI = "docker://{ud.container_name};digest={actual_digest};tag={ud.tag}"')
+ messages.append("Otherwise you should retry the download and/or " \
+ "check with upstream to determine if the container image has " \
+ "become corrupted or otherwise unexpectedly modified.")
+ raise ChecksumError("\n".join(messages), ud.url, actual_digest)
+
# Take a two steps for downloading into a docker archive because
# not all source may have the required Docker schema 2 manifest.
runfetchcmd("skopeo copy --preserve-digests " + \
--
2.49.0
--
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/20250625135442.1420977-2-clara.kowalsky%40siemens.com.
next prev parent reply other threads:[~2025-06-25 13:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-25 13:54 [PATCH 1/2] container_fetcher: Fix missing checksum warning 'Clara Kowalsky' via isar-users
2025-06-25 13:54 ` 'Clara Kowalsky' via isar-users [this message]
2025-06-25 15:47 ` [PATCH 2/2] container_fetcher: Verify that tag and digest match 'Jan Kiszka' via isar-users
2025-06-25 19:58 ` 'Clara Kowalsky' via isar-users
2025-06-25 15:42 ` [PATCH 1/2] container_fetcher: Fix missing checksum warning 'Jan Kiszka' via isar-users
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250625135442.1420977-2-clara.kowalsky@siemens.com \
--to=isar-users@googlegroups.com \
--cc=clara.kowalsky@siemens.com \
--cc=jan.kiszka@siemens.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox