Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 28fc9d6

Browse files
authored
Enforce signature check on library_index.json (#2326)
1 parent 29c70df commit 28fc9d6

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

‎arduino/resources/index.go‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package resources
1717

1818
import (
1919
"context"
20+
"errors"
2021
"net/url"
2122
"path"
2223
"strings"
@@ -33,8 +34,9 @@ import (
3334

3435
// IndexResource is a reference to an index file URL with an optional signature.
3536
type IndexResource struct {
36-
URL *url.URL
37-
SignatureURL *url.URL
37+
URL *url.URL
38+
SignatureURL *url.URL
39+
EnforceSignatureVerification bool
3840
}
3941

4042
// IndexFileName returns the index file name as it is saved in data dir (package_xxx_index.json).
@@ -140,6 +142,10 @@ func (res *IndexResource) Download(destDir *paths.Path, downloadCB rpc.DownloadP
140142
} else if !valid {
141143
return &arduino.SignatureVerificationFailedError{File: res.URL.String()}
142144
}
145+
} else {
146+
if res.EnforceSignatureVerification {
147+
return &arduino.PermissionDeniedError{Message: tr("Error verifying signature"), Cause: errors.New(tr("missing signature"))}
148+
}
143149
}
144150

145151
// TODO: Implement a ResourceValidator

‎commands/instances.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,8 @@ func UpdateLibrariesIndex(ctx context.Context, req *rpc.UpdateLibrariesIndexRequ
511511
defer tmp.RemoveAll()
512512

513513
indexResource := resources.IndexResource{
514-
URL: librariesmanager.LibraryIndexWithSignatureArchiveURL,
514+
URL: librariesmanager.LibraryIndexWithSignatureArchiveURL,
515+
EnforceSignatureVerification: true,
515516
}
516517
if err := indexResource.Download(lm.IndexFile.Parent(), downloadCB); err != nil {
517518
return err

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /