-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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: Apply App Store compliance patch during installation #121947
Conversation
.PHONY: check-app-store-compliance | ||
check-app-store-compliance: | ||
@if [ "$(APP_STORE_COMPLIANCE_PATCH)" != "" ]; then \ | ||
patch --dry-run --quiet --force --strip 1 --directory "$(abs_srcdir)" --input "$(abs_srcdir)/$(APP_STORE_COMPLIANCE_PATCH)"; \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some explanation of the choices here:
--dry-run
means no changes are applied--quiet
means no "patching xyz.py" messages are output--force
means no questions are asked of the user, and the patch is assumed to be forward.
@ # due to files that are missing because of --disable-test-modules etc. | ||
@if [ "$(APP_STORE_COMPLIANCE_PATCH)" != "" ]; then \ | ||
echo "Applying app store compliance patch"; \ | ||
patch --force --reject-file "$(abs_builddir)/app-store-compliance.rej" --strip 2 --directory "$(DESTDIR)$(LIBDEST)" --input "$(abs_srcdir)/$(APP_STORE_COMPLIANCE_PATCH)" || true ; \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some explanation of the choices here:
--force
means no questions are asked of the user, and the patch is assumed to be forward.--reject-file
provides a file where rejected chunks will be output.
The --reject-file
option is required because installing when --disable-test-modules
is enabled results in a failure patching test/test_urlparse.py
- which then fails again because the test
folder doesn't exist, so it can't write a .rej
file. If the directory did exist, there would be a .rej
file in the distributed artefact.
.orig
files shouldn't be generated because we know the patch applies cleanly as a result of pre-validation.
An additional note for reviewers: It would be possible to enable checking the patch on macOS when not installing; but it would require adding another configuration target to differentiate between "apply", and "check but don't apply" cases. Given the additional complexity, and the fact that the patch will always be applied on iOS, I opted to omit this option - but I'm happy to revisit that. |
!buildbot iOS |
The iOS buildbot will fail because of #121832, but the host install stage will show evidence that the patch has been applied. |
@Yhg1s Could I ask for a release manager's call on back porting this to 3.12? As noted in the PR description, the problem exists in 3.12, but fixing it requires introducing a change to the build process, and it's not really a "security" issue by any conventional measure. |
Thanks for pursuing this, @freakboy3742! I will get to reviewing it ASAP but it likely won't be in time for 3.13.0b4 tomorrow. |
3.12 didn't even celebrate its first birthday yet! afaik it's still well within the "security AND bugfixes" realm. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent! This looks really good and this time I wasn't able to think of any other strange configure / make options to try! Thanks for taking so much time and care to try to get this as good as possible. Given the complexity of our Unix builds, it wouldn't be surprising if someone does find another edge case but I think we've done more than our due diligence here.
FWIW, I am -0 (maybe even -1) for backporting to 3.12. At several releases in at this point, 3.12 is at a stable point in its lifecycle. Making changes like this to |
That's a solid enough argument for me. I'll backport to 3.13, but leave it at that. |
Thanks @freakboy3742 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
…pythonGH-121947) Adds a --with-app-store-compliance configuration option that patches out code known to be an issue with App Store review processes. This option is applied automatically on iOS, and optionally on macOS. (cherry picked from commit 728432c) Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
GH-122105 is a backport of this pull request to the 3.13 branch. |
GH-121947) (#122105) gh-120522: Apply App Store compliance patch during installation (GH-121947) Adds a --with-app-store-compliance configuration option that patches out code known to be an issue with App Store review processes. This option is applied automatically on iOS, and optionally on macOS. (cherry picked from commit 728432c) Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
|
As far as I can make out, the buildbot failure is a false positive. The code that has been merged won't do anything on non-Apple platforms; and test that is failing doesn't intersect with the change that would have been made. |
…llation (pythonGH-121947) (python#122105) pythongh-120522: Apply App Store compliance patch during installation (pythonGH-121947) Adds a --with-app-store-compliance configuration option that patches out code known to be an issue with App Store review processes. This option is applied automatically on iOS, and optionally on macOS. (cherry picked from commit 728432c) Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
…llation (pythonGH-121947) (python#122105) pythongh-120522: Apply App Store compliance patch during installation (pythonGH-121947) Adds a --with-app-store-compliance configuration option that patches out code known to be an issue with App Store review processes. This option is applied automatically on iOS, and optionally on macOS. (cherry picked from commit 728432c) Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
…llation (pythonGH-121947) (python#122105) pythongh-120522: Apply App Store compliance patch during installation (pythonGH-121947) Adds a --with-app-store-compliance configuration option that patches out code known to be an issue with App Store review processes. This option is applied automatically on iOS, and optionally on macOS. (cherry picked from commit 728432c) Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
…llation (pythonGH-121947) (python#122105) pythongh-120522: Apply App Store compliance patch during installation (pythonGH-121947) Adds a --with-app-store-compliance configuration option that patches out code known to be an issue with App Store review processes. This option is applied automatically on iOS, and optionally on macOS. (cherry picked from commit 728432c) Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
…lation (pythonGH-121947) (python#122105) pythongh-120522: Apply App Store compliance patch during installation (pythonGH-121947) Adds a --with-app-store-compliance configuration option that patches out code known to be an issue with App Store review processes. This option is applied automatically on iOS, and optionally on macOS. (cherry picked from commit 728432c) Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
…llation (pythonGH-121947) (python#122105) pythongh-120522: Apply App Store compliance patch during installation (pythonGH-121947) Adds a --with-app-store-compliance configuration option that patches out code known to be an issue with App Store review processes. This option is applied automatically on iOS, and optionally on macOS. (cherry picked from commit 728432c) Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
…llation (pythonGH-121947) (python#122105) pythongh-120522: Apply App Store compliance patch during installation (pythonGH-121947) Adds a --with-app-store-compliance configuration option that patches out code known to be an issue with App Store review processes. This option is applied automatically on iOS, and optionally on macOS. (cherry picked from commit 728432c) Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
…llation (pythonGH-121947) (python#122105) pythongh-120522: Apply App Store compliance patch during installation (pythonGH-121947) Adds a --with-app-store-compliance configuration option that patches out code known to be an issue with App Store review processes. This option is applied automatically on iOS, and optionally on macOS. (cherry picked from commit 728432c) Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
…llation (pythonGH-121947) (python#122105) pythongh-120522: Apply App Store compliance patch during installation (pythonGH-121947) Adds a --with-app-store-compliance configuration option that patches out code known to be an issue with App Store review processes. This option is applied automatically on iOS, and optionally on macOS. (cherry picked from commit 728432c) Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
…lation (pythonGH-121947) (python#122105) pythongh-120522: Apply App Store compliance patch during installation (pythonGH-121947) Adds a --with-app-store-compliance configuration option that patches out code known to be an issue with App Store review processes. This option is applied automatically on iOS, and optionally on macOS. (cherry picked from commit 728432c) Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
…llation (pythonGH-121947) (python#122105) pythongh-120522: Apply App Store compliance patch during installation (pythonGH-121947) Adds a --with-app-store-compliance configuration option that patches out code known to be an issue with App Store review processes. This option is applied automatically on iOS, and optionally on macOS. (cherry picked from commit 728432c) Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
A revised approach to the change made by #120984 (which was reverted) and #121830, incorporating feedback from the review of those patches.
Apple’s macOS App Store is auto-rejects any app that contains the string
itms-services
. 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, and is always applied on iOS, 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 allows 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.
If the use of the patch is configured, a dry-run of the patching is performed early in the build process, against the original sources. This provides early feedback if the patch needs to be updated; if the patch cannot be applied, the build will fail.
The patch is actually applied during the
libinstall
target. It is applied against the installed library, prior to bytecode compilation.Any errors returned during this patch are ignored. This is required because the installed library might be missing files that are included in the patch. If
--disable-test-modules
is configured, any missing files will generate rejected chunks, andpatch
will return an error. However, in our case, we know (as a result of the validation check during the build) that the patch can be successfully applied against the files that do exist, so the only failures must be due to missing files. Any rejected chunks are written to a.rej
file in the build directory.As the patch is always applied on iOS, we'll get verification if the patch becomes incompatible (admittedly, only during buildbot validation, not during standard GitHub CI).
The underlying problem exists in 3.12, but fixing it requires adding a new build option, which arguably falls outside the "security fixes only" status of 3.12.
Fixes #120522.
📚 Documentation preview 📚: https://cpython-previews--121947.org.readthedocs.build/