Fix verifyMergeable functionality#1316
Open
IITI-tushar wants to merge 1 commit into
Open
Conversation
patzielinski
reviewed
May 1, 2026
patzielinski
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for sending this in, @IITI-tushar.
Can you also add tests for this to make sure this doesn't regress?
1 task
Signed-off-by: Tushar Saxena <019saxenatushar@gmail.com>
7447544 to
af83670
Compare
There was a problem hiding this comment.
Pull request overview
This PR tightens VerifyMergeable/VerifyMergeableForCommit verification by ensuring global threshold checks only count principals that actually contributed toward meeting the verification threshold, rather than counting all trusted principals.
Changes:
- Fix
verifyGitObjectAndAttestationsUsingVerifiersto setacceptedPrincipalIDstotrustedUsedPrincipalIDsin mergeable mode. - Add regression tests intended to cover the global-threshold bypass scenario in mergeable verification paths.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
internal/policy/verify.go |
Corrects accepted-principal accounting in mergeable verification to prevent inflating principal counts for global threshold checks. |
internal/policy/verify_test.go |
Adds new test cases meant to ensure mergeable verification fails when global thresholds aren’t satisfied. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1381
to
+1399
| repo, _ := createTestRepository(t, func(t *testing.T) *State { | ||
| state := createTestStateWithThresholdPolicyAndGitHubAppTrustForMixedAttestations(t) | ||
|
|
||
| rootMetadata, err := state.GetRootMetadata(false) | ||
| require.NoError(t, err) | ||
| require.NoError(t, rootMetadata.AddGlobalRule( | ||
| tufv01.NewGlobalRuleThreshold("global-threshold-3", []string{"git:refs/heads/main"}, 3), | ||
| )) | ||
|
|
||
| signer := setupSSHKeysForSigning(t, rootKeyBytes, rootPubKeyBytes) | ||
| rootEnv, err := dsse.CreateEnvelope(rootMetadata) | ||
| require.NoError(t, err) | ||
| rootEnv, err = dsse.SignEnvelope(testCtx, rootEnv, signer) | ||
| require.NoError(t, err) | ||
|
|
||
| state.Metadata.RootEnvelope = rootEnv | ||
| require.NoError(t, state.preprocess()) | ||
| return state | ||
| }) |
Contributor
Author
There was a problem hiding this comment.
@copilot give fix based on this feedback
Comment on lines
+2082
to
+2100
| repo, _ := createTestRepository(t, func(t *testing.T) *State { | ||
| state := createTestStateWithThresholdPolicyAndGitHubAppTrustForMixedAttestations(t) | ||
|
|
||
| rootMetadata, err := state.GetRootMetadata(false) | ||
| require.NoError(t, err) | ||
| require.NoError(t, rootMetadata.AddGlobalRule( | ||
| tufv01.NewGlobalRuleThreshold("global-threshold-3", []string{"git:refs/heads/main"}, 3), | ||
| )) | ||
|
|
||
| signer := setupSSHKeysForSigning(t, rootKeyBytes, rootPubKeyBytes) | ||
| rootEnv, err := dsse.CreateEnvelope(rootMetadata) | ||
| require.NoError(t, err) | ||
| rootEnv, err = dsse.SignEnvelope(testCtx, rootEnv, signer) | ||
| require.NoError(t, err) | ||
|
|
||
| state.Metadata.RootEnvelope = rootEnv | ||
| require.NoError(t, state.preprocess()) | ||
| return state | ||
| }) |
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.
Refers #1315
Description
This pull request makes a targeted update to the logic for verifying principals in the
verifyGitObjectAndAttestationsUsingVerifiersfunction. The change ensures that only the principals actually counted toward the verification threshold are accepted, rather than all trusted principals.verifyGitObjectAndAttestationsUsingVerifiers(internal/policy/verify.go), changed assignment so that only the principals used to meet the threshold (trustedUsedPrincipalIDs) are accepted, instead of all trusted principals (trustedPrincipalIDs). This tightens the logic to accurately reflect which principals contributed to verification.AI Usage
request.
pull request. I have described my use of AI below.
Contributor Checklist
request.
applicable.
Signoff.
Conduct.