Skip to content

Add npm and pip cooldown defaults#21919

Merged
MikeMcQuaid merged 1 commit into
mainfrom
npm-pip-cooldown-defaults
Apr 4, 2026
Merged

Add npm and pip cooldown defaults#21919
MikeMcQuaid merged 1 commit into
mainfrom
npm-pip-cooldown-defaults

Conversation

@MikeMcQuaid
Copy link
Copy Markdown
Member

  • delay new npm and pip packages by one day so freshly published compromises are less likely to land in builds
  • apply the npm cooldown in shared helpers so Node formula dependency installs inherit it too
  • cover the new defaults in node_spec.rb and formula_spec.rb

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests (excluding integration tests) for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes.

OpenAI Codex used with manual review and edits.


Copilot AI review requested due to automatic review settings April 4, 2026 11:43
@MikeMcQuaid MikeMcQuaid force-pushed the npm-pip-cooldown-defaults branch from 706be94 to 46c6208 Compare April 4, 2026 11:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces default “cooldown” behavior for dependency installation via npm and pip to reduce the chance of consuming very recently published packages, and adds unit test coverage for the new defaults.

Changes:

  • Add --min-release-age=1 to npm install argument helpers in Language::Node.
  • Add a pip “uploaded prior to” cutoff (24h) to Formula#std_pip_args.
  • Update node_spec.rb and formula_spec.rb to assert the new default arguments.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
Library/Homebrew/language/node.rb Adds npm cooldown flag to shared npm argument helpers.
Library/Homebrew/formula.rb Adds pip cutoff argument and supporting time require.
Library/Homebrew/test/language/node_spec.rb Updates Node helper tests for new npm args and stubs env setup.
Library/Homebrew/test/formula_spec.rb Adds coverage for the new pip cutoff argument formatting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Library/Homebrew/formula.rb
Comment thread Library/Homebrew/formula.rb
Comment thread Library/Homebrew/test/language/node_spec.rb Outdated
@MikeMcQuaid MikeMcQuaid enabled auto-merge April 4, 2026 11:50
- delay new `npm` and `pip` packages by one day so freshly
  published compromises are less likely to land in builds
- apply the `npm` cooldown in shared helpers so Node formula
  dependency installs inherit it too
- cover the new defaults in `node_spec.rb` and `formula_spec.rb`
@MikeMcQuaid MikeMcQuaid force-pushed the npm-pip-cooldown-defaults branch from 46c6208 to 6c02db3 Compare April 4, 2026 11:51
@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Apr 4, 2026
Merged via the queue into main with commit 7c387d9 Apr 4, 2026
40 checks passed
@MikeMcQuaid MikeMcQuaid deleted the npm-pip-cooldown-defaults branch April 4, 2026 13:05
Comment on lines +2136 to +2138
# Delay packages published in the last day so builds are less likely to
# install a freshly compromised PyPI release.
args << "--uploaded-prior-to=#{(time - (24 * 60 * 60)).iso8601(0)}"
Copy link
Copy Markdown
Member

@cho-m cho-m Apr 4, 2026

Choose a reason for hiding this comment

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

This will only impact build-time packages when run in build-isolation. And nothing when no-build-isolation as we use --no-deps.

To cooldown a Python formula's dependencies, need to update the resource resolver:

def self.pip_report(packages, python_name: "python", print_stderr: false)
return [] if packages.blank?
command = [
Formula[python_name].opt_libexec/"bin/python", "-m", "pip", "install", "-q", "--disable-pip-version-check",
"--dry-run", "--ignore-installed", "--report=/dev/stdout", *packages.map(&:to_s)


EDIT: Though this may want to wait for bump support, i.e. #21888, so that the cooldown is applied to both main package and dependencies

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, let's add there too.

Though this may want to wait for bump support, i.e. #21888, so that the cooldown is applied to both main package and dependencies

Let's not. Let's not perfect be the enemy of good here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@cho-m thanks: #21920

@storopoli
Copy link
Copy Markdown

Sorry about the notification noise, but thank you for this change :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants