Repository navigation
fix: add checkHiddenCommits to tag push chain - #1893
Conversation
✅ Deploy Preview for endearing-brigadeiros-63f9d0 canceled.
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1893 +/- ##
==========================================
+ Coverage 88.97% 88.98% +0.01%
==========================================
Files 132 132
Lines 7273 7281 +8
Branches 1362 1365 +3
==========================================
+ Hits 6471 6479 +8
Misses 494 494
Partials 308 308 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dcoric
left a comment
There was a problem hiding this comment.
One ordering issue: in tagPushChainElements, checkIfWaitingAuth still runs before pullRemote, writePack and checkHiddenCommits. Once a tag push is approved, the re-push finds the approval, sets allowPush and leaves the chain before the new check. That re-push is the one forwarded upstream, so its pack is never checked for hidden commits.
The branch chain runs checkHiddenCommits before checkIfWaitingAuth. Could we move checkIfWaitingAuth after checkHiddenCommits here too, and extend the chain-order test to cover it? Everything else looks good.
|
@dcoric You're right, I didn't notice that 👍🏼 Should be good for a final look! |
|
CI is failing from a Docker image fetch failure... Should be good to merge otherwise |
dcoric
left a comment
There was a problem hiding this comment.
Ordering fix looks good. Two problems showed up running the check against real clones:
1. Hidden commits pass when the tag target is outside the shallow clone.
Tag HEAD~1 with an extra unreferenced commit in the pack: local receive-pack rejects the pack, writePack ignores that, newIdxFiles is empty, and the check passes with "Total commits in the pack: 0". The branch chain catches this later in getDiff; the tag chain has nothing after it.
Fix: in checkHiddenCommits, fail closed for tag pushes when nothing was indexed and the pack holds more than tag objects.
const packMeta = action.steps.find((s) => s.stepName === 'parsePackFile')?.content?.meta;
const onlyTagObjects = packMeta?.entries === (action.tagData?.length ?? 0);
if (action.actionType === PushType.TAG && !action.newIdxFiles?.length && !onlyTagObjects) {
step.setError('Unable to verify the pushed pack. Push the commits on a branch first, then push the tag.');
action.error = true;
return action;
}2. Force-moving a tag over SSH to a new commit is falsely rejected.
The single-branch clone lacks the old tag object, so rev-list old..new fails silently and the new commit is reported as unreferenced.
Fix: for tags, use the new OID alone.
const revRange =
oldOid === EMPTY_COMMIT_HASH || action.actionType === PushType.TAG ? newOid : `${oldOid}..${newOid}`;Please add a test for each.
|
@dcoric Thanks for catching that! Ready for another look. 👍🏼 |
Description
Adds
checkHiddenCommitsto tag push chain, and regression tests. Tag pushes were added in 2.1 but were missing this processor. Although this appears to be a regression from GHSA-v98g-8rqx-g93g, I'm not aware of any other orgs actively using tag pushes (and even then it's hard to exploit despite the risk score).Checklist
General
Documentation
Tests
npm test)npm run lintandnpm run format:check)npm run check-types)