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: blob inspect command #1133

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

JeyJeyGao
Copy link
Contributor

@JeyJeyGao JeyJeyGao commented Jan 2, 2025

Feat:

  • added notation blob inspect command

Refactor:

  • added Signature struct to share between OCI inspect and blob inspect commands
  • added ioutil.Time and ioutil.Timestamp wrapper types for formatting time when print text and marshal JSON

Test:

  • added E2E and unit test

Output example:

/home/jj/download/LICENSE.jws.sig
├── signature algorithm: RSASSA-PSS-SHA-256
├── signature envelope type: application/jose+json
├── signed attributes
│   ├── signingScheme: notary.x509
│   └── signingTime: Tue Dec 31 08:05:29 2024
├── user defined attributes
│   └── (empty)
├── unsigned attributes
│   ├── signingAgent: notation-go/1.3.0+unreleased
│   └── timestamp signature
│       ├── timestamp: [Tue Dec 31 08:05:29 2024, Tue Dec 31 08:05:30 2024]
│       └── certificates
│           ├── SHA256 fingerprint: 36e731cfa9bfd69dafb643809f6dec500902f7197daeaad86ea0159a2268a2b8
│           │   ├── issued to: CN=Microsoft Public RSA Timestamping CA 2020,O=Microsoft Corporation,C=US
│           │   ├── issued by: CN=Microsoft Identity Verification Root Certificate Authority 2020,O=Microsoft Corporation,C=US
│           │   └── expiry: Mon Nov 19 20:42:31 2035
│           └── SHA256 fingerprint: 93db2732c49e2624cf0a5cc03ad04acc0927fcaf5e7afdd4a3e23b6fc196aedc
│               ├── issued to: CN=Microsoft Public RSA Time Stamping Authority,OU=Microsoft America Operations+OU=nShield TSS ESN:7800-05E0-D947,O=Microsoft Corporation,L=Redmond,ST=Washington,C=US
│               ├── issued by: CN=Microsoft Public RSA Timestamping CA 2020,O=Microsoft Corporation,C=US
│               └── expiry: Sat Feb 15 20:36:12 2025
├── certificates
│   └── SHA256 fingerprint: dadee19c843e94b94daae9854d0de7ad93642b6075e2d1523b860b1770b64a03
│       ├── issued to: CN=testcert2,O=Notary,L=Seattle,ST=WA,C=US
│       ├── issued by: CN=testcert2,O=Notary,L=Seattle,ST=WA,C=US
│       └── expiry: Wed Jan  1 08:04:39 2025
└── signed artifact
    ├── media type: application/octet-stream
    ├── digest: sha256:c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4
    └── size: 11357

Signed-off-by: Junjie Gao <[email protected]>
@JeyJeyGao JeyJeyGao changed the title fix: blob inspect command prototype feat: blob inspect command prototype Jan 2, 2025
Copy link

codecov bot commented Jan 2, 2025

Codecov Report

Attention: Patch coverage is 92.95775% with 15 lines in your changes missing coverage. Please review.

Project coverage is 73.97%. Comparing base (cd933da) to head (5e8d773).

Files with missing lines Patch % Lines
internal/envelope/signature.go 89.85% 10 Missing and 4 partials ⚠️
cmd/notation/inspect.go 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1133      +/-   ##
==========================================
+ Coverage   72.38%   73.97%   +1.58%     
==========================================
  Files          50       53       +3     
  Lines        3125     3181      +56     
==========================================
+ Hits         2262     2353      +91     
+ Misses        670      639      -31     
+ Partials      193      189       -4     

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

Signed-off-by: Junjie Gao <[email protected]>
Signed-off-by: Junjie Gao <[email protected]>
Signed-off-by: Junjie Gao <[email protected]>
Signed-off-by: Junjie Gao <[email protected]>
Signed-off-by: Junjie Gao <[email protected]>
Signed-off-by: Junjie Gao <[email protected]>
Signed-off-by: Junjie Gao <[email protected]>
Signed-off-by: Junjie Gao <[email protected]>
Signed-off-by: Junjie Gao <[email protected]>
Signed-off-by: Junjie Gao <[email protected]>
Signed-off-by: Junjie Gao <[email protected]>
@JeyJeyGao JeyJeyGao changed the title feat: blob inspect command prototype feat: blob inspect command Jan 8, 2025
@JeyJeyGao JeyJeyGao marked this pull request as ready for review January 8, 2025 06:15
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.

This PR should be reviewed and merged after PR: #1128

@JeyJeyGao JeyJeyGao requested a review from Two-Hearts January 14, 2025 09:24
@JeyJeyGao
Copy link
Contributor Author

This PR should be reviewed and merged after PR: #1128

Unblocked now.

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.

Let's discuss offline for the design first.

I'd like to refactor notation and adopt the same rendering model as oras.

func (parent *Node) AddPair(key string, value string) *Node {
return parent.Add(key + ": " + value)
func (parent *Node) AddPair(key string, value any) *Node {
return parent.Add(fmt.Sprintf("%s: %s", key, value))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return parent.Add(fmt.Sprintf("%s: %s", key, value))
return parent.Add(fmt.Sprintf("%s: %v", key, value))

@@ -53,7 +53,7 @@ func (root *Node) Print() {
}

func print(prefix string, itemMarker string, nextPrefix string, n *Node) {
fmt.Println(prefix + itemMarker + n.Value)
fmt.Printf("%s%s%s\n", prefix, itemMarker, n.Value)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
fmt.Printf("%s%s%s\n", prefix, itemMarker, n.Value)
fmt.Printf("%s%s%v\n", prefix, itemMarker, n.Value)

Long: `Inspect a signature associated with a blob.

Example - Inspect a signature:
notation inspect blob.cose.sig
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
notation inspect blob.cose.sig
notation blob inspect blob.cose.sig

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.

3 participants