Skip to content

Commit 2688df3

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 b124084 commit 2688df3

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
@@ -1306,7 +1306,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
13061306
},
13071307
tags = [
13081308
name,
1309-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1309+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
13101310
] + common.skip_ci_tags,
13111311
)
13121312
apple_verification_test(
@@ -1319,7 +1319,22 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
13191319
},
13201320
tags = [
13211321
name,
1322-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1322+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
1323+
] + common.skip_ci_tags,
1324+
)
1325+
1326+
# Tests that the rules report a user-actionable error when enhanced security features are
1327+
# requested without the required Xcode 26 opt-in feature assigned to a target.
1328+
analysis_failure_message_test(
1329+
name = "{}_enhanced_security_features_missing_xcode_26_opt_in_fail_test".format(name),
1330+
target_under_test = "//test/starlark_tests/targets_under_test/ios:simple_enhanced_security_app_without_required_opt_in",
1331+
expected_error = """
1332+
Apple enhanced security features were requested, but the build is missing the required feature \
1333+
"apple.enable_enhanced_security" that is needed to enable required entitlements in Xcode 26.0 or later.
1334+
""",
1335+
tags = [
1336+
name,
1337+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
13231338
] + common.skip_ci_tags,
13241339
)
13251340

@@ -1336,7 +1351,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
13361351
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform IOS"],
13371352
tags = [
13381353
name,
1339-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1354+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
13401355
] + common.skip_ci_tags,
13411356
)
13421357
apple_verification_test(
@@ -1349,7 +1364,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
13491364
},
13501365
tags = [
13511366
name,
1352-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1367+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
13531368
] + common.skip_ci_tags,
13541369
)
13551370
apple_verification_test(
@@ -1362,7 +1377,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
13621377
},
13631378
tags = [
13641379
name,
1365-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1380+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
13661381
] + common.skip_ci_tags,
13671382
)
13681383

@@ -1379,7 +1394,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
13791394
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform IOS"],
13801395
tags = [
13811396
name,
1382-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1397+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
13831398
] + common.skip_ci_tags,
13841399
)
13851400

@@ -1397,7 +1412,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
13971412
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform IOS"],
13981413
tags = [
13991414
name,
1400-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1415+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
14011416
] + common.skip_ci_tags,
14021417
)
14031418
apple_verification_test(
@@ -1412,7 +1427,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
14121427
},
14131428
tags = [
14141429
name,
1415-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1430+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
14161431
] + common.skip_ci_tags,
14171432
)
14181433
apple_verification_test(
@@ -1427,7 +1442,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
14271442
},
14281443
tags = [
14291444
name,
1430-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1445+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
14311446
] + common.skip_ci_tags,
14321447
)
14331448

@@ -1444,7 +1459,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
14441459
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform IOS"],
14451460
tags = [
14461461
name,
1447-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1462+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
14481463
] + common.skip_ci_tags,
14491464
)
14501465
apple_verification_test(
@@ -1458,7 +1473,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
14581473
},
14591474
tags = [
14601475
name,
1461-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1476+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
14621477
] + common.skip_ci_tags,
14631478
)
14641479
apple_verification_test(
@@ -1472,7 +1487,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
14721487
},
14731488
tags = [
14741489
name,
1475-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1490+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
14761491
] + common.skip_ci_tags,
14771492
)
14781493

@@ -1489,7 +1504,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
14891504
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform IOS"],
14901505
tags = [
14911506
name,
1492-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1507+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
14931508
] + common.skip_ci_tags,
14941509
)
14951510

@@ -1506,7 +1521,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
15061521
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform IOS"],
15071522
tags = [
15081523
name,
1509-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1524+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
15101525
] + common.skip_ci_tags,
15111526
)
15121527
apple_verification_test(
@@ -1520,7 +1535,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
15201535
},
15211536
tags = [
15221537
name,
1523-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1538+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
15241539
] + common.skip_ci_tags,
15251540
)
15261541
apple_verification_test(
@@ -1534,7 +1549,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
15341549
},
15351550
tags = [
15361551
name,
1537-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1552+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
15381553
] + common.skip_ci_tags,
15391554
)
15401555

@@ -1551,7 +1566,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
15511566
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform IOS"],
15521567
tags = [
15531568
name,
1554-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1569+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
15551570
] + common.skip_ci_tags,
15561571
)
15571572

@@ -1569,7 +1584,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
15691584
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform IOS"],
15701585
tags = [
15711586
name,
1572-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1587+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
15731588
] + common.skip_ci_tags,
15741589
)
15751590
apple_verification_test(
@@ -1584,7 +1599,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
15841599
},
15851600
tags = [
15861601
name,
1587-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1602+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
15881603
] + common.skip_ci_tags,
15891604
)
15901605
apple_verification_test(
@@ -1599,7 +1614,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
15991614
},
16001615
tags = [
16011616
name,
1602-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1617+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
16031618
] + common.skip_ci_tags,
16041619
)
16051620

@@ -1616,7 +1631,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
16161631
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform IOS"],
16171632
tags = [
16181633
name,
1619-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1634+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
16201635
] + common.skip_ci_tags,
16211636
)
16221637
apple_verification_test(
@@ -1630,7 +1645,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
16301645
},
16311646
tags = [
16321647
name,
1633-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1648+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
16341649
] + common.skip_ci_tags,
16351650
)
16361651
apple_verification_test(
@@ -1644,7 +1659,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
16441659
},
16451660
tags = [
16461661
name,
1647-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1662+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
16481663
] + common.skip_ci_tags,
16491664
)
16501665

@@ -1662,7 +1677,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
16621677
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform WATCHOS"],
16631678
tags = [
16641679
name,
1665-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1680+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
16661681
] + common.skip_ci_tags,
16671682
)
16681683
apple_verification_test(
@@ -1677,7 +1692,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
16771692
},
16781693
tags = [
16791694
name,
1680-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1695+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
16811696
] + common.skip_ci_tags,
16821697
)
16831698
apple_verification_test(
@@ -1692,7 +1707,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
16921707
},
16931708
tags = [
16941709
name,
1695-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1710+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
16961711
] + common.skip_ci_tags,
16971712
)
16981713

@@ -1709,7 +1724,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
17091724
macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform WATCHOS"],
17101725
tags = [
17111726
name,
1712-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1727+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
17131728
] + common.skip_ci_tags,
17141729
)
17151730
apple_verification_test(
@@ -1723,7 +1738,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
17231738
},
17241739
tags = [
17251740
name,
1726-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1741+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
17271742
] + common.skip_ci_tags,
17281743
)
17291744
apple_verification_test(
@@ -1737,7 +1752,7 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
17371752
},
17381753
tags = [
17391754
name,
1740-
# TODO: b/449684779 - Remove this tag once Xcode 26+ is the default Xcode.
1755+
# TODO: b/466364519 - Remove this tag once Xcode 26+ is the default Xcode.
17411756
] + common.skip_ci_tags,
17421757
)
17431758

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)