Skip to content

Commit a52f2b2

Browse files
committed
return empty signature manifest
1 parent 9c387e0 commit a52f2b2

File tree

4 files changed

+6
-67
lines changed

4 files changed

+6
-67
lines changed

extensionsign/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
// Package extensionsign is a Go implementation of https://github.com/filiptronicek/node-ovsx-sign
1+
// Package extensionsign provides utilities for working with extension signatures.
22
package extensionsign

extensionsign/key.go

Lines changed: 0 additions & 14 deletions
This file was deleted.

extensionsign/sigzip.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func ExtractSignatureManifest(zip []byte) (SignatureManifest, error) {
2525
return manifest, nil
2626
}
2727

28-
func IncludeEmptySignature(manifest json.RawMessage) ([]byte, error) {
28+
func IncludeEmptySignature() ([]byte, error) {
2929
var buf bytes.Buffer
3030
w := zip.NewWriter(&buf)
3131

@@ -34,7 +34,7 @@ func IncludeEmptySignature(manifest json.RawMessage) ([]byte, error) {
3434
return nil, xerrors.Errorf("create manifest: %w", err)
3535
}
3636

37-
_, err = manFile.Write(manifest)
37+
_, err = manFile.Write([]byte{})
3838
if err != nil {
3939
return nil, xerrors.Errorf("write manifest: %w", err)
4040
}

storage/signature.go

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package storage
22

33
import (
44
"context"
5-
"encoding/json"
6-
"io"
75
"io/fs"
86
"path/filepath"
97
"strings"
@@ -49,26 +47,6 @@ func (s *Signature) SigningEnabled() bool {
4947
return s.IncludeEmptySignatures
5048
}
5149

52-
// AddExtension includes the signature manifest of the vsix. Signing happens on
53-
// demand, so leave the manifest unsigned. This is safe to do even if
54-
// 'signExtensions' is disabled, as these files lay dormant until signed.
55-
func (s *Signature) AddExtension(ctx context.Context, manifest *VSIXManifest, vsix []byte, extra ...File) (string, error) {
56-
sigManifest, err := extensionsign.GenerateSignatureManifest(vsix)
57-
if err != nil {
58-
return "", xerrors.Errorf("generate signature manifest: %w", err)
59-
}
60-
61-
sigManifestJSON, err := json.Marshal(sigManifest)
62-
if err != nil {
63-
return "", xerrors.Errorf("encode signature manifest: %w", err)
64-
}
65-
66-
return s.Storage.AddExtension(ctx, manifest, vsix, append(extra, File{
67-
RelativePath: sigManifestName,
68-
Content: sigManifestJSON,
69-
})...)
70-
}
71-
7250
func (s *Signature) Manifest(ctx context.Context, publisher, name string, version Version) (*VSIXManifest, error) {
7351
manifest, err := s.Storage.Manifest(ctx, publisher, name, version)
7452
if err != nil {
@@ -95,8 +73,7 @@ func (s *Signature) Manifest(ctx context.Context, publisher, name string, versio
9573
// Open will intercept requests for signed extensions payload.
9674
// It does this by looking for 'SigzipFileExtension' or p7s.sig.
9775
//
98-
// The signed payload and signing process is taken from:
99-
// https://github.com/filiptronicek/node-ovsx-sign
76+
// The signed payload is completely empty. Nothing it actually signed.
10077
//
10178
// Some notes:
10279
//
@@ -110,22 +87,8 @@ func (s *Signature) Manifest(ctx context.Context, publisher, name string, versio
11087
// will not work.
11188
func (s *Signature) Open(ctx context.Context, fp string) (fs.File, error) {
11289
if s.SigningEnabled() && strings.HasSuffix(filepath.Base(fp), SigzipFileExtension) {
113-
// hijack this request, sign the sig manifest
114-
manifest, err := s.Storage.Open(ctx, filepath.Join(filepath.Dir(fp), sigManifestName))
115-
if err != nil {
116-
// If this file is missing, it means the extension was added before
117-
// signatures were handled by the marketplace.
118-
// TODO: Generate the sig manifest payload and insert it?
119-
return nil, xerrors.Errorf("open signature manifest: %w", err)
120-
}
121-
defer manifest.Close()
122-
123-
manifestData, err := io.ReadAll(manifest)
124-
if err != nil {
125-
return nil, xerrors.Errorf("read signature manifest: %w", err)
126-
}
127-
128-
signed, err := s.SigZip(ctx, manifestData)
90+
// hijack this request, return an empty signature payload
91+
signed, err := extensionsign.IncludeEmptySignature()
12992
if err != nil {
13093
return nil, xerrors.Errorf("sign and zip manifest: %w", err)
13194
}
@@ -137,13 +100,3 @@ func (s *Signature) Open(ctx context.Context, fp string) (fs.File, error) {
137100

138101
return s.Storage.Open(ctx, fp)
139102
}
140-
141-
// SigZip currently just returns an empty signature.
142-
func (s *Signature) SigZip(ctx context.Context, sigManifest []byte) ([]byte, error) {
143-
signed, err := extensionsign.IncludeEmptySignature(sigManifest)
144-
if err != nil {
145-
s.Logger.Error(ctx, "signing manifest", slog.Error(err))
146-
return nil, xerrors.Errorf("sign and zip manifest: %w", err)
147-
}
148-
return signed, nil
149-
}

0 commit comments

Comments
 (0)