Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 19d2eb4

Browse files
authored
iOS,macOS: add unsigned_binaries.txt (#54977)
There are three categories of binaries produced as part of the framework artifacts: * Those that use APIs that require entitlements and must be code-signed; e.g. gen_snapshot * Those that do not use APIs that require entitlements and must be code-signed; e.g. Flutter.framework dylib. * Those that do not need to be code-signed; e.g. Flutter.dSYM symbols. Until now, our signing infrastructure has assumed that all mach-o binaries in the artifacts we produce require a signature. dSYM files are not required to be codesigned, although the xcframework containing them are, and as such they cannot be removed or tampered with. The framework code-signing tests in `dev/bots/suite_runners/run_verify_binaries_codesigned_tests.dart` are only run on post-submit on release branches, and thus, this issue was not uncovered until the first release after all the dSYM work landed. Those tests were updated in flutter/flutter#154591. This updates the framework and artifact archive generation code to also explicitly exclude those files from signing. Issue: flutter/flutter#154571 Related: flutter/flutter#116493 Related: flutter/flutter#153532 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
1 parent cbfcee2 commit 19d2eb4

File tree

3 files changed

+51
-18
lines changed

3 files changed

+51
-18
lines changed

sky/tools/create_ios_framework.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,34 +168,44 @@ def zip_archive(dst, args):
168168
# the framework's `verifyCodeSignedTestRunner`.
169169
#
170170
# See: https://github.com/flutter/flutter/blob/62382c7b83a16b3f48dc06c19a47f6b8667005a5/dev/bots/suite_runners/run_verify_binaries_codesigned_tests.dart#L82-L130
171+
172+
# Binaries that must be codesigned and require entitlements for particular APIs.
171173
with_entitlements = ['gen_snapshot_arm64']
172174
with_entitlements_file = os.path.join(dst, 'entitlements.txt')
173175
sky_utils.write_codesign_config(with_entitlements_file, with_entitlements)
174176

177+
# Binaries that must be codesigned and DO NOT require entitlements.
175178
without_entitlements = [
176179
'Flutter.xcframework/ios-arm64/Flutter.framework/Flutter',
177180
'Flutter.xcframework/ios-arm64_x86_64-simulator/Flutter.framework/Flutter',
178181
'extension_safe/Flutter.xcframework/ios-arm64/Flutter.framework/Flutter',
179182
'extension_safe/Flutter.xcframework/ios-arm64_x86_64-simulator/Flutter.framework/Flutter',
180183
]
184+
without_entitlements_file = os.path.join(dst, 'without_entitlements.txt')
185+
sky_utils.write_codesign_config(without_entitlements_file, without_entitlements)
186+
187+
# Binaries that will not be codesigned.
188+
unsigned_binaries = []
181189
if args.dsym:
182-
without_entitlements.extend([
190+
unsigned_binaries.extend([
183191
'Flutter.xcframework/ios-arm64/dSYMs/Flutter.framework.dSYM/Contents/Resources/DWARF/Flutter',
184192
'extension_safe/Flutter.xcframework/ios-arm64/dSYMs/Flutter.framework.dSYM/Contents/Resources/DWARF/Flutter',
185193
])
186-
187-
without_entitlements_file = os.path.join(dst, 'without_entitlements.txt')
188-
sky_utils.write_codesign_config(without_entitlements_file, without_entitlements)
194+
unsigned_binaries_file = os.path.join(dst, 'unsigned_binaries.txt')
195+
sky_utils.write_codesign_config(unsigned_binaries_file, unsigned_binaries)
189196
# pylint: enable=line-too-long
190197

191198
zip_contents = [
192199
'gen_snapshot_arm64',
193200
'Flutter.xcframework',
194201
'entitlements.txt',
195202
'without_entitlements.txt',
203+
'unsigned_binaries.txt',
196204
'extension_safe/Flutter.xcframework',
197205
]
198-
sky_utils.assert_valid_codesign_config(dst, zip_contents, with_entitlements, without_entitlements)
206+
sky_utils.assert_valid_codesign_config(
207+
dst, zip_contents, with_entitlements, without_entitlements, unsigned_binaries
208+
)
199209
sky_utils.create_zip(dst, 'artifacts.zip', zip_contents)
200210

201211

sky/tools/create_macos_framework.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,28 +121,38 @@ def zip_xcframework_archive(dst, args):
121121
# the framework's `verifyCodeSignedTestRunner`.
122122
#
123123
# See: https://github.com/flutter/flutter/blob/62382c7b83a16b3f48dc06c19a47f6b8667005a5/dev/bots/suite_runners/run_verify_binaries_codesigned_tests.dart#L82-L130
124+
125+
# Binaries that must be codesigned and require entitlements for particular APIs.
124126
with_entitlements = []
125127
with_entitlements_file = os.path.join(dst, 'entitlements.txt')
126128
sky_utils.write_codesign_config(with_entitlements_file, with_entitlements)
127129

130+
# Binaries that must be codesigned and DO NOT require entitlements.
128131
without_entitlements = [
129132
'FlutterMacOS.xcframework/macos-arm64_x86_64/FlutterMacOS.framework/Versions/A/FlutterMacOS',
130133
]
134+
without_entitlements_file = os.path.join(dst, 'without_entitlements.txt')
135+
sky_utils.write_codesign_config(without_entitlements_file, without_entitlements)
136+
137+
# Binaries that will not be codesigned.
138+
unsigned_binaries = []
131139
if args.dsym:
132-
without_entitlements.extend([
140+
unsigned_binaries.extend([
133141
'FlutterMacOS.xcframework/macos-arm64_x86_64/dSYMs/FlutterMacOS.framework.dSYM/Contents/Resources/DWARF/FlutterMacOS',
134142
])
135-
136-
without_entitlements_file = os.path.join(dst, 'without_entitlements.txt')
137-
sky_utils.write_codesign_config(without_entitlements_file, without_entitlements)
143+
unsigned_binaries_file = os.path.join(dst, 'unsigned_binaries.txt')
144+
sky_utils.write_codesign_config(unsigned_binaries_file, unsigned_binaries)
138145
# pylint: enable=line-too-long
139146

140147
zip_contents = [
141148
'FlutterMacOS.xcframework',
142149
'entitlements.txt',
143150
'without_entitlements.txt',
151+
'unsigned_binaries.txt',
144152
]
145-
sky_utils.assert_valid_codesign_config(dst, zip_contents, with_entitlements, without_entitlements)
153+
sky_utils.assert_valid_codesign_config(
154+
dst, zip_contents, with_entitlements, without_entitlements, unsigned_binaries
155+
)
146156
sky_utils.create_zip(dst, 'framework.zip', zip_contents)
147157

148158

sky/tools/sky_utils.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ def assert_file(path, what):
2525
sys.exit(os.EX_NOINPUT)
2626

2727

28-
def assert_valid_codesign_config(framework_dir, zip_contents, entitlements, without_entitlements):
28+
def assert_valid_codesign_config(
29+
framework_dir, zip_contents, entitlements, without_entitlements, unsigned_binaries
30+
):
2931
"""Exits with exit code 1 if the codesign configuration contents are incorrect.
3032
All Mach-O binaries found within zip_contents exactly must be listed in
3133
either entitlements or without_entitlements."""
@@ -37,7 +39,11 @@ def assert_valid_codesign_config(framework_dir, zip_contents, entitlements, with
3739
log_error('ERROR: duplicate value(s) found in without_entitlements.txt')
3840
sys.exit(os.EX_DATAERR)
3941

40-
if _contains_duplicates(entitlements + without_entitlements):
42+
if _contains_duplicates(unsigned_binaries):
43+
log_error('ERROR: duplicate value(s) found in unsigned_binaries.txt')
44+
sys.exit(os.EX_DATAERR)
45+
46+
if _contains_duplicates(entitlements + without_entitlements + unsigned_binaries):
4147
log_error('ERROR: value(s) found in both entitlements and without_entitlements.txt')
4248
sys.exit(os.EX_DATAERR)
4349

@@ -52,26 +58,33 @@ def assert_valid_codesign_config(framework_dir, zip_contents, entitlements, with
5258
if _is_macho_binary(file):
5359
binaries.add(os.path.relpath(file, framework_dir))
5460

55-
# Verify that all Mach-O binaries are listed in either entitlements or without_entitlements.
56-
listed_binaries = set(entitlements + without_entitlements)
61+
# Verify that all Mach-O binaries are listed in either entitlements,
62+
# without_entitlements, or unsigned_binaries.
63+
listed_binaries = set(entitlements + without_entitlements + unsigned_binaries)
5764
if listed_binaries != binaries:
5865
log_error(
59-
'ERROR: binaries listed in entitlements.txt and without_entitlements.txt do not '
60-
'match the set of binaries in the files to be zipped'
66+
'ERROR: binaries listed in entitlements.txt, without_entitlements.txt, and'
67+
'unsigned_binaries.txt do not match the set of binaries in the files to be zipped'
6168
)
6269
log_error('Binaries found in files to be zipped:')
6370
for file in sorted(binaries):
6471
log_error(' ' + file)
6572

6673
not_listed = sorted(binaries - listed_binaries)
6774
if not_listed:
68-
log_error('Binaries NOT LISTED in entitlements.txt/without_entitlements.txt:')
75+
log_error(
76+
'Binaries NOT LISTED in entitlements.txt, without_entitlements.txt, '
77+
'unsigned_binaries.txt:'
78+
)
6979
for file in not_listed:
7080
log_error(' ' + file)
7181

7282
not_found = sorted(listed_binaries - binaries)
7383
if not_found:
74-
log_error('Binaries listed in entitlements.txt/without_entitlements.txt but NOT FOUND:')
84+
log_error(
85+
'Binaries listed in entitlements.txt, without_entitlements.txt, '
86+
'unsigned_binaries.txt but NOT FOUND:'
87+
)
7588
for file in not_found:
7689
log_error(' ' + file)
7790
sys.exit(os.EX_NOINPUT)

0 commit comments

Comments
 (0)