[Git][reproducible-builds/diffoscope][master] Improve mobileprovision support

Mattia Rizzolo (@mattia) gitlab at salsa.debian.org
Sun May 30 18:41:10 UTC 2021



Mattia Rizzolo pushed to branch master at Reproducible Builds / diffoscope


Commits:
ec3e353b by Keith Smiley at 2021-05-30T10:42:02-07:00
Improve mobileprovision support

Provisioning profiles generated by Apple do not have reproducible
formatting. Because of this a profile that is the same in many ways
(besides a few fields like CreationDate that always change) can have a
very noisy diff of whitespace and ordering changes. Ideally this
wouldn't be the case on their end (filed as FB9037367), but by using
plistlib we can normalize this output.

- - - - -


1 changed file:

- diffoscope/comparators/openssl.py


Changes:

=====================================
diffoscope/comparators/openssl.py
=====================================
@@ -16,11 +16,13 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.
 
+import plistlib
+
 from diffoscope.tools import tool_required
 from diffoscope.difference import Difference
 
 from .utils.file import File
-from .utils.command import Command
+from .utils.command import Command, our_check_output
 
 
 class OpenSSLPKCS7(Command):
@@ -29,23 +31,6 @@ class OpenSSLPKCS7(Command):
         return ("openssl", "pkcs7", "-print", "-noout", "-in", self.path)
 
 
-class OpenSSLSMIME(Command):
-    MASK_STDERR = True
-
-    @tool_required("openssl")
-    def cmdline(self):
-        return (
-            "openssl",
-            "smime",
-            "-inform",
-            "der",
-            "-verify",
-            "-noverify",
-            "-in",
-            self.path,
-        )
-
-
 class Pkcs7File(File):
     DESCRIPTION = "Public Key Cryptography Standards (PKCS) files (version #7)"
     FILE_TYPE_HEADER_PREFIX = b"-----BEGIN PKCS7-----"[:16]
@@ -65,9 +50,36 @@ class MobileProvisionFile(File):
     DESCRIPTION = "Apple Xcode mobile provisioning files"
     FILE_EXTENSION_SUFFIX = {".mobileprovision"}
 
+    @staticmethod
+    @tool_required("openssl")
+    def _get_structured_profile_text(path):
+        openssl_output = our_check_output(
+            [
+                "openssl",
+                "smime",
+                "-inform",
+                "der",
+                "-verify",
+                "-noverify",
+                "-in",
+                path,
+            ]
+        )
+        return plistlib.dumps(plistlib.loads(openssl_output), sort_keys=True)
+
     def compare_details(self, other, source=None):
+        my_content = MobileProvisionFile._get_structured_profile_text(
+            self.path
+        )
+        other_content = MobileProvisionFile._get_structured_profile_text(
+            other.path
+        )
         return [
-            Difference.from_operation(
-                OpenSSLSMIME, self.path, other.path, source="openssl smime"
+            Difference.from_text(
+                my_content,
+                other_content,
+                self.name,
+                other.name,
+                source="openssl smime",
             )
         ]



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/ec3e353bd184e94faa7803979bf45b2c494a0a23

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/ec3e353bd184e94faa7803979bf45b2c494a0a23
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20210530/3675a8ca/attachment.htm>


More information about the rb-commits mailing list