The Wayback Machine - https://web.archive.org/web/20240628064635/https://github.com/python/cpython/pull/120984
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-120522: Add a --with-app-store-compliance configure option to patch out problematic code #120984

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

freakboy3742
Copy link
Contributor

@freakboy3742 freakboy3742 commented Jun 25, 2024 •

Apple’s macOS App Store is auto-rejects any app that has the string itms-services in it. This is the custom URL prefix used for requesting an app installation from the iTunes App Store; however, sandboxed apps are prohibited from using these URLs. Apple’s automagical review processes are catching on the code in urllib’s parser’s handling of these URLs - even if the app in question never uses an itms-services:// URL. It’s present in the standard library; therefore the app is rejected.

Following a discussion on discuss.python.org, this PR adds a --with-app-store-compliance option to configure that will patch out any code that is known to be an issue with app store compliance.

There is currently a single patch, in the Mac resources directory, patching the known occurrences of itms-services. This patch is optionally applied on macOS if the configure flag is enabled, but the patch is applied in as "dry run" if the flag is not enabled. This ensures that a standard macOS CI pass will identify any drift in the patch.

The same patch is also used by iOS builds, as the review issues are the same. On iOS, the patch is always applied, because all apps will need to pass App Store compliance.

The option allows for a custom patch file to be provided (in case App Store rules change after support for a Python release has ceased. This also a platform other than iOS or macOS to apply a "compliance" patch by manually supplying one; although there's no known use case for this at present.

Fixes #120522.


📚 Documentation preview 📚: https://cpython-previews--120984.org.readthedocs.build/

@freakboy3742 freakboy3742 added OS-mac 3.12 bugs and security fixes 3.13 bugs and security fixes OS-ios 3.14 new features, bugs and security fixes needs backport to 3.13 bugs and security fixes labels Jun 25, 2024
@freakboy3742
Copy link
Contributor Author

I've flagged this for backport to 3.13, and documented the option as being added in 3.13. The issue also exists in (and was originally reported against) 3.12; I'm not sure what the policy is regarding a backport of a new (strictly optional) configuration option.

@freakboy3742
Copy link
Contributor Author

!buildbot iOS

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @freakboy3742 for commit eee0c93 🤖

The command will test the builders whose names match following regular expression: iOS

The builders matched are:

  • iOS ARM64 Simulator PR
Doc/using/ios.rst Outdated Show resolved Hide resolved
Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
Doc/using/mac.rst Outdated Show resolved Hide resolved
Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
@nineteendo
Copy link
Contributor

Did this get fixed already? https://buildbot.python.org/all/#/builders/1382/builds/32

patch -p1 --dry-run < ../../Mac/Resources/app-store-compliance.patch
File to patch: 
No file found--skip this patch? [y] 
/bin/sh: line 1: 33119 Segmentation fault: 11  patch -p1 --dry-run < ../../Mac/Resources/app-store-compliance.patch
make: *** [app-store-compliance] Error 139
@freakboy3742
Copy link
Contributor Author

Did this get fixed already?

No - the patch command isn't quite right for out-of-tree builds. I need to make a small tweak.

@freakboy3742
Copy link
Contributor Author

!buildbot iOS

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @freakboy3742 for commit 2d5a0a7 🤖

The command will test the builders whose names match following regular expression: iOS

The builders matched are:

  • iOS ARM64 Simulator PR
@freakboy3742 freakboy3742 marked this pull request as draft June 25, 2024 10:17
@freakboy3742
Copy link
Contributor Author

Hrm... that still isn't quite right. I'll need to take another look in the morning.

@freakboy3742
Copy link
Contributor Author

!buildbot iOS

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @freakboy3742 for commit eb48987 🤖

The command will test the builders whose names match following regular expression: iOS

The builders matched are:

  • iOS ARM64 Simulator PR
@freakboy3742 freakboy3742 marked this pull request as ready for review June 25, 2024 23:51
@freakboy3742
Copy link
Contributor Author

Worked out the problem(s). The code will now only allow one compliance patch to be applied, and gets the --dry-run and out-of-tree build handling correct as well.

@python/macos-team This should now be ready for review; apologies for the noise.

Copy link
Contributor

@ncoghlan ncoghlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of docs suggestions inline (this is a CPython implementation feature rather than a general Python language feature), but otherwise LGTM.

``news``, ``nntp``, ``prospero``, ``rsync``, ``rtsp``, ``rtsps``, ``rtspu``,
``sftp``, ``shttp``, ``sip``, ``sips``, ``snews``, ``svn``, ``svn+ssh``,
``telnet``, ``wais``, ``ws``, ``wss``.

.. note::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be impl-detail and "...CPython has been built.." rather than a regular note?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't know that option existed. Definitely seems appropriate here.

Doc/using/configure.rst Outdated Show resolved Hide resolved
Doc/library/urllib.parse.rst Outdated Show resolved Hide resolved
Doc/using/ios.rst Outdated Show resolved Hide resolved
Doc/using/mac.rst Outdated Show resolved Hide resolved
Doc/using/mac.rst Outdated Show resolved Hide resolved
@ncoghlan
Copy link
Contributor

A 3.12 backport would be a release manager call (so a question for @Yhg1s).

passing Apple's App Store review process for the macOS and iOS App Stores.
Handling for the ``itms-services`` scheme is always removed on iOS; on
macOS, it *may* be removed if CPython has been built with the
``--with-app-store-compliance`` option.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a link:

Suggested change
``--with-app-store-compliance`` option.
:option:`--with-app-store-compliance` option.
:source:`a patch file <Mac/Resources/app-store-compliance.patch>` that will remove
all code that is known to cause issues with the App Store review process. This
patch is applied automatically when CPython is configured with the
``--with-app-store-compliance`` option.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
``--with-app-store-compliance`` option.
:option:`--with-app-store-compliance` option.
@@ -0,0 +1,2 @@
Added a ``--with-app-store-compliance`` option to patch out known issues
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Added a ``--with-app-store-compliance`` option to patch out known issues
Added a :option:`--with-app-store-compliance` option to patch out known issues
AC_ARG_WITH(
[app_store_compliance],
[AS_HELP_STRING(
[--with-app-store-compliance=@<:@=PATCH-FILE@:>@],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One too many =, I presume?

Suggested change
[--with-app-store-compliance=@<:@=PATCH-FILE@:>@],
[--with-app-store-compliance=@<:@PATCH-FILE@:>@],
APP_STORE_COMPLIANCE_PATCH_TARGET="build/app-store-compliant"
APP_STORE_COMPLIANCE_PATCH_FLAGS=
;;
*) AC_MSG_ERROR([No default app store compliance patch available for $ac_sys_system]) ;;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with the other AC_MSG macros in this PR.

Suggested change
*) AC_MSG_ERROR([No default app store compliance patch available for $ac_sys_system]) ;;
*) AC_MSG_ERROR([no default app store compliance patch available for $ac_sys_system]) ;;
;;
*) AC_MSG_ERROR([No default app store compliance patch available for $ac_sys_system]) ;;
esac
AC_MSG_RESULT(["applying default app store compliance patch"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
AC_MSG_RESULT(["applying default app store compliance patch"])
AC_MSG_RESULT([applying default app store compliance patch])
APP_STORE_COMPLIANCE_PATCH="${withval}"
APP_STORE_COMPLIANCE_PATCH_TARGET="build/app-store-compliant"
APP_STORE_COMPLIANCE_PATCH_FLAGS=
AC_MSG_RESULT(["applying custom app store compliance patch"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
AC_MSG_RESULT(["applying custom app store compliance patch"])
AC_MSG_RESULT([applying custom app store compliance patch])
APP_STORE_COMPLIANCE_PATCH="Mac/Resources/app-store-compliance.patch"
APP_STORE_COMPLIANCE_PATCH_TARGET="build/app-store-compliant"
APP_STORE_COMPLIANCE_PATCH_FLAGS=
AC_MSG_RESULT(["applying default app store compliance patch"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
AC_MSG_RESULT(["applying default app store compliance patch"])
AC_MSG_RESULT([applying default app store compliance patch])
APP_STORE_COMPLIANCE_PATCH="Mac/Resources/app-store-compliance.patch"
APP_STORE_COMPLIANCE_PATCH_TARGET="build/app-store-compliant"
APP_STORE_COMPLIANCE_PATCH_FLAGS="--dry-run"
AC_MSG_RESULT(["checking (not applying) default app store compliance patch"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
AC_MSG_RESULT(["checking (not applying) default app store compliance patch"])
AC_MSG_RESULT([checking (not applying) default app store compliance patch])
APP_STORE_COMPLIANCE_PATCH=
APP_STORE_COMPLIANCE_PATCH_TARGET=
APP_STORE_COMPLIANCE_PATCH_FLAGS=
AC_MSG_RESULT(["not patching for app store compliance"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
AC_MSG_RESULT(["not patching for app store compliance"])
AC_MSG_RESULT([not patching for app store compliance])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and security fixes 3.13 bugs and security fixes 3.14 new features, bugs and security fixes awaiting merge needs backport to 3.13 bugs and security fixes OS-ios OS-mac
5 participants