Skip to content

Commit 46a85f1

Browse files
authored
(feat): disable PREFIX substitution in entitlements (#2865)
1 parent e59e188 commit 46a85f1

File tree

2 files changed

+19
-29
lines changed

2 files changed

+19
-29
lines changed

tools/plisttool/plisttool.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,15 +1115,6 @@ def __init__(self, target, options):
11151115
# via the *_substitutions keys in the control because it takes an
11161116
# action running to extract them from the provisioning profile, so
11171117
# the starlark for the rule doesn't have access to the values.
1118-
#
1119-
# Set up the subs using the info extracted from the provisioning
1120-
# profile:
1121-
# - "PREFIX.*" -> "PREFIX.BUNDLE_ID"
1122-
bundle_id = self.options.get('bundle_id')
1123-
if bundle_id:
1124-
self._extra_raw_subs['%s.*' % team_prefix] = '%s.%s' % (
1125-
team_prefix, bundle_id)
1126-
# - "$(AppIdentifierPrefix)" -> "PREFIX."
11271118
self._extra_var_subs['AppIdentifierPrefix'] = '%s.' % team_prefix
11281119

11291120
else:
@@ -1288,7 +1279,8 @@ def _validate_entitlements_against_profile(self, entitlements):
12881279
self._check_entitlements_array(
12891280
entitlements, profile_entitlements,
12901281
'keychain-access-groups', self.target,
1291-
supports_wildcards=True)
1282+
supports_wildcards=True,
1283+
allow_wildcards_in_entitlements=True)
12921284

12931285
# com.apple.security.application-groups
12941286
# (This check does not apply to macOS-only provisioning profiles.)

tools/plisttool/plisttool_unittest.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,8 @@ def test_entitlements_options_var_subs(self):
12561256
},
12571257
}, {'Foo': 'abc123.'})
12581258

1259-
def test_entitlements_options_raw_subs(self):
1259+
def test_entitlements_options_preserves_wildcards(self):
1260+
"""Verify that wildcards in entitlements are preserved (matching Xcode behavior)."""
12601261
plist1 = {'Bar': 'abc123.*'}
12611262
self._assert_plisttool_result({
12621263
'plists': [plist1],
@@ -1267,7 +1268,7 @@ def test_entitlements_options_raw_subs(self):
12671268
'Version': 1,
12681269
},
12691270
},
1270-
}, {'Bar': 'abc123.my.bundle.id'})
1271+
}, {'Bar': 'abc123.*'})
12711272

12721273
def test_entitlements_no_profile_for_app_id_prefix(self):
12731274
with self.assertRaisesRegex(
@@ -1622,23 +1623,20 @@ def test_entitlements_keychain_not_allowed(self):
16221623
},
16231624
})
16241625

1625-
def test_entitlements_keychain_entitlements_wildcard_not_allowed(self):
1626-
with self.assertRaisesRegex(
1627-
plisttool.PlistToolError,
1628-
re.escape(plisttool.ENTITLEMENTS_VALUE_HAS_WILDCARD % (
1629-
_testing_target, 'keychain-access-groups', 'QWERTY.*'))):
1630-
_plisttool_result({
1631-
'plists': [{'keychain-access-groups': ['QWERTY.*']}],
1632-
'entitlements_options': {
1633-
'bundle_id': 'my.bundle.id',
1634-
'profile_metadata_file': {
1635-
'Entitlements': {
1636-
'keychain-access-groups': ['QWERTY.*'],
1637-
},
1638-
'Version': 1,
1639-
},
1640-
},
1641-
})
1626+
def test_entitlements_keychain_entitlements_wildcard_allowed(self):
1627+
"""Verify that wildcards in keychain-access-groups are allowed (matching Xcode behavior)."""
1628+
self._assert_plisttool_result({
1629+
'plists': [{'keychain-access-groups': ['QWERTY.*']}],
1630+
'entitlements_options': {
1631+
'bundle_id': 'my.bundle.id',
1632+
'profile_metadata_file': {
1633+
'Entitlements': {
1634+
'keychain-access-groups': ['QWERTY.*'],
1635+
},
1636+
'Version': 1,
1637+
},
1638+
},
1639+
}, {'keychain-access-groups': ['QWERTY.*']})
16421640

16431641
def test_entitlements_keychain_mismatch(self):
16441642
with self.assertRaisesRegex(

0 commit comments

Comments
 (0)