Skip to content

Commit 200777e

Browse files
committed
implement signature verification in case of tool install with URL
The endpoint affected is `/v2/pkgs/tools/installed`. If the signature is invalid the endpoint returns 500 with "rsa verification error" If the signature is not present we try to install the tool using "name, version, packager" arguments
1 parent da360fc commit 200777e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

v2/pkgs/tools.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,16 @@ func (c *Tools) Installed(ctx context.Context) (tools.ToolCollection, error) {
136136
func (c *Tools) Install(ctx context.Context, payload *tools.ToolPayload) (*tools.Operation, error) {
137137
path := filepath.Join(payload.Packager, payload.Name, payload.Version)
138138

139-
if payload.URL != nil {
139+
//if URL is defined and is signed we verify the signature and override the name, payload, version parameters
140+
if payload.URL != nil && payload.Signature != nil && payload.Checksum != nil {
141+
err := utilities.VerifyInput(*payload.URL, *payload.Signature)
142+
if err != nil {
143+
return nil, err
144+
}
140145
return c.install(ctx, path, *payload.URL, *payload.Checksum)
141146
}
142147

148+
// otherwise we install from the loaded indexes
143149
list, err := c.Indexes.List(ctx)
144150
if err != nil {
145151
return nil, err

0 commit comments

Comments
 (0)