From c7f26ee2779a5e589e533c94c3dc7cfc40d3633a Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Mon, 15 Jan 2024 12:43:00 -0800 Subject: [PATCH] apple-codesign: add test for signing of .dSYM directories The behavior of the test is buggy, as the .dSYM/ directory should not be signed as a nested bundle. This should reproduce the bug reported in #128. --- .../tests/cmd/sign-bundle-dsym.trycmd | 404 ++++++++++++++++++ 1 file changed, 404 insertions(+) create mode 100644 apple-codesign/tests/cmd/sign-bundle-dsym.trycmd diff --git a/apple-codesign/tests/cmd/sign-bundle-dsym.trycmd b/apple-codesign/tests/cmd/sign-bundle-dsym.trycmd new file mode 100644 index 000000000..c9fdee5c3 --- /dev/null +++ b/apple-codesign/tests/cmd/sign-bundle-dsym.trycmd @@ -0,0 +1,404 @@ +Sign an application bundle with debug symbols in a .dSYM directory. + +``` +$ rcodesign debug-create-info-plist --bundle-name MyApp MyApp.app/Contents/Info.plist +writing MyApp.app/Contents/Info.plist + +$ rcodesign debug-create-macho MyApp.app/Contents/MacOS/MyApp +assuming default minimum version 11.0.0 +writing Mach-O to MyApp.app/Contents/MacOS/MyApp + +$ mkdir -p MyApp.app/Contents/MacOS/MyApp.app.dSYM/Contents/Resources/DWARF +$ mkdir -p MyApp.app/Contents/MacOS/MyApp.app.dSYM/Contents/Resources/Relocations/aarch64 + +$ rcodesign debug-create-info-plist --bundle-name MyApp.app.dSYM --package-type dSYM MyApp.app/Contents/MacOS/MyApp.app.dSYM/Contents/Info.plist +writing MyApp.app/Contents/MacOS/MyApp.app.dSYM/Contents/Info.plist + +$ touch MyApp.app/Contents/MacOS/MyApp.app.dSYM/Contents/Resources/DWARF/MyApp +$ touch MyApp.app/Contents/MacOS/MyApp.app.dSYM/Contents/Resources/Relocations/aarch64/MyApp.yml + +$ rcodesign sign MyApp.app MyApp.app.signed +signing MyApp.app to MyApp.app.signed +signing bundle at MyApp.app +signing 1 nested bundles in the following order: +Contents/MacOS/MyApp.app.dSYM +entering nested bundle Contents/MacOS/MyApp.app.dSYM +signing bundle at MyApp.app/Contents/MacOS/MyApp.app.dSYM into MyApp.app.signed/Contents/MacOS/MyApp.app.dSYM +bundle has no main executable to sign specially +leaving nested bundle Contents/MacOS/MyApp.app.dSYM +signing bundle at MyApp.app into MyApp.app.signed +signing main executable Contents/MacOS/MyApp + +$ rcodesign debug-file-tree MyApp.app.signed +d MyApp.app.signed/ +d MyApp.app.signed/Contents +f 0a5902dc8e47f490d038 MyApp.app.signed/Contents/Info.plist +d MyApp.app.signed/Contents/MacOS +f 5ae6736f434bcc89d779 MyApp.app.signed/Contents/MacOS/MyApp +d MyApp.app.signed/Contents/MacOS/MyApp.app.dSYM +d MyApp.app.signed/Contents/MacOS/MyApp.app.dSYM/Contents +f 6708b8b2252c5817e214 MyApp.app.signed/Contents/MacOS/MyApp.app.dSYM/Contents/Info.plist +d MyApp.app.signed/Contents/MacOS/MyApp.app.dSYM/Contents/Resources +d MyApp.app.signed/Contents/MacOS/MyApp.app.dSYM/Contents/Resources/DWARF +f e3b0c44298fc1c149afb MyApp.app.signed/Contents/MacOS/MyApp.app.dSYM/Contents/Resources/DWARF/MyApp +d MyApp.app.signed/Contents/MacOS/MyApp.app.dSYM/Contents/Resources/Relocations +d MyApp.app.signed/Contents/MacOS/MyApp.app.dSYM/Contents/Resources/Relocations/aarch64 +f e3b0c44298fc1c149afb MyApp.app.signed/Contents/MacOS/MyApp.app.dSYM/Contents/Resources/Relocations/aarch64/MyApp.yml +d MyApp.app.signed/Contents/MacOS/MyApp.app.dSYM/Contents/_CodeSignature +f de284994e528302d0e0a MyApp.app.signed/Contents/MacOS/MyApp.app.dSYM/Contents/_CodeSignature/CodeResources +d MyApp.app.signed/Contents/_CodeSignature +f cc2d27446655d0b25e58 MyApp.app.signed/Contents/_CodeSignature/CodeResources + +$ rcodesign print-signature-info MyApp.app.signed +- path: Contents/Info.plist + file_size: 576 + file_sha256: 0a5902dc8e47f490d03889d3593d17bddbf79e6c1f79494e20dd28f9459effa5 + entity: other +- path: Contents/MacOS/MyApp + file_size: 22544 + file_sha256: 5ae6736f434bcc89d7797606854610aec1618993e858fc5f8ba2a487ea5af576 + entity: + mach_o: + macho_linkedit_start_offset: 16384 / 0x4000 + macho_signature_start_offset: 16400 / 0x4010 + macho_signature_end_offset: 16821 / 0x41b5 + macho_linkedit_end_offset: 22544 / 0x5810 + macho_end_offset: 22544 / 0x5810 + linkedit_signature_start_offset: 16 / 0x10 + linkedit_signature_end_offset: 437 / 0x1b5 + linkedit_bytes_after_signature: 5723 / 0x165b + signature: + superblob_length: 421 / 0x1a5 + blob_count: 3 + blobs: + - slot: CodeDirectory (0) + magic: fade0c02 + length: 365 + sha1: c75393bcf61044e0d10cb03c81bc74c82966b595 + sha256: daa2ade41cf51bf9664f9a81e37d8b07f14af6eb62d2d649667ac65c3f80235f + - slot: RequirementSet (2) + magic: fade0c01 + length: 12 + sha1: 3a75f6db058529148e14dd7ea1b4729cc09ec973 + sha256: 987920904eab650e75788c054aa0b0524e6a80bfc71aa32df8d237a61743f986 + - slot: CMS Signature (65536) + magic: fade0b01 + length: 8 + sha1: 2a7254313aa41796079bb0e9d0f044345f69f98b + sha256: e6c83bc98a10348492c7d4d2378a54572ef29e1a5692ccd02b5e29f4b762d6a0 + code_directory: + version: '0x20400' + flags: CodeSignatureFlags(ADHOC) + identifier: com.example.mybundle + digest_type: sha256 + platform: 0 + signed_entity_size: 16400 + executable_segment_flags: ExecutableSegmentFlags(MAIN_BINARY) + code_digests_count: 5 + slot_digests: + - 'Info (1): 0a5902dc8e47f490d03889d3593d17bddbf79e6c1f79494e20dd28f9459effa5' + - 'RequirementSet (2): 987920904eab650e75788c054aa0b0524e6a80bfc71aa32df8d237a61743f986' + - 'Resources (3): cc2d27446655d0b25e58aa5da3dc69320fa09d259e0215f17e6bdee93b354043' + cms: null +- path: Contents/MacOS/MyApp.app.dSYM/Contents/Info.plist + file_size: 603 + file_sha256: 6708b8b2252c5817e2142a8c4a818b4463b822fd891e436583686c1b29cc061a + entity: other +- path: Contents/MacOS/MyApp.app.dSYM/Contents/Resources/DWARF/MyApp + file_size: 0 + file_sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + entity: other +- path: Contents/MacOS/MyApp.app.dSYM/Contents/Resources/Relocations/aarch64/MyApp.yml + file_size: 0 + file_sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + entity: other +- path: Contents/MacOS/MyApp.app.dSYM/Contents/_CodeSignature/CodeResources + file_size: 2708 + file_sha256: de284994e528302d0e0aff72fbb67494b72801d74462bdc86b44b0661e515233 + entity: + bundle_code_signature_file: !ResourcesXml + - + - + - + - + - ' files' + - ' ' + - ' Resources/DWARF/MyApp' + - ' ' + - ' 2jmj7l5rSw0yVb/vlWAYkK/YBwk=' + - ' ' + - ' Resources/Relocations/aarch64/MyApp.yml' + - ' ' + - ' 2jmj7l5rSw0yVb/vlWAYkK/YBwk=' + - ' ' + - ' ' + - ' files2' + - ' ' + - ' Resources/DWARF/MyApp' + - ' ' + - ' hash2' + - ' ' + - ' 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=' + - ' ' + - ' ' + - ' Resources/Relocations/aarch64/MyApp.yml' + - ' ' + - ' hash2' + - ' ' + - ' 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=' + - ' ' + - ' ' + - ' ' + - ' rules' + - ' ' + - ' ^Resources/' + - ' ' + - ' ^Resources/.*/.lproj/' + - ' ' + - ' optional' + - ' ' + - ' weight' + - ' 1000' + - ' ' + - ' ^Resources/.*/.lproj/locversion.plist$' + - ' ' + - ' omit' + - ' ' + - ' weight' + - ' 1100' + - ' ' + - ' ^Resources/Base/.lproj/' + - ' ' + - ' weight' + - ' 1010' + - ' ' + - ' ^version.plist$' + - ' ' + - ' ' + - ' rules2' + - ' ' + - ' .*/.dSYM($|/)' + - ' ' + - ' weight' + - ' 11' + - ' ' + - ' ^(.*/)?/.DS_Store$' + - ' ' + - ' omit' + - ' ' + - ' weight' + - ' 2000' + - ' ' + - ' ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/' + - ' ' + - ' nested' + - ' ' + - ' weight' + - ' 10' + - ' ' + - ' ^.*' + - ' ' + - ' ^Info/.plist$' + - ' ' + - ' omit' + - ' ' + - ' weight' + - ' 20' + - ' ' + - ' ^PkgInfo$' + - ' ' + - ' omit' + - ' ' + - ' weight' + - ' 20' + - ' ' + - ' ^Resources/' + - ' ' + - ' weight' + - ' 20' + - ' ' + - ' ^Resources/.*/.lproj/' + - ' ' + - ' optional' + - ' ' + - ' weight' + - ' 1000' + - ' ' + - ' ^Resources/.*/.lproj/locversion.plist$' + - ' ' + - ' omit' + - ' ' + - ' weight' + - ' 1100' + - ' ' + - ' ^Resources/Base/.lproj/' + - ' ' + - ' weight' + - ' 1010' + - ' ' + - ' ^[^/]+$' + - ' ' + - ' nested' + - ' ' + - ' weight' + - ' 10' + - ' ' + - ' ^embedded/.provisionprofile$' + - ' ' + - ' weight' + - ' 20' + - ' ' + - ' ^version/.plist$' + - ' ' + - ' weight' + - ' 20' + - ' ' + - ' ' + - + - + - '' +- path: Contents/_CodeSignature/CodeResources + file_size: 2734 + file_sha256: cc2d27446655d0b25e58aa5da3dc69320fa09d259e0215f17e6bdee93b354043 + entity: + bundle_code_signature_file: !ResourcesXml + - + - + - + - + - ' files' + - ' ' + - ' files2' + - ' ' + - ' MacOS/MyApp.app.dSYM/Contents/Info.plist' + - ' ' + - ' hash2' + - ' ' + - ' Zwi4siUsWBfiFCqMSoGLRGO4Iv2JHkNlg2hsGynMBho=' + - ' ' + - ' ' + - ' MacOS/MyApp.app.dSYM/Contents/Resources/DWARF/MyApp' + - ' ' + - ' hash2' + - ' ' + - ' 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=' + - ' ' + - ' ' + - ' MacOS/MyApp.app.dSYM/Contents/Resources/Relocations/aarch64/MyApp.yml' + - ' ' + - ' hash2' + - ' ' + - ' 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=' + - ' ' + - ' ' + - ' ' + - ' rules' + - ' ' + - ' ^Resources/' + - ' ' + - ' ^Resources/.*/.lproj/' + - ' ' + - ' optional' + - ' ' + - ' weight' + - ' 1000' + - ' ' + - ' ^Resources/.*/.lproj/locversion.plist$' + - ' ' + - ' omit' + - ' ' + - ' weight' + - ' 1100' + - ' ' + - ' ^Resources/Base/.lproj/' + - ' ' + - ' weight' + - ' 1010' + - ' ' + - ' ^version.plist$' + - ' ' + - ' ' + - ' rules2' + - ' ' + - ' .*/.dSYM($|/)' + - ' ' + - ' weight' + - ' 11' + - ' ' + - ' ^(.*/)?/.DS_Store$' + - ' ' + - ' omit' + - ' ' + - ' weight' + - ' 2000' + - ' ' + - ' ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/' + - ' ' + - ' nested' + - ' ' + - ' weight' + - ' 10' + - ' ' + - ' ^.*' + - ' ' + - ' ^Info/.plist$' + - ' ' + - ' omit' + - ' ' + - ' weight' + - ' 20' + - ' ' + - ' ^PkgInfo$' + - ' ' + - ' omit' + - ' ' + - ' weight' + - ' 20' + - ' ' + - ' ^Resources/' + - ' ' + - ' weight' + - ' 20' + - ' ' + - ' ^Resources/.*/.lproj/' + - ' ' + - ' optional' + - ' ' + - ' weight' + - ' 1000' + - ' ' + - ' ^Resources/.*/.lproj/locversion.plist$' + - ' ' + - ' omit' + - ' ' + - ' weight' + - ' 1100' + - ' ' + - ' ^Resources/Base/.lproj/' + - ' ' + - ' weight' + - ' 1010' + - ' ' + - ' ^[^/]+$' + - ' ' + - ' nested' + - ' ' + - ' weight' + - ' 10' + - ' ' + - ' ^embedded/.provisionprofile$' + - ' ' + - ' weight' + - ' 20' + - ' ' + - ' ^version/.plist$' + - ' ' + - ' weight' + - ' 20' + - ' ' + - ' ' + - + - + - '' + +```