Skip to content

Commit 43d8b50

Browse files
committed
Add more comments
1 parent cc33da1 commit 43d8b50

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

extensionsign/sigmanifest.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ func (a SignatureManifest) String() string {
2323
return fmt.Sprintf("Package %q with Entries: %d", a.Package.Digests.SHA256, len(a.Entries))
2424
}
2525

26-
// Equal is helpful for debugging
26+
// Equal is helpful for debugging to know if two manifests are equal.
27+
// They can change if any file is removed/added/edited to an extension.
2728
func (a SignatureManifest) Equal(b SignatureManifest) error {
2829
var err error
2930
if err := a.Package.Equal(b.Package); err != nil {
@@ -82,7 +83,8 @@ type Digests struct {
8283
}
8384

8485
// GenerateSignatureManifest generates a signature manifest for a VSIX file.
85-
// It does not sign the manifest.
86+
// It does not sign the manifest. The manifest is the base64 encoded file path
87+
// followed by the sha256 hash of the file, and it's size.
8688
func GenerateSignatureManifest(vsixFile []byte) (SignatureManifest, error) {
8789
pkgManifest, err := FileManifest(bytes.NewReader(vsixFile))
8890
if err != nil {

extensionsign/sigzip.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ func ExtractSignatureManifest(zip []byte) (SignatureManifest, error) {
2828
}
2929

3030
// SignAndZipManifest signs a manifest and zips it up
31-
// Sign
3231
func SignAndZipManifest(secret crypto.Signer, manifest json.RawMessage) ([]byte, error) {
3332
var buf bytes.Buffer
3433
w := zip.NewWriter(&buf)

storage/signature.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"crypto"
66
"encoding/json"
7-
"fmt"
87
"io"
98
"io/fs"
109
"path/filepath"
@@ -76,16 +75,24 @@ func (s *Signature) Manifest(ctx context.Context, publisher, name string, versio
7675
return manifest, nil
7776
}
7877

78+
// Open will intercept requests for signed extensions payload.
79+
// It does this by looking for 'sigzipFilename' or p7s.sig.
80+
//
81+
// The signed payload and signing process is taken from:
82+
// https://github.com/filiptronicek/node-ovsx-sign
7983
func (s *Signature) Open(ctx context.Context, fp string) (fs.File, error) {
8084
if s.SigningEnabled() && filepath.Base(fp) == "p7s.sig" {
8185
// This file must exist, and it is always empty
8286
return mem.NewFileHandle(mem.CreateFile("p7s.sig")), nil
8387
}
88+
8489
if s.SigningEnabled() && filepath.Base(fp) == sigzipFilename {
8590
// hijack this request, sign the sig manifest
8691
manifest, err := s.Storage.Open(ctx, filepath.Join(filepath.Dir(fp), sigManifestName))
8792
if err != nil {
88-
fmt.Println(err)
93+
// If this file is missing, it means the extension was added before
94+
// signatures were handled by the marketplace.
95+
// TODO: Generate the sig manifest payload and insert it?
8996
return nil, xerrors.Errorf("open signature manifest: %w", err)
9097
}
9198
defer manifest.Close()

0 commit comments

Comments
 (0)