-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
Support for opt-in network isolation in build/test sandboxes #17081
Conversation
9302afb
to
4d5d65b
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
For this point in particular, to achieve this would require more significant re-design of the formula installation/postinstall/test sandbox setup code. Currently, the sandbox is set up before the respective block is run, so the decision/logic to enable this has to be outside the install/test/postinstall blocks; trying to change it inside the block is too late since everything inside e.g.
I personally like this idea but am not sure how it ( |
This comment was marked as off-topic.
This comment was marked as off-topic.
@alebcay AMAZING work here 👏🏻. Seen many attempts over the years and this seems by far the most likely to actually get adopted.
Given there's only three: I wonder about just having them all be separate calls? I guess "methods" would work instead of "phases". I don't think we really describe these to users/contributors anywhere 🤔
Yeh, I think different phases makes sense.
This makes sense to me 👍🏻 The main question I have here isn't actually about the implementation but about formulae: how many formulae have you tried this on already? I'd be interested to see at least 3+ where it's working for (each of) build, postinstall, test before this gets merged. Also I think it'd make sense pretty quickly to have some sort of environment variable to enable this without the DSL. It'd be great to be able to play around locally or with test-bot to find out which formulae can have this DSL used. We also probably want to e.g. require it unconditionally for new formulae at some point. Relatedly, based on similar DSL addition work like this, it might be nice to have effectively a no-op reverse DSL e.g. This DSL would also make it easier to have a triage process (perhaps with the environment variable above) for formulae where:
Again: great work here and looking forward to seeing how this evolves! ❤️ |
@RandomDSdevel I appreciate the enthusiasm but I'm not sure your code review on PRs like this is helpful given your knowledge of Homebrew internals and Ruby, sorry ❤️ |
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.
Minor bikeshedding comment, but otherwise seems reasonable to me
4d5d65b
to
d6d916e
Compare
Thanks for the feedback everyone, made some adjustments:
One thing I noticed - tests that use resources currently cannot run offline because, unlike formula build time, the resource fetch seems to be executed in the sandbox (vs before the sandbox). Todo - consider opening up localhost in test sandbox when network access is denied. Some formulae that already seem to be working offline - or not - with this. Might update with some more in the next day or two.
1 - In the long term, I think there will be formulae (like |
I don't think we should ever do that vendoring. I think better to make some DSL changes/additions. Most of these dependency download systems use checksummed and/or version pinned downloads here and have their own (used at comparable scale to Homebrew) security around this. Instead we should isolate what they do so they aren't able to e.g. arbitrarily write and perhaps restrict which hosts they can download from. I think there's probably a place for a
To be clear: this should not block this PR being merged/DSL being added but will be worth thinking about as time goes on and we want to get 100% of homebrew-core formulae offline. Alternatively, for tests: there was also talk in other issues about having resources assigned as "test resources" (much like how "normal" resources are implicitly "build resources") and then they could be fetched by |
This comment was marked as off-topic.
This comment was marked as off-topic.
@RandomDSdevel I asked you earlier so I'll be a little more firm here: until you're willing to step up contributions such that you're asking to be a Homebrew maintainer: please stop commenting on PRs, thanks. |
Agreed. It would probably be better to run something like |
d6d916e
to
7195054
Compare
Made some adjustments:
|
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.
Looking good @alebcay, almost ready to merge here! Might be worth a homebrew/core PR to modify a few formulae so we can see what the syntax might look like there.
0aa581e
to
bcb5d45
Compare
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.
One question and then should be good to go!
@alebcay Would love to see an example PR in homebrew-core! |
bcb5d45
to
9e7aed0
Compare
Opened Homebrew/homebrew-core#169720. A few more things I thought of as I opened that:
|
There's already an existing cop so you should be able to add it to that 👍🏻
This makes sense to me.
Feels like it should be the same building from source/building bottles with/without API. |
9e7aed0
to
934398d
Compare
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.
Thanks again @alebcay, great work here!
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?This is probably going to need a lot of iterating, but I think it's in a state that's ready for some eyes and feedback now.
Overview
This PR introduces opt-in (disabled by default) support for network isolation during build, test, and postinstall. A formula can opt-in like so:
Suppose we opt-in a formula for offline build phase like so:
and perhaps there's a pesky
curl
call in the install block:When we attempt to install this formula:
Things still to be (re-)considered
:build
and:postinstall
into:build
, while leaving:test
as its ownenable_offline_phase
without arguments currently enables for all. Would it be less surprising for the no-arguments case to enable for build only? build + postinstall? Or maybe require an argument:all
as an easy way to enable for everything, if we decide to require an argument