Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update: Package verification refactoring #186

Merged
merged 51 commits into from
Nov 15, 2022

Conversation

patrickzheng200
Copy link
Contributor

@patrickzheng200 patrickzheng200 commented Nov 7, 2022

PR review order: This PR -> #200.

This PR refactors the verifier package. Files intended to be reviewed in this PR:

  1. Files in verifier folder except verifier/trustpolicy and verifier/truststore (they should already been reviewed in feat: Added trustpolicy and truststore packages under verification #192).
  2. internal/envelope
  3. notation.go, this is for logic change on only returning successful signature verification outcomes.

(This PR incorporates the refactored plugin and plugin/proto into the verifier package.)

This PR removes internal/mock_origin, internal/notation.go, and internal/registry, as they've been refactored in the previous PRs. internal/plugin is there for compile reason. After the refactoring of Sign (#200 ), internal/plugin shall be removed.

This PR does not change code related to Sign, so please skip the signature package for now. (Refactoring of signature package is inside #200)

Edit:
A brief summary after our multiple rounds of discussions:

  1. If verification succeeded, one and only one success outcome will be returned.
  2. If verification failed,
    a. if the total number of signatures associated with the artifact is larger than the user given MaxSignatureAttempts, errExceededMaxVerificationLimit will be returned.
    b. Otherwise, ErrorVerificationFailed will be returned.

Copy link
Contributor

@rgnote rgnote left a comment

Choose a reason for hiding this comment

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

Reviewed only half of the PR, but publishing comments. Will review the remaining files.

notation/errors.go Outdated Show resolved Hide resolved
notation/notation.go Outdated Show resolved Hide resolved
notation/notation.go Outdated Show resolved Hide resolved
notation/notation.go Outdated Show resolved Hide resolved
notation/notation.go Outdated Show resolved Hide resolved
notation/notation.go Outdated Show resolved Hide resolved
notation/notation.go Outdated Show resolved Hide resolved
notation/notation.go Outdated Show resolved Hide resolved
notation/notation.go Outdated Show resolved Hide resolved
Signed-off-by: Patrick Zheng <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Nov 8, 2022

Codecov Report

Merging #186 (024c85c) into main (fc5044e) will decrease coverage by 3.62%.
The diff coverage is 71.61%.

@@            Coverage Diff             @@
##             main     #186      +/-   ##
==========================================
- Coverage   77.34%   73.71%   -3.63%     
==========================================
  Files          33       27       -6     
  Lines        2189     1769     -420     
==========================================
- Hits         1693     1304     -389     
+ Misses        405      375      -30     
+ Partials       91       90       -1     
Impacted Files Coverage Δ
signature/signer.go 38.23% <ø> (ø)
notation.go 32.58% <40.00%> (-2.11%) ⬇️
verifier/helpers.go 62.92% <62.92%> (ø)
signature/plugin.go 73.43% <72.00%> (-5.82%) ⬇️
verifier/verifier.go 73.80% <73.80%> (ø)
verifier/trustpolicy/trustpolicy.go 95.06% <82.35%> (ø)
signature/envelope.go 100.00% <100.00%> (ø)
verifier/truststore/truststore.go 55.38% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Signed-off-by: Patrick Zheng <[email protected]>
Signed-off-by: Patrick Zheng <[email protected]>
@shizhMSFT
Copy link
Contributor

This PR will be split into several smaller PRs to be reviewed.

Signed-off-by: Patrick Zheng <[email protected]>
Signed-off-by: Patrick Zheng <[email protected]>
Signed-off-by: Patrick Zheng <[email protected]>
Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

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

In verifier_helpers.go, not all receiver functions (i.e. methods associated with structs) are indeed receiver functions. We can make it a "static function".

Meanwhile, I suggest moving all receiver functions of the verifier struct to verifier.go and all others to helper.go, and cleans up verifier_helpers.go.

internal/slice/slice.go Outdated Show resolved Hide resolved
internal/slice/slice.go Outdated Show resolved Hide resolved
notation.go Show resolved Hide resolved
verifier/trustpolicy/trustpolicy.go Outdated Show resolved Hide resolved
verifier/verifier.go Outdated Show resolved Hide resolved
Copy link
Contributor

@rgnote rgnote left a comment

Choose a reason for hiding this comment

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

Rest looks good to me

verifier/verifier.go Outdated Show resolved Hide resolved
verifier/verifier.go Show resolved Hide resolved
Signed-off-by: Patrick Zheng <[email protected]>
@patrickzheng200
Copy link
Contributor Author

In verifier_helpers.go, not all receiver functions (i.e. methods associated with structs) are indeed receiver functions. We can make it a "static function".

Meanwhile, I suggest moving all receiver functions of the verifier struct to verifier.go and all others to helper.go, and cleans up verifier_helpers.go.

Done.

notation.go Show resolved Hide resolved
Signed-off-by: Patrick Zheng <[email protected]>
notation.go Show resolved Hide resolved
verifier/helpers.go Show resolved Hide resolved
verifier/helpers.go Show resolved Hide resolved
verifier/helpers.go Show resolved Hide resolved
verifier/verifier.go Outdated Show resolved Hide resolved
verifier/verifier.go Outdated Show resolved Hide resolved
verifier/verifier.go Outdated Show resolved Hide resolved
verifier/verifier.go Outdated Show resolved Hide resolved
verifier/verifier.go Outdated Show resolved Hide resolved
verifier/verifier.go Outdated Show resolved Hide resolved
Signed-off-by: Patrick Zheng <[email protected]>
Signed-off-by: Patrick Zheng <[email protected]>
verifier/trustpolicy/trustpolicy_test.go Outdated Show resolved Hide resolved
verifier/helpers.go Outdated Show resolved Hide resolved
verifier/verifier.go Outdated Show resolved Hide resolved
verifier/verifier.go Show resolved Hide resolved
verifier/verifier.go Outdated Show resolved Hide resolved
verifier/verifier.go Outdated Show resolved Hide resolved
verifier/verifier.go Outdated Show resolved Hide resolved
internal/slice/slice.go Outdated Show resolved Hide resolved
Signed-off-by: Patrick Zheng <[email protected]>
Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

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

LGTM

@yizha1
Copy link
Contributor

yizha1 commented Nov 15, 2022

As per discussion during community call and aligned with Vani, this PR can be merged with two approvals from one org. The leftover issue is tracked here #201.

Copy link
Contributor

@JeyJeyGao JeyJeyGao left a comment

Choose a reason for hiding this comment

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

LGTM

@patrickzheng200 patrickzheng200 merged commit e43b292 into notaryproject:main Nov 15, 2022
@patrickzheng200 patrickzheng200 deleted the refactor branch November 15, 2022 06:29
@patrickzheng200 patrickzheng200 linked an issue Nov 17, 2022 that may be closed by this pull request
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.

Using Verifier without a repository
8 participants