hosted: pin python3 in the image for the containment suite
The containment suite, certification's positive control, launches /usr/bin/python3 in its sandboxes, and the MicroVM base has none. Over the base and the 23 pinned RPMs, microdnf's closure of python3 (no weak dependencies) is five packages from the same AL2023 release (2023.12.20261102, repoguid 0d08b707...): python3 and python3-libs 3.9.25-1.amzn2023.0.11, gdbm-libs 1.19-2.amzn2023.0.2, python3-pip-wheel 21.3.1-2.amzn2023.0.22 and python3-setuptools-wheel 59.6.0-2.amzn2023.0.6. Each SHA-256 is the repository's pkgId (primary database checked against repomd.xml); each passes rpm -K against Amazon's key D832C631. All 28 install offline on the base. The scan found one false positive in two copies, distutils' msvccompiler.py assigning win32api.RegEnumKey; both are allowed by member, rule and digest. TestPinsCarryContainmentSuiteTools keeps python3 pinned.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 files changed,
+56
−0
infra/hosted/image/manifest.json+14 −0infra/hosted/image/pins.json+25 −0internal/hostedimage/assemble_test.go+17 −0
diff --git a/infra/hosted/image/manifest.json b/infra/hosted/image/manifest.json| index 6bfe445d..66ca281c 100644 |
| --- a/infra/hosted/image/manifest.json |
| +++ b/infra/hosted/image/manifest.json |
| @@ -215,6 +215,20 @@ |
| "Rule": "forbidden-path", |
| "SHA256": "8479c767aeb256e4b2465d23f96dd98998d4210f12c0c9b41bd0a6f1f2e6f17c", |
| "Reason": "OpenSSH's document describing its private key format (a .key name): prose, no key" |
| + }, |
| + { |
| + "Input": "pkgs/python3-libs-3.9.25-1.amzn2023.0.11.x86_64.rpm", |
| + "Member": "usr/lib64/python3.9/distutils/msvccompiler.py", |
| + "Rule": "generic-api-key", |
| + "SHA256": "658b27520202e2d653d969096d39135325520807369c533d0d5288b887cf054d", |
| + "Reason": "distutils' Windows compiler module assigning win32api.RegEnumKey: an identifier, no key" |
| + }, |
| + { |
| + "Input": "pkgs/python3-setuptools-wheel-59.6.0-2.amzn2023.0.6.noarch.rpm", |
| + "Member": "usr/share/python3-wheels/setuptools-59.6.0-py3-none-any.whl!/setuptools/_distutils/msvccompiler.py", |
| + "Rule": "generic-api-key", |
| + "SHA256": "aabb802de191abcf828ed8c4dad2d0f16dba42772171879d5b31667bc0316784", |
| + "Reason": "setuptools' copy of distutils' Windows compiler module assigning win32api.RegEnumKey: an identifier, no key" |
| } |
| ] |
| } |
diff --git a/infra/hosted/image/pins.json b/infra/hosted/image/pins.json| index e130dd6f..beea0736 100644 |
| --- a/infra/hosted/image/pins.json |
| +++ b/infra/hosted/image/pins.json |
| @@ -22,6 +22,11 @@ |
| "URL": "https://cdn.amazonlinux.com/al2023/blobstore/16f4c8e1fe525d9d3e8c8ef5387448d2587d5a34ad062efb6513a6250eda3778/expat-2.8.3-1.amzn2023.0.1.x86_64.rpm", |
| "SHA256": "16f4c8e1fe525d9d3e8c8ef5387448d2587d5a34ad062efb6513a6250eda3778" |
| }, |
| + { |
| + "Name": "gdbm-libs-1.19-2.amzn2023.0.2.x86_64.rpm", |
| + "URL": "https://cdn.amazonlinux.com/al2023/blobstore/b1c503fbf4757f1879b7bf8b950454b3f6a2d0d4edb3bcdc0607ca865b9f172e/gdbm-libs-1.19-2.amzn2023.0.2.x86_64.rpm", |
| + "SHA256": "b1c503fbf4757f1879b7bf8b950454b3f6a2d0d4edb3bcdc0607ca865b9f172e" |
| + }, |
| { |
| "Name": "git-core-2.50.1-1.amzn2023.0.1.x86_64.rpm", |
| "URL": "https://cdn.amazonlinux.com/al2023/blobstore/1a266c41e66b0dca131ea2cb616588d75b580d2bfbb8b67a6504280ee90d640c/git-core-2.50.1-1.amzn2023.0.1.x86_64.rpm", |
| @@ -102,6 +107,26 @@ |
| "URL": "https://cdn.amazonlinux.com/al2023/blobstore/3664efb5954a1c8c01c3600da2418cd5c8fa1f2323bc1200aa3a13edcee64540/pam-1.5.1-8.amzn2023.0.8.x86_64.rpm", |
| "SHA256": "3664efb5954a1c8c01c3600da2418cd5c8fa1f2323bc1200aa3a13edcee64540" |
| }, |
| + { |
| + "Name": "python3-3.9.25-1.amzn2023.0.11.x86_64.rpm", |
| + "URL": "https://cdn.amazonlinux.com/al2023/blobstore/7353b7dac39edaeac141c30b94378db3418393fe6cf6ea6ce89cc266b4cd0709/python3-3.9.25-1.amzn2023.0.11.x86_64.rpm", |
| + "SHA256": "7353b7dac39edaeac141c30b94378db3418393fe6cf6ea6ce89cc266b4cd0709" |
| + }, |
| + { |
| + "Name": "python3-libs-3.9.25-1.amzn2023.0.11.x86_64.rpm", |
| + "URL": "https://cdn.amazonlinux.com/al2023/blobstore/d70f8b0359a2cb539e28f3d435524c7ce8ca04f209124ca4a765a49503cc3f2d/python3-libs-3.9.25-1.amzn2023.0.11.x86_64.rpm", |
| + "SHA256": "d70f8b0359a2cb539e28f3d435524c7ce8ca04f209124ca4a765a49503cc3f2d" |
| + }, |
| + { |
| + "Name": "python3-pip-wheel-21.3.1-2.amzn2023.0.22.noarch.rpm", |
| + "URL": "https://cdn.amazonlinux.com/al2023/blobstore/34f88fa066ed3efa8ab75fad213a9d0ef4db6096d569c8d2400f5eb39574ac0f/python3-pip-wheel-21.3.1-2.amzn2023.0.22.noarch.rpm", |
| + "SHA256": "34f88fa066ed3efa8ab75fad213a9d0ef4db6096d569c8d2400f5eb39574ac0f" |
| + }, |
| + { |
| + "Name": "python3-setuptools-wheel-59.6.0-2.amzn2023.0.6.noarch.rpm", |
| + "URL": "https://cdn.amazonlinux.com/al2023/blobstore/26d5e04214d99805d7bb320c5ac8bb4d5ff57ff1147e1a38e112f9ad00ba0a44/python3-setuptools-wheel-59.6.0-2.amzn2023.0.6.noarch.rpm", |
| + "SHA256": "26d5e04214d99805d7bb320c5ac8bb4d5ff57ff1147e1a38e112f9ad00ba0a44" |
| + }, |
| { |
| "Name": "shadow-utils-4.9-12.amzn2023.0.4.x86_64.rpm", |
| "URL": "https://cdn.amazonlinux.com/al2023/blobstore/bf29c6750bc92a3ca2eb0857ae91c3d28b935f744ee808d1b4517f74f8397ae1/shadow-utils-4.9-12.amzn2023.0.4.x86_64.rpm", |
diff --git a/internal/hostedimage/assemble_test.go b/internal/hostedimage/assemble_test.go| index 881887c5..b0741d21 100644 |
| --- a/internal/hostedimage/assemble_test.go |
| +++ b/internal/hostedimage/assemble_test.go |
| @@ -9,6 +9,7 @@ import ( |
| "net/http/httptest" |
| "os" |
| "path/filepath" |
| + "slices" |
| "strings" |
| "sync/atomic" |
| "testing" |
| @@ -328,3 +329,19 @@ func TestAssembleRefusesBadPackagesBeforeFetching(t *testing.T) { |
| } |
| } |
| } |
| + |
| +// TestPinsCarryContainmentSuiteTools: the image's containment suite |
| +// (certification's positive control) launches /usr/bin/python3 inside its |
| +// sandboxes and the MicroVM base has none, so the pinned packages carry |
| +// python3 and its libraries. |
| +func TestPinsCarryContainmentSuiteTools(t *testing.T) { |
| + p, err := LoadPins(filepath.Join(repoRoot, "infra", "hosted", "image", "pins.json")) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, want := range []string{"python3-3.", "python3-libs-3."} { |
| + if !slices.ContainsFunc(p.Packages, func(k PackageSource) bool { return strings.HasPrefix(k.Name, want) }) { |
| + t.Errorf("pins.json carries no %s* package; the containment suite needs /usr/bin/python3", want) |
| + } |
| + } |
| +} |