Repository navigation
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Summary by CodeRabbit
Walkthrough
Changescheckver downgrade prevention
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
bin/checkver.ps1 (1)
443-449: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd integration coverage for the new direction branches.
Cover these cases in the
checkvertests:
- A newer source version updates normally.
- An older source version with
-Updateleaves the manifest unchanged and emits the warning.-ForceUpdatepermits the downgrade.- A skipped regression does not stop processing the next manifest.
The supplied
Compare-Versiontests intest/Scoop-Versions.Tests.ps1, Lines 64-71, do not verify this guard or itscontinuepath.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: c9cb1e95-7053-4003-b73b-7826a861930a
📒 Files selected for processing (2)
CHANGELOG.mdbin/checkver.ps1
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Good call — added in 95640c6 as a separate commit, covering exactly the four cases listed. There was no existing harness for Tagged To check the tests actually exercise the new branches rather than passing vacuously, I ran them against unpatched
The two guard-specific cases fail without the fix while the two controls still pass, which is the signature I wanted. Verified on Windows 11 x64 / PowerShell 7.6.5 / Pester 6.1.0. You're also right that the |
2e2ffc9 to
cc8247f
Compare
|
This is actively working as expected. My scoop-vpinball bucket has been running the excavator against this fork branch since #6717 was filed, and it's been correctly blocking the nightly version regressions every scheduled run while still allowing genuine updates through: https://github.com/gitfool/scoop-vpinball/actions/runs/32251763617/job/96064166590 Also trimmed the warning message in the latest force-push — the "; source may be reporting a stale version" suffix was unnecessarily verbose for a log line that's already self-explanatory. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: fcc85fba-8d5b-4c81-abb9-5d55644c3864
📒 Files selected for processing (2)
bin/checkver.ps1test/Scoop-Checkver.Tests.ps1
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
cc8247f to
6eacf76
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
test/Scoop-Checkver.Tests.ps1 (1)
53-75: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winAssert the complete manifest state.
Get-ManifestVersionchecks onlyversion. The upgrade and forced-downgrade tests can pass whileurlorhashremain stale. The regression test can pass while a skipped update changes those fields. Read the full manifest and assertversion,url, andhash; compare the complete pre/post manifest for the skipped case.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 5ab70e19-bfc9-450b-8aa3-0e066ffd672e
📒 Files selected for processing (1)
test/Scoop-Checkver.Tests.ps1
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
6eacf76 to
f8159c7
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 3ab80262-8b73-4b5e-81dd-b9256ddca61b
📒 Files selected for processing (1)
test/Scoop-Checkver.Tests.ps1
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
f8159c7 to
cf771f4
Compare
|
Blocking automatic downgrades by default makes sense as a safeguard against incorrect upstream version detection. However, I don’t think downgrades should be prohibited entirely. A lower version is not necessarily less secure than a higher one. In the event of a compromised release or supply-chain attack, reverting to a previously verified version may be the safest remediation. The Trivy supply-chain incident illustrates this case: a newer release was malicious, so version ordering alone could not be used as a security or trust signal. Could we keep this protection by default while providing an explicit override? Reference: https://www.aquasec.com/blog/trivy-supply-chain-attack-what-you-need-to-know/ |
9a73d06 to
47d9ef1
Compare
|
This is by design. The upstream may may withdraw the version release and delete the released artifacts, and Scoop always tracks the latest and downloadable version. |
|
@niheaven if by design, it's actually undesirable/unwanted in my scenario, so it should at least be configurable. |
1d055b8 to
b39beed
Compare
b39beed to
bd69f89
Compare
I also find this design to be quite sound. This guarantees that in the event of a version rollback upstream, the manifest doesn't require manual intervention for users to install or update without issues (since the latest version is still functional); otherwise, manual edits to the manifest would be necessary. Below is a comparison between Scoop (which allows downgrades) and Homebrew (which disallows downgrades).
Since the client side does not perform downgrades even if a version rollback occurs, in such cases you should not do a
It would be better to provide manifest-level or bucket-level options to allow customization, rather than changing the default behavior directly. This could help with edge cases (such as CDN cache inconsistencies, or in your scenario, inconsistent responses from the GitHub API) where no better checkver workaround is available (though in any scenario, I believe updating checkver should always be the preferred approach). |
|
@z-Fng I have a homebrew tap for the same artifacts and like you say it does not have the same downgrade behaviour, which is good/better from my pov. So are you proposing I should move the downgrade check to my bucket or manifest, more likely since the nightly is the only one with the issue, instead? How would I do that exactly? Are there buckets or manifests that already do this? |
I'll reconsider the proper method to handle this after v0.6.0 release. |
Yes. In my view, this is an edge case. There are also lots of examples of intended downgrades across official buckets. We shouldn't change the default behavior of checkver just for an edge case. Changing the default behavior would be a breaking change, requiring far more adaptation effort than the benefits it would bring.
Having manifest-level or bucket-level options would be a much better way to handle unintended downgrades. BTW, from what I recall, there are indeed some tricky workarounds. For example, |
I could rewrite this to be opt-in and thereby keep the current default behaviour, but it sounds like you'd still prefer bucket/manifest-level config instead, and since that's not really supported (requires "workarounds") and not in the public api, then I'll just have to wait. |
bd69f89 to
c0c08fc
Compare
c0c08fc to
7ed4a98
Compare
|
@niheaven @z-Fng following up now that v0.6.0 has shipped. I've rebased onto the latest The default behaviour of Squashed to a single commit; CI and the automated review are green on the new head. I've also updated the PR title and description to match. |
|
Quick question: we already have a |
|
@niheaven I think It's client-side, in
So enabling What I want is upstream of all that: as the bucket maintainer I want to control and prevent downgrades from my side, at the source. |
|
Yes, but from user side, they are the same: stop from installing a fallback/old version. |
|
I didn't change the user side at all, and it's not relevant here. This is all about the maintainer side. I never want to downgrade the vpinball-nightly version in my bucket as this only happens due to unstable github artifacts. |
7ed4a98 to
e2f2ba6
Compare
Providing a few examples where CDN cache inconsistency caused version flip-flopping, just for the maintainers' visibility. With this feature in place, we wouldn't have to bother with workarounds.
By the way, guess this should be considered a feature rather than a fix. Also, should we allow passing this as a global parameter ( |
e2f2ba6 to
7525a88
Compare
1773b3d to
387fe69
Compare
Description
checkver.ps1 -Updaterewrites a manifest whenever the detected version differs from the manifest version, including when it is older. This adds an opt-in guard so a manifest can refuse a backwards rewrite.The existing
$update_availablecheck (... -ne 0) only distinguishes "same" from "different" and feeds a console message; it never gated the actual write against direction, so a lower detected version was rewritten as if it were an update. This captures the comparison result, derives an explicit$version_regressedflag from it, and adds a per-manifest, opt-in guard keyed offcheckver.skipdowngrade:[Scoop.VersionComparer]::Comparealready returns the correct direction for these cases (positive when the manifest is ahead of the detected version), including dash-suffixed nightly versions, so no comparison logic needed changing and$update_availablekeeps its existing meaning.The guard is opt-in and off by default: default
checkverbehaviour is unchanged, so this cannot alter any existing manifest's updates unless its maintainer sets the flag.-ForceUpdateoverrides the guard, matching how it already overrides the other version checks incheckver, so a deliberate downgrade is still possible.Design
checkver.skipdowngrademanifest property turns the guard on. Absent orfalseleaves the long-standing behaviour intact.checkver.ps1is a bucket-maintainer tool (run by the excavator / auto-pr), never by an end user installing a package, so the control lives in the manifest'scheckverblock alongside the other maintainer knobs (reverse,useragent,jsonpath, ...) and is documented inschema.json.-ForceUpdateescape hatch rather than introducing a parameter.Motivation and Context
Closes #6717
When an upstream source transiently reports a stale version, the excavator commits and pushes the downgrade to the bucket, from where it propagates to users. Recovery requires
reset --hardplus a force-push, which then breaksscoop updatefor anyone who already pulled the bad commit (fatal: Not possible to fast-forward, aborting.).In the case that prompted this, a nightly manifest versioned
<semver>-<commit-count>-<sha>was moved from10.8.1-5435-292018604back to10.8.1-5357-d63469107, i.e. 78 commits and three weeks backwards, and then repeatedly on subsequent scheduled runs. The trigger was upstream — GitHub's/actions/workflows/{id}/runs?event=pushintermittently omitting recent runs (community/community#24626) — so the stale read is not Scoop's bug. The problem is that Scoop treats "different" as "newer" and offers no way to guard against it.There is prior art for the directional-by-default-with-opt-out pattern on the client-side status path, still present in
app_status:Scoop/lib/core.ps1
Lines 570 to 576 in 20779c9
This change gives bucket maintainers an equivalent, explicit control for the
checkverwrite path.How Has This Been Tested?
Automated coverage added in
test/Scoop-Checkver.Tests.ps1, taggedScoopso it runs whenever PowerShell files change. The fixtures pointcheckver.urlandautoupdate.hash.urlat local files viafile://URIs, so the fullcheckver -Updateround trip runs offline and deterministically with no network dependency:skipdowngradeunset -> manifest downgraded (default behaviour, unchanged)skipdowngradeexplicitlyfalse-> manifest downgradedskipdowngradetrue-> manifest unchanged, warning emittedskipdowngradetruewith-ForceUpdate-> downgrade permitted (override)That covers the three states of the flag (absent,
false,true) plus the-ForceUpdateoverride. Verified locally on Windows 11 x64, PowerShell 7.6.5, Pester 6.2.0 (6/6 passing), rebased onto the latestdevelopwith the[Scoop.VersionComparer]API.Also confirmed
Invoke-ScriptAnalyzeragainstPSScriptAnalyzerSettings.psd1reports no findings forbinortest, and the new file satisfies theScoop-00File.Tests.ps1style constraints (CRLF, no BOM, trailing newline, no trailing whitespace, no leading tabs).Manually reproduced against a real source with
skipdowngradeenabled. Before the guard:and after:
Checklist:
developbranch.The
schema.jsonproperty and the CHANGELOG entry are the documentation surfaces this change touches; there is no user-facing document describingcheckverupdate semantics.

Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
Adds an opt-in
checkver.skipdowngradeflag that stops older detected versions from rewriting a manifest.No actionable issues found. Tests were inspected, not run.
Reviews (5) · Last reviewed commit: "fix(checkver): Add opt-in skipdowngrade ..." · Reviewed by Greptile