Conversation
628f5ae to
66778b8
Compare
A configurable delay between when a package version is published and
when it becomes eligible for selection during dependency resolution,
to mitigate supply-chain attacks where a freshly compromised release
is pulled into projects before it can be detected and retired.
Configuration:
* New `cooldown` config key (env `HEX_COOLDOWN`, project `:hex`
block, global `hex.config`); accepts "<N>d", "<N>w", "<N>mo".
* New `cooldown_exclude_repos` config key (env
`HEX_COOLDOWN_EXCLUDE_REPOS` comma-separated, project / global as
list); skips cooldown for the named repos so an organization can
consume hotfixes to its own repository without delay.
Implementation:
* `Hex.Cooldown` parses durations, computes cutoffs, and renders
pre-flight errors and solver failure notes.
* `Hex.Registry.Server` stores per-release `published_at` (Unix
seconds extracted from the registry Timestamp) under a new ETS slot;
`@ets_version` bumps to 5 so stale caches missing the slot are
invalidated on upgrade. `Hex.Dev.copy_package` and the test
fixture helper grow alongside.
* `Hex.Registry.Cooldown` wraps the registry behaviour, filtering
versions on `versions/2` against the active cutoff and respecting
the per-repo exclude list and a per-resolution bypass set.
* `Hex.RemoteConverger` builds the cutoff and bypass set at the
start of resolution. The bypass set has two sources:
- packages whose lock survived prepare_locked (mix deps.get against
an intact lockfile bypasses cooldown entirely);
- packages in old_lock whose locked version is known-unsafe (retired
or carrying a security advisory) so re-resolving to escape a
known-unsafe lock is never blocked.
A pre-flight check walks both top-level requirements and nested
hex deps under non-Hex (path / git) parents, raising a formatted
cooldown error when every matching version of a direct dep is in
cooldown. Solver failures get a generic cooldown hint appended when
cooldown is non-zero.
Releases without `published_at` (legacy registry data, repos that
have not rebuilt their index, or self-hosted clones) are treated as
eligible. Empty env values (`HEX_COOLDOWN=`,
`HEX_COOLDOWN_EXCLUDE_REPOS=`) fall through to the next source
instead of clobbering project / global config.
Re-vendor hex_core to pick up the Timestamp `published_at` field on
`Release`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A configurable delay between when a package version is published and when it becomes eligible for selection during dependency resolution, to mitigate supply-chain attacks where a freshly compromised release is pulled into projects before it can be detected and retired.
Configuration:
cooldownconfig key (envHEX_COOLDOWN, project:hexblock, globalhex.config); accepts "d", "w", "mo".cooldown_exclude_reposconfig key (envHEX_COOLDOWN_EXCLUDE_REPOScomma-separated, project / global as list); skips cooldown for the named repos so an organization can consume hotfixes to its own repository without delay.Implementation:
Hex.Cooldownparses durations, computes cutoffs, and renders pre-flight errors and solver failure notes.Hex.Registry.Serverstores per-releasepublished_at(Unix seconds extracted from the registry Timestamp) under a new ETS slot;@ets_versionbumps to 5 so stale caches missing the slot are invalidated on upgrade.Hex.Dev.copy_packageand the test fixture helper grow alongside.Hex.Registry.Cooldownwraps the registry behaviour, filtering versions onversions/2against the active cutoff and respecting the per-repo exclude list and a per-resolution bypass set.Hex.RemoteConvergerbuilds the cutoff and bypass set at the start of resolution. The bypass set has two sources:Releases without
published_at(legacy registry data, repos that have not rebuilt their index, or self-hosted clones) are treated as eligible. Empty env values (HEX_COOLDOWN=,HEX_COOLDOWN_EXCLUDE_REPOS=) fall through to the next source instead of clobbering project / global config.Re-vendor hex_core to pick up the Timestamp
published_atfield onRelease.