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

Autobuild: Work around CodeQL-induced build failures #3223

Merged
merged 3 commits into from
Feb 6, 2024

Conversation

softins
Copy link
Member

@softins softins commented Feb 1, 2024

This PR introduces the fix created by @hoffie to prevent CodeQL from interfering with the operation of create-dmg/hdiutil when the Github CI is building for MacOS.

It uses sudo without changing user, to provide isolation of the create-dmg step in the build process.

CHANGELOG: Autobuild: Prevent CodeQL-induced build failures for MacOS

Context: Fixes an issue?

Fixes: #3207

Does this change need documentation? What needs to be documented and how?

No

Status of this Pull Request

Ready to merge.

What is missing until this pull request can be merged?

Just review.

Checklist

  • I've verified that this Pull Request follows the general code principles
  • I tested my code and it does what I want
  • My code follows the style guide
  • I waited some time after this Pull Request was opened and all GitHub checks completed without errors.
  • I've filled all the content above

@softins
Copy link
Member Author

softins commented Feb 1, 2024

It would be good to get this in, as I have a few other PRs to create, and would like their autobuilds to go green! :)

Copy link
Member

@ann0see ann0see left a comment

Choose a reason for hiding this comment

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

Otherwise approving as CI is green.

mac/deploy_mac.sh Outdated Show resolved Hide resolved
@ann0see ann0see added this to the Release 3.11.0 milestone Feb 1, 2024
@@ -120,7 +120,9 @@ build_installer_image() {

# Build installer image

create-dmg \
# Using sudo gets rid of CodeQL's virally infecting dylib preloads which break hdiutil's helper
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reference for where this information can be confirmed? (i.e. site providing background explanation and details of why the fix is safe and appropriate)

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the solution was found by @hoffie empirically, as a way to prevent propagation of CodeQL's dylib injection environment variables. He described the tests in the original issue #3207, but didn't quote any third-party reference.

Copy link
Member

Choose a reason for hiding this comment

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

I think it should be safe as it should be equivalent to a new shell just executing create-dmg.
@hoffie probably did that based on testing?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the comment needs to be more reassuring about what's happening, in that case.

Copy link
Member

Choose a reason for hiding this comment

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

Is there a reference for where this information can be confirmed? (i.e. site providing background explanation and details of why the fix is safe and appropriate)

I don't think so. That CodeQL uses DYLIB injection can be observed by dumping environment variables. That environment-cleaned shells still inherit it was the result of my tests. That sudo is a workaround (maybe due to SETUID) was found in other projects as well. That sudo-to-root is not required at all was a result of my tests (and is way better than running everything with elevated privileges by default, in my opinion).

Comment on lines +123 to +132
# When this script is run on Github's CI with CodeQL enabled, CodeQL adds dynamic library
# shims via environment variables, so that it can monitor the compilation of code.
# In order for these settings to propagate to compilation called via shell/bash scripts,
# the CodeQL libs seem automatically to create the same environment variables in sub-shells,
# even when called via 'env'. This was determined by experimentation.
# Unfortunately, the CodeQL libraries are not compatible with the hdiutil program called
# by create-dmg. In order to prevent the automatic propagation of the environment, we use
# sudo to the same user in order to invoke create-dmg with a guaranteed clean environment.
#
# /System/Library/PrivateFrameworks/DiskImages.framework/Resources/diskimages-helper.
Copy link
Member

Choose a reason for hiding this comment

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

Looks good to me, thanks!

@softins softins merged commit 2110095 into jamulussoftware:main Feb 6, 2024
15 checks passed
@softins softins deleted the mac-codeql-fix branch February 6, 2024 23:37
@pljones pljones added the tooling Changes to the automated build system label Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tooling Changes to the automated build system
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Autobuild: Mac legacy CI failure: hdiutil: create failed - No child processes
4 participants