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

feat: add inspect blob commands #888

Closed

Conversation

rrsemlani
Copy link

Adding inspect blob commands.
Spec Pr used for ref: #811

cmd/notation/blob/inspect.go Outdated Show resolved Hide resolved
cmd/notation/internal/sharedutils/inspect.go Outdated Show resolved Hide resolved
cmd/notation/internal/sharedutils/inspect.go Outdated Show resolved Hide resolved
@priteshbandi
Copy link
Contributor

Also as per spec we have a new field called signature envelope type. Please add support for it in both oci and blob inspect command.

cmd/notation/blob/cmd.go Outdated Show resolved Hide resolved
cmd/notation/blob/cmd.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect.go Outdated Show resolved Hide resolved
@rrsemlani rrsemlani force-pushed the rsemlani_notation_inspect branch from 665c5f8 to 53d25cf Compare March 22, 2024 23:25
cmd/notation/blob/cmd.go Outdated Show resolved Hide resolved
cmd/notation/blob/cmd.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect_test.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect_test.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect_test.go Show resolved Hide resolved
cmd/notation/main.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect.go Outdated Show resolved Hide resolved
@rrsemlani rrsemlani force-pushed the rsemlani_notation_inspect branch from 53d25cf to 3272be7 Compare April 2, 2024 17:31
@rrsemlani rrsemlani force-pushed the rsemlani_notation_inspect branch from 3272be7 to 9788c7a Compare April 2, 2024 17:39
@rrsemlani rrsemlani force-pushed the rsemlani_notation_inspect branch from 9788c7a to 7e8dbe0 Compare April 3, 2024 21:55
Signed-off-by: Rishab Semlani <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Apr 4, 2024

Codecov Report

Attention: Patch coverage is 68.68132% with 57 lines in your changes missing coverage. Please review.

Project coverage is 71.05%. Comparing base (eaa5fb4) to head (3ee161f).
Report is 71 commits behind head on main.

Files Patch % Lines
cmd/notation/internal/outputs/inspect.go 70.53% 23 Missing and 10 partials ⚠️
cmd/notation/blob/inspect.go 47.50% 21 Missing ⚠️
cmd/notation/internal/osutil/read.go 86.66% 1 Missing and 1 partial ⚠️
cmd/notation/inspect.go 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #888      +/-   ##
==========================================
+ Coverage   64.93%   71.05%   +6.12%     
==========================================
  Files          45       49       +4     
  Lines        2729     2246     -483     
==========================================
- Hits         1772     1596     -176     
+ Misses        795      453     -342     
- Partials      162      197      +35     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Rishab Semlani <[email protected]>
internal/testdata/Output.txt Outdated Show resolved Hide resolved
cmd/notation/blob/inspect.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect_test.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect_test.go Outdated Show resolved Hide resolved
Signed-off-by: Rishab Semlani <[email protected]>
Signed-off-by: Rishab Semlani <[email protected]>
Signed-off-by: Rishab Semlani <[email protected]>
cmd/notation/blob/inspect.go Outdated Show resolved Hide resolved
cmd/notation/internal/osutil/read.go Outdated Show resolved Hide resolved
cmd/notation/internal/osutil/read.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect.go Show resolved Hide resolved
cmd/notation/blob/inspect_test.go Outdated Show resolved Hide resolved
cmd/notation/blob/inspect_test.go Outdated Show resolved Hide resolved
internal/testdata/LargeFile.txt Outdated Show resolved Hide resolved
Signed-off-by: Rishab Semlani <[email protected]>
Signed-off-by: Rishab Semlani <[email protected]>
Signed-off-by: Rishab Semlani <[email protected]>
Signed-off-by: Rishab Semlani <[email protected]>
Signed-off-by: Rishab Semlani <[email protected]>
Signed-off-by: Rishab Semlani <[email protected]>
cmd/notation/internal/osutil/read.go Outdated Show resolved Hide resolved
cmd/notation/internal/outputs/inspect.go Outdated Show resolved Hide resolved
}
}

func Signatures(mediaType string, digest string, output InspectOutput, sigFile []byte) (error, []SignatureOutput) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function is called Signatures and returning an array of SignatureOutput, so it seems to be processing multiple signatures. However, from its input sigFile []byte and logic sigEnvelope, err := signature.ParseEnvelope(mediaType, sigFile), it actually can only process one signature per call. Please make sure this is by design.

skippedSignatures := false
if err != nil {
logSkippedSignature(digest, err)
skippedSignatures = true
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you are return nil, nil right after this line, toggling this local bool seems redundant?


certListNode := sigNode.Add("certificates")
for _, cert := range signature.Certificates {
certNode := certListNode.AddPair("SHA256 fingerprint", cert.SHA256Fingerprint)
Copy link
Contributor

@Two-Hearts Two-Hearts May 30, 2024

Choose a reason for hiding this comment

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

I have a use case that the user would like to have an array of SHA256 fingerprints, starting from the leaf cert to the root cert, in the output. For example, if the SHA256 fingerprints for leaf is aaaaa, for intermediate 1 is bbbbb, for intermediate 2 is ccccc, and for root is ddddd. Then when I run notation blob inspect my_sig, I could get an array ["aaaaa", "bbbbb", "ccccc", "ddddd"] from the final output.
The current implementation does not support it, where I have to copy/paste/assemble such an array myself. Can we add a new field to the output to show the array?
/cc: @yizha1 @FeynmanZhou

Copy link
Contributor

Choose a reason for hiding this comment

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

Displaying duplicate information in CLI output is not recommended. Instead, users can opt to emit notation output in JSON format and utilize tools like jq to extract the desired text.

Copy link
Contributor

Choose a reason for hiding this comment

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

Displaying duplicate information in CLI output is not recommended. Instead, users can opt to emit notation output in JSON format and utilize tools like jq to extract the desired text.

Asking users to do a jq on the output is extra work though, where we could save this effort for them by adding a field in the output. @yizha1 for your comments please.

Copy link
Contributor

Choose a reason for hiding this comment

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

@priteshbandi Here is the scenario:

Users produce OCI signatures based on Notary Project specifications. When users attach signatures to OCI artifact in OCI registries, users need to add a specific annotation io.cncf.notary.x509chain.thumbprint#S256 per Notary Project OCI signature spec. It is not easy for users to 1) generate the fingerprints, 2) figure out the order based on the spec.

As blob inspect has all these information, so it will improve the user experience to get ordered x509 chain thumbprints in an easy way, and help more users to adopt Notary Project spec. So, my suggestion would be blob inspect to support output certificate SHA256 fingerprints with a new field under current certificates, for example

certificate SHA256 fingerprints: ["leaf-sha256-fingerprint","intermediate-sha256-fingerprint","root-sha256-fingerprint"]

This will not block this PR, if you agree, we can create a new issue to track this work. It will be a simple work, but save a big effort for our users.

Copy link
Contributor

@Two-Hearts Two-Hearts left a comment

Choose a reason for hiding this comment

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

Please add corresponding E2E test cases for blob inspect command under test/e2e.

@shizhMSFT shizhMSFT changed the title Adding inspect blob commands feat: add inspect blob commands Jun 4, 2024
Copy link

This PR is stale because it has been opened for 45 days with no activity. Remove stale label or comment. Otherwise, it will be closed in 30 days.

@github-actions github-actions bot added Stale and removed Stale labels Aug 12, 2024
Copy link

This PR is stale because it has been opened for 45 days with no activity. Remove stale label or comment. Otherwise, it will be closed in 30 days.

@github-actions github-actions bot added the Stale label Oct 20, 2024
Copy link

PR closed due to no activity in the past 30 days.

@github-actions github-actions bot closed this Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants