Skip to content

Commit 6e6bd99

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 846e769 commit 6e6bd99

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

v2/pkgs/tools.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"strings"
3232

3333
"github.com/arduino/arduino-create-agent/gen/tools"
34+
"github.com/arduino/arduino-create-agent/utilities"
3435
"github.com/codeclysm/extract/v3"
3536
)
3637

@@ -135,10 +136,16 @@ func (c *Tools) Installed(ctx context.Context) (tools.ToolCollection, error) {
135136
func (c *Tools) Install(ctx context.Context, payload *tools.ToolPayload) (*tools.Operation, error) {
136137
path := filepath.Join(payload.Packager, payload.Name, payload.Version)
137138

138-
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+
}
139145
return c.install(ctx, path, *payload.URL, *payload.Checksum)
140146
}
141147

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

0 commit comments

Comments
 (0)