From 000f4c8c1fadd9687b03417fd848f6cd8526a31a Mon Sep 17 00:00:00 2001 From: Barrett Karstens Date: Wed, 11 Oct 2023 18:53:32 -0700 Subject: [PATCH] Limiting capsule install to supported versions (#431) The syntax 'DIRID 13' was introduced in OS version 10.0.16299, but DDInstall sections utilizing the syntax will install on earlier OS versions. Those DDInstall sections should be restricted to only install on 10.0.16299 or higher using a TargetOSVersion decoration. --- edk2toollib/windows/capsule/inf_generator.py | 4 ++-- edk2toollib/windows/capsule/inf_generator2.py | 4 ++-- tests.unit/test_inf_generator.py | 4 ++-- tests.unit/test_inf_generator2.py | 18 +++++++++--------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/edk2toollib/windows/capsule/inf_generator.py b/edk2toollib/windows/capsule/inf_generator.py index 3b891995..c22d3428 100644 --- a/edk2toollib/windows/capsule/inf_generator.py +++ b/edk2toollib/windows/capsule/inf_generator.py @@ -51,9 +51,9 @@ class InfGenerator(object): CatalogFile={Name}.cat [Manufacturer] -%MfgName% = Firmware,NT{Arch} +%MfgName% = Firmware,NT{Arch}.10.0...16299 -[Firmware.NT{Arch}] +[Firmware.NT{Arch}.10.0...16299] %FirmwareDesc% = Firmware_Install,UEFI\RES_{{{EsrtGuid}}} [Firmware_Install.NT] diff --git a/edk2toollib/windows/capsule/inf_generator2.py b/edk2toollib/windows/capsule/inf_generator2.py index 3ef2ffe0..766950fe 100644 --- a/edk2toollib/windows/capsule/inf_generator2.py +++ b/edk2toollib/windows/capsule/inf_generator2.py @@ -121,7 +121,7 @@ def __str__(self) -> str: CatalogFile={self.Name}.cat [Manufacturer] - %MfgName% = Firmware,NT{self.Arch} + %MfgName% = Firmware,NT{self.Arch}.10.0...16299 """) @@ -284,7 +284,7 @@ def __str__(self) -> str: This includes any InfFirmware objects in it. """ - firmwareStr = f"[Firmware.NT{self.Arch}]\n" + firmwareStr = f"[Firmware.NT{self.Arch}.10.0...16299]\n" for InfFirmware in self.Sections.values(): firmwareStr += f"%{InfFirmware.Tag}Desc% = {InfFirmware.Tag}_Install,UEFI\\RES_{{{InfFirmware.EsrtGuid}}}\n" firmwareStr += "\n" diff --git a/tests.unit/test_inf_generator.py b/tests.unit/test_inf_generator.py index fd8ae75b..b1df4570 100644 --- a/tests.unit/test_inf_generator.py +++ b/tests.unit/test_inf_generator.py @@ -151,9 +151,9 @@ def test_invalid_guid_format(self): CatalogFile=TestName.cat [Manufacturer] -%MfgName% = Firmware,NTamd64 +%MfgName% = Firmware,NTamd64.10.0...16299 -[Firmware.NTamd64] +[Firmware.NTamd64.10.0...16299] %FirmwareDesc% = Firmware_Install,UEFI\\RES_{3cad7a0c-d35b-4b75-96b1-03a9fb07b7fc} [Firmware_Install.NT] diff --git a/tests.unit/test_inf_generator2.py b/tests.unit/test_inf_generator2.py index 7da5a46b..6afe8319 100644 --- a/tests.unit/test_inf_generator2.py +++ b/tests.unit/test_inf_generator2.py @@ -33,7 +33,7 @@ def test_header(self): CatalogFile=InfTest.cat [Manufacturer] - %MfgName% = Firmware,NTamd64 + %MfgName% = Firmware,NTamd64.10.0...16299 """) self.assertEqual(ExpectedStr, str(Header)) @@ -258,7 +258,7 @@ def test_one_section(self): Sections.AddSection(Firmware) ExpectedStr = textwrap.dedent("""\ - [Firmware.NTamd64] + [Firmware.NTamd64.10.0...16299] %tagDesc% = tag_Install,UEFI\\RES_{34e094e9-4079-44cd-9450-3f2cb7824c97} [tag_Install.NT] @@ -312,7 +312,7 @@ def test_two_sections(self): Sections.AddSection(Firmware2) ExpectedStr = textwrap.dedent("""\ - [Firmware.NTamd64] + [Firmware.NTamd64.10.0...16299] %tag1Desc% = tag1_Install,UEFI\\RES_{34e094e9-4079-44cd-9450-3f2cb7824c97} %tag2Desc% = tag2_Install,UEFI\\RES_{bec9124f-9934-4ec0-a6ed-b8bc1c91d276} @@ -480,9 +480,9 @@ def test_inf_file(self): CatalogFile=CapsuleName.cat [Manufacturer] - %MfgName% = Firmware,NTamd64 + %MfgName% = Firmware,NTamd64.10.0...16299 - [Firmware.NTamd64] + [Firmware.NTamd64.10.0...16299] %tag1Desc% = tag1_Install,UEFI\\RES_{34e094e9-4079-44cd-9450-3f2cb7824c97} %tag2Desc% = tag2_Install,UEFI\\RES_{bec9124f-9934-4ec0-a6ed-b8bc1c91d276} @@ -574,9 +574,9 @@ def test_inf_file_rollback(self): CatalogFile=CapsuleName.cat [Manufacturer] - %MfgName% = Firmware,NTamd64 + %MfgName% = Firmware,NTamd64.10.0...16299 - [Firmware.NTamd64] + [Firmware.NTamd64.10.0...16299] %tag1Desc% = tag1_Install,UEFI\\RES_{34e094e9-4079-44cd-9450-3f2cb7824c97} %tag2Desc% = tag2_Install,UEFI\\RES_{bec9124f-9934-4ec0-a6ed-b8bc1c91d276} @@ -678,9 +678,9 @@ def test_inf_file_rollback_integrity(self): CatalogFile=CapsuleName.cat [Manufacturer] - %MfgName% = Firmware,NTamd64 + %MfgName% = Firmware,NTamd64.10.0...16299 - [Firmware.NTamd64] + [Firmware.NTamd64.10.0...16299] %tag1Desc% = tag1_Install,UEFI\\RES_{34e094e9-4079-44cd-9450-3f2cb7824c97} %tag2Desc% = tag2_Install,UEFI\\RES_{bec9124f-9934-4ec0-a6ed-b8bc1c91d276}