Skip to content

Commit 17054ad

Browse files
nglevinluispadron
authored andcommitted
Add mandatory entitlements check for secure_features as required for Xcode 26+, and rename the mandatory feature to set the minimum required Apple Enhanced Security entitlements to be more significant to end users.
Re-scoped existing TODOs around Apple Enhanced Secuirty support to new issues for tracking. Cherry-pick: 8134b6a
1 parent 9d79f80 commit 17054ad

14 files changed

Lines changed: 140 additions & 96 deletions

apple/internal/entitlements_support.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ def _process_entitlements(
287287
# Retrieve the entitlements required by the requested secure features, if there are any.
288288
secure_features_entitlements = (
289289
secure_features_support.entitlements_from_secure_features(
290+
rule_label = rule_label,
290291
secure_features = secure_features,
291292
xcode_version = platform_prerequisites.xcode_version_config.xcode_version(),
292293
)

apple/internal/secure_features_support.bzl

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ visibility([
2626

2727
# The name of the secure feature that's required for opting into any set of enhanced security
2828
# features on Xcode 26.0 or later.
29-
#
30-
# TODO: b/449684779 - Use this for a mandatory check for the Xcode 26 opt-in feature, since that
31-
# should always be set if any entitlements are required.
32-
_REQUIRED_XCODE_26_OPT_IN = "apple.xcode_26_minimum_opt_in"
29+
_REQUIRED_XCODE_26_OPT_IN = "apple.enable_enhanced_security"
3330

3431
# A map of all of the secure features that requires crosstool support and the entitlements that they
3532
# enable. If a secure feature does not enable any entitlements, it should be mapped to an empty
@@ -157,6 +154,7 @@ Either remove the secure feature from the "secure_features" attribute to disable
157154

158155
def _entitlements_from_secure_features(
159156
*,
157+
rule_label,
160158
secure_features,
161159
xcode_version):
162160
if not secure_features:
@@ -169,11 +167,23 @@ def _entitlements_from_secure_features(
169167

170168
# Build a set of all of the entitlements that are required by the requested secure features.
171169
required_entitlements = dict()
170+
has_mandatory_xcode_26_opt_in = False
172171
for feature_name in secure_features:
172+
if feature_name == _REQUIRED_XCODE_26_OPT_IN:
173+
has_mandatory_xcode_26_opt_in = True
174+
continue
173175
required_entitlements |= _ENTITLEMENTS_FROM_SECURE_FEATURES[feature_name]
174176

175-
# TODO: b/449684779 - Add a mandatory check for the Xcode 26 opt-in feature, since that should
176-
# always be set if any entitlements are required.
177+
if not has_mandatory_xcode_26_opt_in:
178+
fail("""
179+
Apple enhanced security features were requested, but the build is missing the required feature \
180+
"{required_xcode_26_opt_in}" that is needed to enable required entitlements in Xcode 26.0 or later.
181+
182+
Please add it to the "secure_features" rule attribute at `{rule_label}`.
183+
""".format(
184+
required_xcode_26_opt_in = _REQUIRED_XCODE_26_OPT_IN,
185+
rule_label = str(rule_label),
186+
))
177187

178188
return required_entitlements
179189

@@ -182,7 +192,7 @@ def _environment_archs_from_secure_features(
182192
environment_archs,
183193
require_pointer_authentication_attribute,
184194
secure_features):
185-
# TODO: b/449684779 - Migrate users to secure_features behind an allowlist when it's ready for
195+
# TODO: b/466363339 - Migrate users to secure_features behind an allowlist when it's ready for
186196
# onboarding. Remove this "require_pointer_authentication_attribute" check once
187197
# pointer_authentication is onboarded.
188198
if not require_pointer_authentication_attribute:

test/starlark_tests/apple_dynamic_xcframework_import_tests.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ def apple_dynamic_xcframework_import_test_suite(name):
489489
name = "{}_secure_features_app_fails_importing_xcframework_with_no_expected_secure_features_test".format(name),
490490
target_under_test = "//test/starlark_tests/targets_under_test/ios:secure_features_app_with_imported_dynamic_xcframework_and_no_expected_secure_features",
491491
expected_error = """The precompiled artifact at `//test/starlark_tests/targets_under_test/ios:ios_imported_dynamic_xcframework_with_missing_pointer_authentication_secure_features` was expected to be compatible with the following secure features requested from the build, but they were not indicated as supported by the target's `expected_secure_features` attribute:
492-
- apple.xcode_26_minimum_opt_in
492+
- apple.enable_enhanced_security
493493
494494
Please contact the owner of this target to supply a precompiled artifact (likely a framework or XCFramework) that is built with the required Enhanced Security features enabled, and update the "expected_secure_features" attribute to match.""",
495495
tags = [name],

test/starlark_tests/apple_static_xcframework_import_tests.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def apple_static_xcframework_import_test_suite(name):
286286
name = "{}_secure_features_app_fails_importing_xcframework_with_no_expected_secure_features_test".format(name),
287287
target_under_test = "//test/starlark_tests/targets_under_test/ios:secure_features_app_with_imported_static_xcframework_and_no_expected_secure_features",
288288
expected_error = """The precompiled artifact at `//test/starlark_tests/targets_under_test/ios:ios_imported_static_xcframework_with_missing_pointer_authentication_secure_features` was expected to be compatible with the following secure features requested from the build, but they were not indicated as supported by the target's `expected_secure_features` attribute:
289-
- apple.xcode_26_minimum_opt_in
289+
- apple.enable_enhanced_security
290290
291291
Please contact the owner of this target to supply a precompiled artifact (likely a framework or XCFramework) that is built with the required Enhanced Security features enabled, and update the "expected_secure_features" attribute to match.""",
292292
tags = [name],

test/starlark_tests/apple_static_xcframework_tests.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ def apple_static_xcframework_test_suite(name):
393393
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform IOS"],
394394
tags = [
395395
name,
396-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
396+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
397397
] + common.skip_ci_tags,
398398
)
399399
archive_contents_test(
@@ -408,7 +408,7 @@ def apple_static_xcframework_test_suite(name):
408408
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform IOS"],
409409
tags = [
410410
name,
411-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
411+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
412412
] + common.skip_ci_tags,
413413
)
414414

test/starlark_tests/ios_application_tests.bzl

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
13801380
},
13811381
tags = [
13821382
name,
1383-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1383+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
13841384
] + common.skip_ci_tags,
13851385
)
13861386
apple_verification_test(
@@ -1393,7 +1393,22 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
13931393
},
13941394
tags = [
13951395
name,
1396-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1396+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
1397+
] + common.skip_ci_tags,
1398+
)
1399+
1400+
# Tests that the rules report a user-actionable error when enhanced security features are
1401+
# requested without the required Xcode 26 opt-in feature assigned to a target.
1402+
analysis_failure_message_test(
1403+
name = "{}_enhanced_security_features_missing_xcode_26_opt_in_fail_test".format(name),
1404+
target_under_test = "//test/starlark_tests/targets_under_test/ios:simple_enhanced_security_app_without_required_opt_in",
1405+
expected_error = """
1406+
Apple enhanced security features were requested, but the build is missing the required feature \
1407+
"apple.enable_enhanced_security" that is needed to enable required entitlements in Xcode 26.0 or later.
1408+
""",
1409+
tags = [
1410+
name,
1411+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
13971412
] + common.skip_ci_tags,
13981413
)
13991414

@@ -1410,7 +1425,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
14101425
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform IOS"],
14111426
tags = [
14121427
name,
1413-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1428+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
14141429
] + common.skip_ci_tags,
14151430
)
14161431
apple_verification_test(
@@ -1423,7 +1438,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
14231438
},
14241439
tags = [
14251440
name,
1426-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1441+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
14271442
] + common.skip_ci_tags,
14281443
)
14291444
apple_verification_test(
@@ -1436,7 +1451,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
14361451
},
14371452
tags = [
14381453
name,
1439-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1454+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
14401455
] + common.skip_ci_tags,
14411456
)
14421457

@@ -1453,7 +1468,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
14531468
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform IOS"],
14541469
tags = [
14551470
name,
1456-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1471+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
14571472
] + common.skip_ci_tags,
14581473
)
14591474

@@ -1471,7 +1486,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
14711486
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform IOS"],
14721487
tags = [
14731488
name,
1474-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1489+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
14751490
] + common.skip_ci_tags,
14761491
)
14771492
apple_verification_test(
@@ -1486,7 +1501,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
14861501
},
14871502
tags = [
14881503
name,
1489-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1504+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
14901505
] + common.skip_ci_tags,
14911506
)
14921507
apple_verification_test(
@@ -1501,7 +1516,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
15011516
},
15021517
tags = [
15031518
name,
1504-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1519+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
15051520
] + common.skip_ci_tags,
15061521
)
15071522

@@ -1518,7 +1533,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
15181533
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform IOS"],
15191534
tags = [
15201535
name,
1521-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1536+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
15221537
] + common.skip_ci_tags,
15231538
)
15241539
apple_verification_test(
@@ -1532,7 +1547,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
15321547
},
15331548
tags = [
15341549
name,
1535-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1550+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
15361551
] + common.skip_ci_tags,
15371552
)
15381553
apple_verification_test(
@@ -1546,7 +1561,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
15461561
},
15471562
tags = [
15481563
name,
1549-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1564+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
15501565
] + common.skip_ci_tags,
15511566
)
15521567

@@ -1563,7 +1578,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
15631578
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform IOS"],
15641579
tags = [
15651580
name,
1566-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1581+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
15671582
] + common.skip_ci_tags,
15681583
)
15691584

@@ -1580,7 +1595,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
15801595
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform IOS"],
15811596
tags = [
15821597
name,
1583-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1598+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
15841599
] + common.skip_ci_tags,
15851600
)
15861601
apple_verification_test(
@@ -1594,7 +1609,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
15941609
},
15951610
tags = [
15961611
name,
1597-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1612+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
15981613
] + common.skip_ci_tags,
15991614
)
16001615
apple_verification_test(
@@ -1608,7 +1623,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
16081623
},
16091624
tags = [
16101625
name,
1611-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1626+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
16121627
] + common.skip_ci_tags,
16131628
)
16141629

@@ -1625,7 +1640,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
16251640
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform IOS"],
16261641
tags = [
16271642
name,
1628-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1643+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
16291644
] + common.skip_ci_tags,
16301645
)
16311646

@@ -1643,7 +1658,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
16431658
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform IOS"],
16441659
tags = [
16451660
name,
1646-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1661+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
16471662
] + common.skip_ci_tags,
16481663
)
16491664
apple_verification_test(
@@ -1658,7 +1673,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
16581673
},
16591674
tags = [
16601675
name,
1661-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1676+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
16621677
] + common.skip_ci_tags,
16631678
)
16641679
apple_verification_test(
@@ -1673,7 +1688,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
16731688
},
16741689
tags = [
16751690
name,
1676-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1691+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
16771692
] + common.skip_ci_tags,
16781693
)
16791694

@@ -1690,7 +1705,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
16901705
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform IOS"],
16911706
tags = [
16921707
name,
1693-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1708+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
16941709
] + common.skip_ci_tags,
16951710
)
16961711
apple_verification_test(
@@ -1704,7 +1719,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
17041719
},
17051720
tags = [
17061721
name,
1707-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1722+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
17081723
] + common.skip_ci_tags,
17091724
)
17101725
apple_verification_test(
@@ -1718,7 +1733,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
17181733
},
17191734
tags = [
17201735
name,
1721-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1736+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
17221737
] + common.skip_ci_tags,
17231738
)
17241739

@@ -1736,7 +1751,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
17361751
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform WATCHOS"],
17371752
tags = [
17381753
name,
1739-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1754+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
17401755
] + common.skip_ci_tags,
17411756
)
17421757
apple_verification_test(
@@ -1751,7 +1766,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
17511766
},
17521767
tags = [
17531768
name,
1754-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1769+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
17551770
] + common.skip_ci_tags,
17561771
)
17571772
apple_verification_test(
@@ -1766,7 +1781,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
17661781
},
17671782
tags = [
17681783
name,
1769-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1784+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
17701785
] + common.skip_ci_tags,
17711786
)
17721787

@@ -1783,7 +1798,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
17831798
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform WATCHOS"],
17841799
tags = [
17851800
name,
1786-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1801+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
17871802
] + common.skip_ci_tags,
17881803
)
17891804
apple_verification_test(
@@ -1797,7 +1812,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
17971812
},
17981813
tags = [
17991814
name,
1800-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1815+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
18011816
] + common.skip_ci_tags,
18021817
)
18031818
apple_verification_test(
@@ -1811,7 +1826,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
18111826
},
18121827
tags = [
18131828
name,
1814-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1829+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
18151830
] + common.skip_ci_tags,
18161831
)
18171832

test/starlark_tests/ios_static_framework_tests.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def ios_static_framework_test_suite(name):
307307
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform IOS"],
308308
tags = [
309309
name,
310-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
310+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
311311
] + common.skip_ci_tags,
312312
)
313313
archive_contents_test(
@@ -322,7 +322,7 @@ def ios_static_framework_test_suite(name):
322322
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform IOS"],
323323
tags = [
324324
name,
325-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
325+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
326326
] + common.skip_ci_tags,
327327
)
328328

0 commit comments

Comments
 (0)