update: a file from usemagpie.ai has its attestation from usemagpie.ai, GitHub's API after (ArcticLampyrid on X)
The site's cron keeps each release's SLSA bundles on R2 as /files/<tag>/attestations.jsonl (728f3de40,5e51e241c), but the updater still asked api.github.com for every file, 60 an hour unsigned, and with Update source set to the site alone it never checked an attestation at all. attestation() now takes the asset. A file the feed names on the site (Site/files/<tag>/<file>) has its release's bundles read from the same site first; GitHub's API is asked as before when the site misses: a pruned tag's 302 to GitHub's release (not followed; that asset doesn't exist), any other status, a body with no bundle, or the site unreachable. The trust model is unchanged. The site is only transport: its bundles go through the same verifyBundle (embedded Sigstore root, release.yml of yetone/magpie-releases, the digest from the ed25519-signed SHA256SUMS). A site bundle that fails sends the updater to GitHub's API, where a valid bundle holds; if that API can't be read it is a refusal, not unknown, so a tampered mirror plus a blocked GitHub can't go through as "unattested". Update source "site alone": the site's bundles are checked, GitHub never asked; a miss is unknown as before. Update source "GitHub": the API alone. docs/reference.md and the start page (en, zh, ja) say so; no docs/subsystems page covers updates. llms-full.txt regenerated. Run (mote): - go test -count=1 ./internal/update/ ok; go vet darwin, GOOS=linux -tags nogui, GOOS=windows ok; gofmt -l clean. - node --test site/*.test.mjs 120/120. - New tests (attest_site_test.go, fixture = the site's real v0.1.3986/attestations.jsonl): the site serves it and GitHub isn't asked; site-alone source attested; another digest refused; misses (302, 404, 502, html, empty, cut mid-line, site down) go to GitHub; site-alone miss stays unknown; a tampered site bundle refused with GitHub 403/503/404 and with site-alone, and passes on GitHub's valid bundle; wrong identity refused; GitHub source and github.com files never ask the site. No test reaches the network (TestMain points the site at 127.0.0.1:1). - Broken by hand, each red: never asking the site (4 tests), taking a site bundle unchecked (3), following the redirect (1), a failing site bundle plus unreadable GitHub kept unknown (2). - Live once (a throwaway test, not committed): usemagpie.ai's real v0.1.3986 bundles attested magpie-cli-android-arm64 with the API pointed at a dead address; pruned v0.1.3985 (302) fell back to api.github.com and attested. Not tried: a full app update from the site end to end; Windows and Linux runs of the package (the change is OS-independent).
This commit is contained in:
+18
-6
@@ -3425,9 +3425,10 @@ From v0.1.3891 the release workflow also attests every file with
|
||||
`actions/attest-build-provenance` (a SLSA provenance statement signed through
|
||||
Sigstore with the run's GitHub identity). Before downloading a file of such a
|
||||
release, the updater (`internal/update/attest.go`, sigstore-go) fetches the
|
||||
bundle for the file's signed SHA-256 from
|
||||
`api.github.com/repos/yetone/magpie-releases/attestations/sha256:<digest>` and
|
||||
checks it offline against the Sigstore trusted root embedded in the binary
|
||||
bundles for the file's signed SHA-256 (from the site's copy first when the file
|
||||
comes from the site, below, else from
|
||||
`api.github.com/repos/yetone/magpie-releases/attestations/sha256:<digest>`) and
|
||||
checks them offline against the Sigstore trusted root embedded in the binary
|
||||
(`attest_root.json`, public-good instance): certificate chain, certificate
|
||||
timestamp, Rekor entry, issuer `token.actions.githubusercontent.com`, subject
|
||||
`release.yml` of `yetone/magpie-releases` on `main` or a `v*` tag, source
|
||||
@@ -3435,7 +3436,7 @@ repository `yetone/magpie-releases`, and the digest among the statement's
|
||||
subjects. This is in addition to the ed25519 check, never instead of it. A
|
||||
bundle that fails, or GitHub saying it has none (404, empty list), refuses the
|
||||
file. Anything that leaves it unknown (GitHub unreachable, rate limited, 5xx,
|
||||
not JSON, *Update source* set to the site alone) does not stop the update,
|
||||
not JSON, *Update source* set to the site alone and the site has none) does not stop the update,
|
||||
since the signature has held; the log says the file went unattested. A
|
||||
`MAGPIE_UPDATE_FEED` of your own skips it. The embedded root must be renewed
|
||||
(`gh attestation trusted-root`, first line) when Sigstore rotates its public
|
||||
@@ -3447,8 +3448,19 @@ once every file has one, writes `<tag>/attestations.jsonl` (a bundle to a line),
|
||||
served at `https://usemagpie.ai/files/<tag>/attestations.jsonl` and checked with
|
||||
`gh attestation verify <file> -R yetone/magpie-releases --bundle
|
||||
attestations.jsonl`. It is not a release asset (the release's count is
|
||||
unchanged), is written only whole, and is pruned with its tag. The updater does
|
||||
not read it yet; it still asks GitHub's API (ArcticLampyrid on X).
|
||||
unchanged), is written only whole, and is pruned with its tag.
|
||||
|
||||
The updater reads it for a file the feed names on the site
|
||||
(`https://usemagpie.ai/files/<tag>/<file>`), before asking GitHub's API
|
||||
(ArcticLampyrid on X). The site is only transport: its bundles go through the
|
||||
same check (embedded root, identity, the signed digest), so it can't make a bad
|
||||
one pass. A miss (a pruned tag's 302 to GitHub, which is not followed; any
|
||||
other status; no bundle in the body; the site unreachable) asks GitHub's API as
|
||||
before. A bundle from the site that fails asks GitHub's API too, and a valid one
|
||||
there holds; when that API can't be read, it is a refusal, not unknown. With
|
||||
*Update source* set to the site alone, the site's bundles are checked and
|
||||
GitHub is never asked: a miss is unknown, a failing bundle a refusal. With it
|
||||
set to GitHub, the file and its bundles come from GitHub alone.
|
||||
|
||||
The feed hands the app that `SHA256SUMS` and signature (`signed`). The app
|
||||
checks the signature against its key, takes every file's SHA-256 from the
|
||||
|
||||
+113
-9
@@ -1,6 +1,7 @@
|
||||
package update
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
_ "embed"
|
||||
"encoding/hex"
|
||||
@@ -10,6 +11,7 @@ import (
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
@@ -64,6 +66,23 @@ import (
|
||||
//
|
||||
// Someone who can only drop the API call downgrades an update to the
|
||||
// ed25519 check, never below it.
|
||||
//
|
||||
// Where the bundles come from (ArcticLampyrid on X): a file the feed names
|
||||
// on the site (usemagpie.ai/files/<tag>/<file>, a copy on R2) has its
|
||||
// release's bundles asked of the same place first,
|
||||
// /files/<tag>/attestations.jsonl, a bundle to a line, which the site's
|
||||
// cron copies from this API (site/files.js). The site is only transport:
|
||||
// its bundles go through the same verifyBundle, against the same embedded
|
||||
// root, identity and signed digest, so it can't make a bad one pass.
|
||||
// - The site has none (a tag pruned from R2 redirects to GitHub, whose
|
||||
// release has no such asset; a redirect is not followed), can't be
|
||||
// reached, or sends no bundle: a miss, and the API is asked as before.
|
||||
// - The site's bundles fail: the API is asked too, and a valid bundle
|
||||
// there is enough. When the API can't be read, or Settings' update
|
||||
// source is the site alone, that is a refusal, not unknown: a bundle
|
||||
// was had and failed.
|
||||
// - Settings' update source is GitHub: the file comes from github.com,
|
||||
// and so do its bundles, from the API alone.
|
||||
|
||||
// firstAttested is the first release whose files carry an attestation
|
||||
// (yetone/magpie-releases 9213fbd).
|
||||
@@ -78,6 +97,14 @@ var attestRootJSON []byte
|
||||
// attestAPI is the address of the attestation API; a var for tests.
|
||||
var attestAPI = "https://api.github.com"
|
||||
|
||||
// attestSite is where a file the feed names on Site has its release's
|
||||
// bundles asked first; a var for tests.
|
||||
var attestSite = Site
|
||||
|
||||
// siteBundles is the name of a release's bundles on the site
|
||||
// (site/files.js BUNDLES).
|
||||
const siteBundles = "attestations.jsonl"
|
||||
|
||||
// attestID is the identity a bundle must show; a var for tests.
|
||||
var attestID = struct{ SAN, Issuer, Repo string }{
|
||||
SAN: `^https://github\.com/` + regexp.QuoteMeta(attestRepo) + `/\.github/workflows/release\.yml@refs/(heads/main|tags/v[0-9A-Za-z.+-]+)$`,
|
||||
@@ -102,7 +129,7 @@ func attestedFile(ctx context.Context, a Asset, name string) error {
|
||||
if !a.attest {
|
||||
return nil
|
||||
}
|
||||
err := attestation(ctx, a.SHA256)
|
||||
err := attestation(ctx, a)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -114,28 +141,105 @@ func attestedFile(ctx context.Context, a Asset, name string) error {
|
||||
return fmt.Errorf("%s: %w; not installed", name, err)
|
||||
}
|
||||
|
||||
func attestation(ctx context.Context, digest string) error {
|
||||
func attestation(ctx context.Context, a Asset) error {
|
||||
if os.Getenv("MAGPIE_UPDATE_FEED") != "" {
|
||||
return nil
|
||||
}
|
||||
if Source() == settings.UpdateSourceSite {
|
||||
return errUnknown{errors.New("Settings' update source is the site alone, which never asks GitHub")}
|
||||
}
|
||||
sum, err := hex.DecodeString(digest)
|
||||
sum, err := hex.DecodeString(a.SHA256)
|
||||
if err != nil || len(sum) != 32 {
|
||||
return fmt.Errorf("%w: the checksum %q is not a SHA-256", errUnattested, digest)
|
||||
return fmt.Errorf("%w: the checksum %q is not a SHA-256", errUnattested, a.SHA256)
|
||||
}
|
||||
raws, err := fetchAttestations(ctx, strings.ToLower(digest))
|
||||
// the site's copy of the release's bundles, when the file comes from it
|
||||
var siteErr error
|
||||
if u := siteBundlesURL(a); u != "" {
|
||||
if raws := fetchSiteBundles(ctx, u); len(raws) > 0 {
|
||||
if siteErr = verifyAny(raws, sum); siteErr == nil {
|
||||
return nil
|
||||
}
|
||||
siteErr = fmt.Errorf("the bundles from %s fail: %v", hostOf(u), siteErr)
|
||||
}
|
||||
}
|
||||
if Source() == settings.UpdateSourceSite {
|
||||
if siteErr != nil {
|
||||
return fmt.Errorf("%w: %v", errUnattested, siteErr)
|
||||
}
|
||||
return errUnknown{errors.New("Settings' update source is the site alone, which never asks GitHub, and the site has no bundles for it")}
|
||||
}
|
||||
raws, err := fetchAttestations(ctx, strings.ToLower(a.SHA256))
|
||||
if err != nil {
|
||||
var u errUnknown
|
||||
if siteErr != nil && errors.As(err, &u) {
|
||||
return fmt.Errorf("%w: %v, and GitHub's couldn't be read (%v)", errUnattested, siteErr, u.err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
if last := verifyAny(raws, sum); last != nil {
|
||||
return fmt.Errorf("%w: %v", errUnattested, last)
|
||||
}
|
||||
if siteErr != nil {
|
||||
log.Printf("update: %s; GitHub's held", siteErr)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// verifyAny is nil when one of raws attests sum, else the last failure.
|
||||
func verifyAny(raws []json.RawMessage, sum []byte) error {
|
||||
var last error
|
||||
for _, raw := range raws {
|
||||
if last = verifyBundle(raw, sum); last == nil {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("%w: %v", errUnattested, last)
|
||||
return last
|
||||
}
|
||||
|
||||
// siteBundlesURL is the address of the bundles of a's release on the site,
|
||||
// "" when a isn't downloaded from there.
|
||||
func siteBundlesURL(a Asset) string {
|
||||
if Source() == settings.UpdateSourceGitHub {
|
||||
return ""
|
||||
}
|
||||
rest, ok := strings.CutPrefix(a.URL, Site+"/files/")
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
tag, _, ok := strings.Cut(rest, "/")
|
||||
if !ok || tag == "" {
|
||||
return ""
|
||||
}
|
||||
return attestSite + "/files/" + url.PathEscape(tag) + "/" + siteBundles
|
||||
}
|
||||
|
||||
// fetchSiteBundles reads the site's attestations.jsonl at u, nil on any
|
||||
// miss. A tag the site no longer keeps is a redirect to GitHub's release,
|
||||
// which has no such file; it is not followed, and the API is asked instead.
|
||||
func fetchSiteBundles(ctx context.Context, u string) []json.RawMessage {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", u, nil)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
c := *client
|
||||
c.CheckRedirect = func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }
|
||||
res, err := c.Do(req)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode != http.StatusOK {
|
||||
return nil
|
||||
}
|
||||
body, err := io.ReadAll(io.LimitReader(res.Body, 4<<20))
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
var raws []json.RawMessage
|
||||
for _, line := range bytes.Split(body, []byte("\n")) {
|
||||
line = bytes.TrimSpace(line)
|
||||
if len(line) > 0 && line[0] == '{' && json.Valid(line) {
|
||||
raws = append(raws, json.RawMessage(line))
|
||||
}
|
||||
}
|
||||
return raws
|
||||
}
|
||||
|
||||
// fetchAttestations asks GitHub for the bundles attesting digest. The
|
||||
|
||||
@@ -0,0 +1,267 @@
|
||||
package update
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/settings"
|
||||
)
|
||||
|
||||
// The fixture is usemagpie.ai/files/v0.1.3986/attestations.jsonl as the
|
||||
// site served it on 2026-11-13, byte for byte: one bundle whose statement
|
||||
// names all 17 files of the release.
|
||||
const (
|
||||
siteTag = "v0.1.3986"
|
||||
siteDigest = "55036e99a685f7ffa844124a4f5ded0a2dc8bc93edeb6b3b5449eb520d8ff1ed" // magpie-cli-android-arm64
|
||||
)
|
||||
|
||||
func siteFixture(t *testing.T) []byte {
|
||||
t.Helper()
|
||||
b, err := os.ReadFile(filepath.Join("testdata", "attest", "attestations-"+siteTag+".jsonl"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// siteAsset is a file the feed names on the site, as the feed gives it.
|
||||
func siteAsset(digest string) Asset {
|
||||
return Asset{URL: Site + "/files/" + siteTag + "/magpie-cli-android-arm64", SHA256: digest, attest: true}
|
||||
}
|
||||
|
||||
// siteServer stands in for usemagpie.ai's /files/<tag>/attestations.jsonl:
|
||||
// it answers with handler, counts the asks and points the updater at it.
|
||||
func siteServer(t *testing.T, handler http.HandlerFunc) *int32 {
|
||||
t.Helper()
|
||||
var asks int32
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
atomic.AddInt32(&asks, 1)
|
||||
if r.URL.Path != "/files/"+siteTag+"/attestations.jsonl" {
|
||||
t.Errorf("asked the site for %s", r.URL.Path)
|
||||
}
|
||||
handler(w, r)
|
||||
}))
|
||||
t.Cleanup(srv.Close)
|
||||
old := attestSite
|
||||
attestSite = srv.URL
|
||||
t.Cleanup(func() { attestSite = old })
|
||||
return &asks
|
||||
}
|
||||
|
||||
func serves(body []byte) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) { w.Write(body) }
|
||||
}
|
||||
|
||||
func withSource(t *testing.T, src string) {
|
||||
t.Helper()
|
||||
before := settings.Load()
|
||||
s := before
|
||||
s.UpdateSource = src
|
||||
if err := settings.Save(s); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { settings.Save(before) })
|
||||
}
|
||||
|
||||
// tamperedLines flips one byte of the signature of every bundle in jsonl.
|
||||
func tamperedLines(t *testing.T, jsonl []byte) []byte {
|
||||
t.Helper()
|
||||
var out [][]byte
|
||||
for _, line := range bytes.Split(bytes.TrimSpace(jsonl), []byte("\n")) {
|
||||
var b map[string]any
|
||||
if err := json.Unmarshal(line, &b); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sig := b["dsseEnvelope"].(map[string]any)["signatures"].([]any)[0].(map[string]any)
|
||||
s := sig["sig"].(string)
|
||||
flip := byte('A')
|
||||
if s[10] == 'A' {
|
||||
flip = 'B'
|
||||
}
|
||||
sig["sig"] = s[:10] + string(flip) + s[11:]
|
||||
l, _ := json.Marshal(b)
|
||||
out = append(out, l)
|
||||
}
|
||||
return append(bytes.Join(out, []byte("\n")), '\n')
|
||||
}
|
||||
|
||||
// A file from the site has its bundles from the site: GitHub's API isn't
|
||||
// asked, and the check is the same one (root, identity, digest).
|
||||
func TestAttestationFromTheSite(t *testing.T) {
|
||||
gh := attestServer(t, 404, nil)
|
||||
site := siteServer(t, serves(siteFixture(t)))
|
||||
if err := attestedFile(context.Background(), siteAsset(siteDigest), "magpie-cli-android-arm64"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if n := atomic.LoadInt32(site); n != 1 {
|
||||
t.Fatalf("asked the site %d times", n)
|
||||
}
|
||||
if n := atomic.LoadInt32(gh); n != 0 {
|
||||
t.Fatalf("asked GitHub %d times", n)
|
||||
}
|
||||
// Settings' update source the site alone: attested now, where it was
|
||||
// unknown before
|
||||
withSource(t, settings.UpdateSourceSite)
|
||||
buf := logged(t)
|
||||
if err := attestation(context.Background(), siteAsset(siteDigest)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if buf.Len() != 0 || atomic.LoadInt32(gh) != 0 {
|
||||
t.Fatalf("log %q, GitHub asked %d", buf.String(), *gh)
|
||||
}
|
||||
}
|
||||
|
||||
// The site's bundles attest other bytes: refused, as GitHub's would be.
|
||||
func TestAttestationFromTheSiteOfAnotherDigestRefused(t *testing.T) {
|
||||
attestServer(t, 404, nil)
|
||||
siteServer(t, serves(siteFixture(t)))
|
||||
if err := attestation(context.Background(), siteAsset(otherDigest)); !errors.Is(err, errUnattested) {
|
||||
t.Fatalf("got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// The site has no bundles for the tag: GitHub's API is asked, as before.
|
||||
// A tag pruned from R2 is a 302 to GitHub's release, which has no such
|
||||
// asset; the redirect is not followed.
|
||||
func TestAttestationSiteMissGoesToGitHub(t *testing.T) {
|
||||
var followed int32
|
||||
gone := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
atomic.AddInt32(&followed, 1)
|
||||
http.NotFound(w, r)
|
||||
}))
|
||||
defer gone.Close()
|
||||
for name, h := range map[string]http.HandlerFunc{
|
||||
"pruned, 302 to GitHub": func(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, gone.URL+"/yetone/magpie-releases/releases/download/"+siteTag+"/attestations.jsonl", http.StatusFound)
|
||||
},
|
||||
"404": func(w http.ResponseWriter, r *http.Request) { http.NotFound(w, r) },
|
||||
"502": func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(502) },
|
||||
"html": serves([]byte("<html>captive portal</html>")),
|
||||
"empty": serves(nil),
|
||||
"cut mid-line": serves(siteFixture(t)[:5000]),
|
||||
} {
|
||||
gh := attestServer(t, 200, attestFixture(t))
|
||||
site := siteServer(t, h)
|
||||
a := siteAsset(attestedSums)
|
||||
if err := attestedFile(context.Background(), a, "f"); err != nil {
|
||||
t.Errorf("%s: %v", name, err)
|
||||
}
|
||||
if atomic.LoadInt32(site) != 1 || atomic.LoadInt32(gh) != 1 {
|
||||
t.Errorf("%s: site asked %d, GitHub %d", name, *site, *gh)
|
||||
}
|
||||
}
|
||||
// nothing listening at the site
|
||||
gh := attestServer(t, 200, attestFixture(t))
|
||||
srv := httptest.NewServer(http.NotFoundHandler())
|
||||
attestSite = srv.URL
|
||||
srv.Close()
|
||||
if err := attestation(context.Background(), siteAsset(attestedSums)); err != nil || atomic.LoadInt32(gh) != 1 {
|
||||
t.Fatalf("site down: %v, GitHub asked %d", err, *gh)
|
||||
}
|
||||
if n := atomic.LoadInt32(&followed); n != 0 {
|
||||
t.Fatalf("the redirect was followed %d times", n)
|
||||
}
|
||||
}
|
||||
|
||||
// A miss at the site with Settings' update source the site alone is
|
||||
// unknown, as it was: GitHub is never asked.
|
||||
func TestAttestationSiteMissSiteAloneUnknown(t *testing.T) {
|
||||
gh := attestServer(t, 200, attestFixture(t))
|
||||
siteServer(t, func(w http.ResponseWriter, r *http.Request) { http.NotFound(w, r) })
|
||||
withSource(t, settings.UpdateSourceSite)
|
||||
var u errUnknown
|
||||
if err := attestation(context.Background(), siteAsset(siteDigest)); !errors.As(err, &u) {
|
||||
t.Fatalf("got %v", err)
|
||||
}
|
||||
if n := atomic.LoadInt32(gh); n != 0 {
|
||||
t.Fatalf("asked GitHub %d times", n)
|
||||
}
|
||||
}
|
||||
|
||||
// A tampered bundle from the site is never taken. GitHub's API is asked;
|
||||
// when it can't be read, or is not to be asked, that is a refusal, not
|
||||
// unknown; when it has a valid bundle, that one holds (the site is only
|
||||
// transport).
|
||||
func TestAttestationSiteTamperedRefused(t *testing.T) {
|
||||
bad := tamperedLines(t, siteFixture(t))
|
||||
for name, c := range map[string]struct {
|
||||
code int
|
||||
body []byte
|
||||
src string
|
||||
}{
|
||||
"GitHub rate limited": {403, []byte(`{"message":"API rate limit exceeded"}`), ""},
|
||||
"GitHub 503": {503, nil, ""},
|
||||
"GitHub has none": {404, nil, ""},
|
||||
"site alone": {200, attestFixture(t), settings.UpdateSourceSite},
|
||||
} {
|
||||
attestServer(t, c.code, c.body)
|
||||
siteServer(t, serves(bad))
|
||||
withSource(t, c.src)
|
||||
err := attestedFile(context.Background(), siteAsset(siteDigest), "magpie-cli-android-arm64")
|
||||
if !errors.Is(err, errUnattested) || !strings.Contains(err.Error(), "not installed") {
|
||||
t.Errorf("%s: got %v", name, err)
|
||||
}
|
||||
}
|
||||
withSource(t, "")
|
||||
// GitHub's own valid bundle for these bytes (v0.1.3925's SHA256SUMS)
|
||||
attestServer(t, 200, attestFixture(t))
|
||||
siteServer(t, serves(tamperedLines(t, siteFixture(t))))
|
||||
buf := logged(t)
|
||||
if err := attestation(context.Background(), siteAsset(attestedSums)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.Contains(buf.String(), "GitHub's held") {
|
||||
t.Fatalf("not said: %q", buf.String())
|
||||
}
|
||||
}
|
||||
|
||||
// The site's bundles must show the same identity as GitHub's.
|
||||
func TestAttestationFromTheSiteWrongIdentityRefused(t *testing.T) {
|
||||
attestServer(t, 503, nil)
|
||||
siteServer(t, serves(siteFixture(t)))
|
||||
old := attestID
|
||||
t.Cleanup(func() { attestID = old })
|
||||
attestID.SAN = `^https://github\.com/someone/else/\.github/workflows/release\.yml@refs/heads/main$`
|
||||
if err := attestation(context.Background(), siteAsset(siteDigest)); !errors.Is(err, errUnattested) {
|
||||
t.Fatalf("got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Only a file from the site has its bundles asked there: Settings' update
|
||||
// source GitHub downloads from github.com, and a file the feed names on
|
||||
// GitHub (the feed's fallback) is GitHub's.
|
||||
func TestAttestationSiteOnlyForTheSitesFiles(t *testing.T) {
|
||||
gh := attestServer(t, 200, attestFixture(t))
|
||||
site := siteServer(t, serves(siteFixture(t)))
|
||||
withSource(t, settings.UpdateSourceGitHub)
|
||||
if err := attestation(context.Background(), siteAsset(attestedSums)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
withSource(t, "")
|
||||
a := Asset{URL: githubWeb + "/" + releaseRepo + "/releases/download/" + siteTag + "/f", SHA256: attestedSums}
|
||||
if err := attestation(context.Background(), a); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if atomic.LoadInt32(site) != 0 || atomic.LoadInt32(gh) != 2 {
|
||||
t.Fatalf("site asked %d, GitHub %d", *site, *gh)
|
||||
}
|
||||
for u, want := range map[string]string{
|
||||
Site + "/files/v0.1.3986/magpie-darwin-arm64.zip": attestSite + "/files/v0.1.3986/attestations.jsonl",
|
||||
Site + "/files/v0.1.3986": "",
|
||||
Site + "/dl/v0.1.3986/f": "",
|
||||
"https://example.com/files/v0.1.3986/f": "",
|
||||
} {
|
||||
if got := siteBundlesURL(Asset{URL: u}); got != want {
|
||||
t.Errorf("%s: %q, want %q", u, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ func logged(t *testing.T) *bytes.Buffer {
|
||||
|
||||
func TestAttestationOfARealBundleHolds(t *testing.T) {
|
||||
attestServer(t, 200, attestFixture(t))
|
||||
if err := attestation(context.Background(), attestedSums); err != nil {
|
||||
if err := attestation(context.Background(), Asset{SHA256: attestedSums}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,7 @@ func TestAttestationOfARealBundleHolds(t *testing.T) {
|
||||
// outside them is not attested. A bundle that attests other bytes is not an attestation of this file.
|
||||
func TestAttestationOfAnotherDigestRefused(t *testing.T) {
|
||||
attestServer(t, 200, attestFixture(t))
|
||||
err := attestation(context.Background(), otherDigest)
|
||||
err := attestation(context.Background(), Asset{SHA256: otherDigest})
|
||||
if !errors.Is(err, errUnattested) {
|
||||
t.Fatalf("got %v", err)
|
||||
}
|
||||
@@ -94,7 +94,7 @@ func TestAttestationTamperedRefused(t *testing.T) {
|
||||
sig["sig"] = s[:10] + string(flip) + s[11:]
|
||||
body, _ := json.Marshal(doc)
|
||||
attestServer(t, 200, body)
|
||||
if err := attestation(context.Background(), attestedSums); !errors.Is(err, errUnattested) {
|
||||
if err := attestation(context.Background(), Asset{SHA256: attestedSums}); !errors.Is(err, errUnattested) {
|
||||
t.Fatalf("got %v", err)
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ func TestAttestationTamperedRefused(t *testing.T) {
|
||||
func TestAttestationEditedPayloadRefused(t *testing.T) {
|
||||
body := bytes.Replace(attestFixture(t), []byte(`"payloadType"`), []byte(`"payloadType": "x", "payloadTypeWas"`), 1)
|
||||
attestServer(t, 200, body)
|
||||
if err := attestation(context.Background(), attestedSums); !errors.Is(err, errUnattested) {
|
||||
if err := attestation(context.Background(), Asset{SHA256: attestedSums}); !errors.Is(err, errUnattested) {
|
||||
t.Fatalf("got %v", err)
|
||||
}
|
||||
}
|
||||
@@ -122,12 +122,12 @@ func TestAttestationWrongIdentityRefused(t *testing.T) {
|
||||
"another issuer": {old.SAN, old.Repo, "https://accounts.example.com"},
|
||||
} {
|
||||
attestID.SAN, attestID.Repo, attestID.Issuer = c.san, c.repo, c.issuer
|
||||
if err := attestation(context.Background(), attestedSums); !errors.Is(err, errUnattested) {
|
||||
if err := attestation(context.Background(), Asset{SHA256: attestedSums}); !errors.Is(err, errUnattested) {
|
||||
t.Errorf("%s: got %v", name, err)
|
||||
}
|
||||
}
|
||||
attestID = old
|
||||
if err := attestation(context.Background(), attestedSums); err != nil {
|
||||
if err := attestation(context.Background(), Asset{SHA256: attestedSums}); err != nil {
|
||||
t.Fatalf("the real identity: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -185,7 +185,7 @@ func TestAttestationUnknownGoesOnAndSaysSo(t *testing.T) {
|
||||
// refused, and a bundle that fails after an unknown answer is still refused.
|
||||
func TestAttestationUnknownIsNotVerified(t *testing.T) {
|
||||
attestServer(t, 503, nil)
|
||||
err := attestation(context.Background(), attestedSums)
|
||||
err := attestation(context.Background(), Asset{SHA256: attestedSums})
|
||||
var u errUnknown
|
||||
if err == nil || !errors.As(err, &u) {
|
||||
t.Fatalf("got %v", err)
|
||||
|
||||
@@ -7,9 +7,11 @@ import (
|
||||
)
|
||||
|
||||
// The tests run in a home of their own, never the user's real files, and
|
||||
// the attestation API is an address nothing listens on: a test that signs a
|
||||
// release must not reach GitHub (attest_test.go serves its own).
|
||||
// the attestation API and the site's bundles are an address nothing
|
||||
// listens on: a test that signs a release must not reach GitHub or
|
||||
// usemagpie.ai (attest_test.go and attest_site_test.go serve their own).
|
||||
func TestMain(m *testing.M) {
|
||||
attestAPI = "http://127.0.0.1:1"
|
||||
attestSite = "http://127.0.0.1:1"
|
||||
testenv.Main(m)
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -355,7 +355,7 @@ magpie claude group/opus-anywhere <span class="c"># これを使う</span></p
|
||||
<p>インストーラと <code>magpie update</code> にプロキシを渡します:<code>curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --proxy http://127.0.0.1:7890</code>、または <code>magpie update --proxy socks5://127.0.0.1:1080</code>(http・https・socks5・socks5h に対応。<code>HTTPS_PROXY</code> と <code>ALL_PROXY</code> も使われます)。リリースファイルは usemagpie.ai(Cloudflare R2)から取得し、失敗したときは github.com から取得します。<code>--mirror <prefix></code> を付けると、サイトからの取得に失敗したとき、指定した GitHub ダウンロードミラーから <code><prefix>https://github.com/…</code> としてリリースファイルを取得します。<code>magpie update mirror <prefix></code> でアプリ自身の更新を含め毎回使い、<code>magpie update mirror off</code> で解除します。指定しない限りミラーは使われず、ファイルの SHA-256 はミラーではなく常に usemagpie.ai から取得するので、ミラーが書き換えたファイルはインストールされません。アプリ自身の更新は <span class="ui">Settings</span> → <span class="ui">Proxy</span> を通ります。</p>
|
||||
|
||||
<h3 id="verify-download"><a class="anchor" href="#verify-download">ダウンロードしたファイルが GitHub Actions でビルドされたものか確認するには?</a></h3>
|
||||
<p><a href="https://github.com/yetone/magpie-releases/releases">yetone/magpie-releases</a> の各ファイルには SLSA ビルド来歴(build provenance)の証明が付いています。GitHub Actions の実行自身の ID で Sigstore を通して署名されており、こちらの鍵は使いません。<a href="https://cli.github.com">GitHub CLI</a> で確認します:<code>gh attestation verify magpie-darwin-arm64.dmg -R yetone/magpie-releases</code>。ビルドした workflow と実行が表示され、その実行が作っていないファイルは失敗します。yetone/magpie の Releases にあるコピーにも同じコマンドが使えます。v0.1.3891 以降が対象です。証明が指すのは magpie-releases リポジトリとそのコミットで、yetone/magpie のソースのコミットではありません。アプリ自身の更新は両方を検証します:リリースの SHA-256 一覧に付いた ed25519 署名を magpie に組み込まれた鍵で確認し(オフラインでも usemagpie.ai のミラーからでも有効)、v0.1.3891 以降はさらに GitHub からそのファイルの証明を取得して、GitHub に証明が無いファイルや、このリポジトリのリリース workflow によるものではない証明のファイルはインストールしません。GitHub に接続できないときは署名だけで更新を続け、ログに記録します。 同じ証明は usemagpie.ai にも、ミラーしたファイルの隣に置かれており、GitHub が使えないときも取得できます:<code>https://usemagpie.ai/files/v<バージョン>/attestations.jsonl</code> には、そのリリースの全ファイル分のバンドルが 1 行に 1 つ入っています。ファイルと一緒にダウンロードすれば、証明 API を使わずに確認できます:<code>gh attestation verify magpie-darwin-arm64.dmg -R yetone/magpie-releases --bundle attestations.jsonl</code>(バンドルは Sigstore バンドルです。ミラーには新しいリリースだけが残るので、古いものは上のコマンドを使ってください)。</p>
|
||||
<p><a href="https://github.com/yetone/magpie-releases/releases">yetone/magpie-releases</a> の各ファイルには SLSA ビルド来歴(build provenance)の証明が付いています。GitHub Actions の実行自身の ID で Sigstore を通して署名されており、こちらの鍵は使いません。<a href="https://cli.github.com">GitHub CLI</a> で確認します:<code>gh attestation verify magpie-darwin-arm64.dmg -R yetone/magpie-releases</code>。ビルドした workflow と実行が表示され、その実行が作っていないファイルは失敗します。yetone/magpie の Releases にあるコピーにも同じコマンドが使えます。v0.1.3891 以降が対象です。証明が指すのは magpie-releases リポジトリとそのコミットで、yetone/magpie のソースのコミットではありません。アプリ自身の更新は両方を検証します:リリースの SHA-256 一覧に付いた ed25519 署名を magpie に組み込まれた鍵で確認し(オフラインでも usemagpie.ai のミラーからでも有効)、v0.1.3891 以降はさらにそのファイルの証明を確認し、証明が無いファイルや、このリポジトリのリリース workflow によるものではない証明のファイルはインストールしません。usemagpie.ai からダウンロードしたファイルは証明も usemagpie.ai から(下の <code>attestations.jsonl</code>)取得し、ミラーに無いときは GitHub から取得します。どこから取得しても magpie に組み込まれた Sigstore のルートで同じように検証するので、ミラーは運ぶだけです。証明を取得できないときは署名だけで更新を続け、ログに記録します。 同じ証明は usemagpie.ai にも、ミラーしたファイルの隣に置かれており、GitHub が使えないときも取得できます:<code>https://usemagpie.ai/files/v<バージョン>/attestations.jsonl</code> には、そのリリースの全ファイル分のバンドルが 1 行に 1 つ入っています。ファイルと一緒にダウンロードすれば、証明 API を使わずに確認できます:<code>gh attestation verify magpie-darwin-arm64.dmg -R yetone/magpie-releases --bundle attestations.jsonl</code>(バンドルは Sigstore バンドルです。ミラーには新しいリリースだけが残るので、古いものは上のコマンドを使ってください)。</p>
|
||||
|
||||
<h3 id="linux-build"><a class="anchor" href="#linux-build">Linux ではインストーラはどのビルドを入れますか?</a></h3>
|
||||
<p>GTK 3 と WebKitGTK 4.1 が入っていればデスクトップアプリ(ウィンドウ、トレイアイコン、アプリメニューの項目)です。デスクトップがあってもそれらが無いときは、パッケージマネージャー(apt、dnf、pacman、zypper)で <code>sudo</code> を通して WebKitGTK 4.1 を入れ(sudo がパスワードを尋ねます)、それからアプリを入れます。パスワードを尋ねる前に何を入れるかを表示します。端末が無いとき(CI、Dockerfile)、<code>sudo</code> が無いとき、知らないディストリビューションやインストールに失敗したときはターミナル版(<code>magpie tui</code>、<code>magpie web</code> と CLI)を入れ、最後に入れるコマンドを表示します。Debian・Ubuntu なら <code>sudo apt install libwebkit2gtk-4.1-0</code>、Fedora なら <code>sudo dnf install webkit2gtk4.1</code> です。入れたあとインストーラをもう一度実行するとアプリになります。デスクトップ上で実行しても ssh 越しでも、グラフィカルなセッション、あなたのグラフィカルなログイン、ログインできるデスクトップ環境のどれかがあればデスクトップありと判断します。デスクトップの無いサーバーにはターミナル版です。自分で選ぶには <code>--gui</code>(ライブラリを今入れられなくてもアプリ)か <code>--tui</code>(ターミナル版、パッケージは入れない)を付けます:<code>curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --tui</code>。</p>
|
||||
|
||||
@@ -355,7 +355,7 @@ magpie claude group/opus-anywhere <span class="c"># use it</span></pre>
|
||||
<p>Give the installer and <code>magpie update</code> a proxy: <code>curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --proxy http://127.0.0.1:7890</code>, or <code>magpie update --proxy socks5://127.0.0.1:1080</code> (http, https, socks5 and socks5h; <code>HTTPS_PROXY</code> and <code>ALL_PROXY</code> are honoured too). Release files come from usemagpie.ai (Cloudflare R2), and from github.com when that fails. <code>--mirror <prefix></code> fetches the release file from a GitHub download mirror you choose, as <code><prefix>https://github.com/…</code>, when the site’s copy fails; <code>magpie update mirror <prefix></code> keeps it for every update, the app’s too, and <code>magpie update mirror off</code> removes it. No mirror is used unless you give one, and the file’s SHA-256 still comes from usemagpie.ai, never from the mirror: a file the mirror changed is refused. The app’s own updates go through <span class="ui">Settings</span> → <span class="ui">Proxy</span>.</p>
|
||||
|
||||
<h3 id="verify-download"><a class="anchor" href="#verify-download">How do I check that a download was built by GitHub Actions?</a></h3>
|
||||
<p>Every file on <a href="https://github.com/yetone/magpie-releases/releases">yetone/magpie-releases</a> carries a SLSA build provenance attestation, signed through Sigstore with the GitHub Actions run’s own identity and no key of ours. With the <a href="https://cli.github.com">GitHub CLI</a>: <code>gh attestation verify magpie-darwin-arm64.dmg -R yetone/magpie-releases</code>. It shows the workflow and run that built the file, and fails for a file that run didn’t produce. The same command works on the copy in yetone/magpie’s Releases. From v0.1.3891 on. The attestation names the magpie-releases repo and its commit, not the source commit in yetone/magpie. The app’s own updates check both: the release’s SHA-256 list carries an ed25519 signature, checked against a key built into magpie (offline, and also for a file from usemagpie.ai’s mirror), and from v0.1.3891 on the app also asks GitHub for the file’s attestation and refuses a file that GitHub has none for or whose attestation is not from this repo’s release workflow. When GitHub can’t be reached, the update goes on on the signature alone and the log says so. The same attestations are kept on usemagpie.ai, beside the mirrored files, so they are there when GitHub is not: <code>https://usemagpie.ai/files/v<version>/attestations.jsonl</code> holds one bundle per line for every file of the release. Download it with the file and check offline of the attestation API: <code>gh attestation verify magpie-darwin-arm64.dmg -R yetone/magpie-releases --bundle attestations.jsonl</code> (the bundles are Sigstore bundles; a release that is not among the newest on the mirror falls back to the command above).</p>
|
||||
<p>Every file on <a href="https://github.com/yetone/magpie-releases/releases">yetone/magpie-releases</a> carries a SLSA build provenance attestation, signed through Sigstore with the GitHub Actions run’s own identity and no key of ours. With the <a href="https://cli.github.com">GitHub CLI</a>: <code>gh attestation verify magpie-darwin-arm64.dmg -R yetone/magpie-releases</code>. It shows the workflow and run that built the file, and fails for a file that run didn’t produce. The same command works on the copy in yetone/magpie’s Releases. From v0.1.3891 on. The attestation names the magpie-releases repo and its commit, not the source commit in yetone/magpie. The app’s own updates check both: the release’s SHA-256 list carries an ed25519 signature, checked against a key built into magpie (offline, and also for a file from usemagpie.ai’s mirror), and from v0.1.3891 on the app also checks the file’s attestation and refuses a file that has none or whose attestation is not from this repo’s release workflow. A file downloaded from usemagpie.ai has its attestation taken from usemagpie.ai too (the <code>attestations.jsonl</code> below), and from GitHub when the mirror doesn’t have it; wherever it comes from, it is checked the same way, against Sigstore’s root built into magpie, so the mirror only carries it. When it can’t be had, the update goes on on the signature alone and the log says so. The same attestations are kept on usemagpie.ai, beside the mirrored files, so they are there when GitHub is not: <code>https://usemagpie.ai/files/v<version>/attestations.jsonl</code> holds one bundle per line for every file of the release. Download it with the file and check offline of the attestation API: <code>gh attestation verify magpie-darwin-arm64.dmg -R yetone/magpie-releases --bundle attestations.jsonl</code> (the bundles are Sigstore bundles; a release that is not among the newest on the mirror falls back to the command above).</p>
|
||||
|
||||
<h3 id="linux-build"><a class="anchor" href="#linux-build">Which build does the installer put on Linux?</a></h3>
|
||||
<p>The desktop app (window, tray icon and a menu entry) when GTK 3 and WebKitGTK 4.1 are installed. On a computer with a desktop but without them, the installer installs WebKitGTK 4.1 with your package manager (apt, dnf, pacman or zypper), through <code>sudo</code>, which asks for your password, and then the app; it says what it installs before it asks. Run without a terminal (CI, a Dockerfile), without <code>sudo</code>, on another distribution or when that install fails, it installs the terminal build (<code>magpie tui</code>, <code>magpie web</code> and the CLI) and ends with the command that installs them, such as <code>sudo apt install libwebkit2gtk-4.1-0</code> on Debian and Ubuntu or <code>sudo dnf install webkit2gtk4.1</code> on Fedora; run the installer again afterwards for the app. A desktop counts whether you run it there or over ssh: a graphical session, your graphical login, or a desktop installed to log in to. A server without one gets the terminal build. To choose yourself, add <code>--gui</code> (the app even when its libraries can't be installed now) or <code>--tui</code> (the terminal build, and no package installed): <code>curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --tui</code>.</p>
|
||||
|
||||
@@ -355,7 +355,7 @@ magpie claude group/opus-anywhere <span class="c"># 使用它</span></pre>
|
||||
<p>给安装脚本和 <code>magpie update</code> 加代理:<code>curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --proxy http://127.0.0.1:7890</code>,或 <code>magpie update --proxy socks5://127.0.0.1:1080</code>(支持 http、https、socks5、socks5h;环境变量 <code>HTTPS_PROXY</code>、<code>ALL_PROXY</code> 同样生效)。发布文件从 usemagpie.ai(Cloudflare R2)下载,失败时改从 github.com 下载。<code>--mirror <前缀></code> 在站点下载失败时从你指定的 GitHub 下载镜像取发布文件,即 <code><前缀>https://github.com/…</code>;<code>magpie update mirror <前缀></code> 让之后每次更新(包括应用自己的更新)都用它,<code>magpie update mirror off</code> 取消。不指定就不用任何镜像;文件的 SHA-256 始终来自 usemagpie.ai,而不是镜像,镜像改过的文件会被拒绝安装。应用自己的更新走 <span class="ui">设置</span> → <span class="ui">代理</span>。</p>
|
||||
|
||||
<h3 id="verify-download"><a class="anchor" href="#verify-download">怎么确认下载的文件是 GitHub Actions 构建的?</a></h3>
|
||||
<p><a href="https://github.com/yetone/magpie-releases/releases">yetone/magpie-releases</a> 上的每个文件都带有 SLSA 构建来源证明(build provenance),由 GitHub Actions 运行自身的身份通过 Sigstore 签发,不用我们自己的密钥。用 <a href="https://cli.github.com">GitHub CLI</a> 校验:<code>gh attestation verify magpie-darwin-arm64.dmg -R yetone/magpie-releases</code>。它会显示构建该文件的 workflow 和运行,不是这次运行产出的文件会校验失败。yetone/magpie 的 Releases 页上的副本用同一条命令。从 v0.1.3891 起提供。证明指向的是 magpie-releases 仓库及其提交,而不是 yetone/magpie 里的源码提交。应用自己的更新两层都校验:发布的 SHA-256 清单带有 ed25519 签名,用内置在 magpie 里的公钥校验(离线可用,文件来自 usemagpie.ai 的镜像时同样有效);从 v0.1.3891 起应用还会向 GitHub 取该文件的构建证明,GitHub 没有证明、或证明不是出自本仓库发布 workflow 的文件不会被安装。连不上 GitHub 时,更新仍凭签名继续,并在日志里说明。 同样的证明也保存在 usemagpie.ai 上、镜像文件的旁边,GitHub 不可用时照样能取:<code>https://usemagpie.ai/files/v<版本号>/attestations.jsonl</code> 每行一个 bundle,覆盖该版本的所有文件。把它和文件一起下载,即可不依赖证明 API 校验:<code>gh attestation verify magpie-darwin-arm64.dmg -R yetone/magpie-releases --bundle attestations.jsonl</code>(bundle 是 Sigstore bundle;镜像里保留较新的几个版本,更早的版本请用上面的命令)。</p>
|
||||
<p><a href="https://github.com/yetone/magpie-releases/releases">yetone/magpie-releases</a> 上的每个文件都带有 SLSA 构建来源证明(build provenance),由 GitHub Actions 运行自身的身份通过 Sigstore 签发,不用我们自己的密钥。用 <a href="https://cli.github.com">GitHub CLI</a> 校验:<code>gh attestation verify magpie-darwin-arm64.dmg -R yetone/magpie-releases</code>。它会显示构建该文件的 workflow 和运行,不是这次运行产出的文件会校验失败。yetone/magpie 的 Releases 页上的副本用同一条命令。从 v0.1.3891 起提供。证明指向的是 magpie-releases 仓库及其提交,而不是 yetone/magpie 里的源码提交。应用自己的更新两层都校验:发布的 SHA-256 清单带有 ed25519 签名,用内置在 magpie 里的公钥校验(离线可用,文件来自 usemagpie.ai 的镜像时同样有效);从 v0.1.3891 起应用还会校验该文件的构建证明,没有证明、或证明不是出自本仓库发布 workflow 的文件不会被安装。从 usemagpie.ai 下载的文件,证明也从 usemagpie.ai 取(即下面的 <code>attestations.jsonl</code>),镜像上没有时再向 GitHub 取;无论从哪里取,都用内置在 magpie 里的 Sigstore 根做同样的校验,镜像只负责传送。取不到证明时,更新仍凭签名继续,并在日志里说明。 同样的证明也保存在 usemagpie.ai 上、镜像文件的旁边,GitHub 不可用时照样能取:<code>https://usemagpie.ai/files/v<版本号>/attestations.jsonl</code> 每行一个 bundle,覆盖该版本的所有文件。把它和文件一起下载,即可不依赖证明 API 校验:<code>gh attestation verify magpie-darwin-arm64.dmg -R yetone/magpie-releases --bundle attestations.jsonl</code>(bundle 是 Sigstore bundle;镜像里保留较新的几个版本,更早的版本请用上面的命令)。</p>
|
||||
|
||||
<h3 id="linux-build"><a class="anchor" href="#linux-build">Linux 上安装脚本装的是哪个版本?</a></h3>
|
||||
<p>装了 GTK 3 和 WebKitGTK 4.1 时装桌面版(窗口、托盘图标和应用菜单项)。有桌面但缺这两个库时,脚本会用系统的包管理器(apt、dnf、pacman 或 zypper)通过 <code>sudo</code> 装上 WebKitGTK 4.1(sudo 会要你的密码),再装桌面版;要密码之前会先说要装什么。没有终端(CI、Dockerfile)、没有 <code>sudo</code>、发行版不认识或者装库失败时,先装终端版(<code>magpie tui</code>、<code>magpie web</code> 和命令行),最后给出装库的命令,比如 Debian、Ubuntu 上是 <code>sudo apt install libwebkit2gtk-4.1-0</code>,Fedora 上是 <code>sudo dnf install webkit2gtk4.1</code>;装好后再运行一次安装脚本就换成桌面版。在桌面上运行还是 ssh 进去运行都算有桌面:有图形会话、你登录着图形界面,或者装了可登录的桌面环境。没有桌面的服务器装终端版。想自己选,加 <code>--gui</code>(库现在装不上也装桌面版)或 <code>--tui</code>(装终端版,不装任何系统包):<code>curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --tui</code>。</p>
|
||||
|
||||
@@ -245,7 +245,7 @@ Give the installer and `magpie update` a proxy: `curl -fsSL https://usemagpie.ai
|
||||
|
||||
### How do I check that a download was built by GitHub Actions?
|
||||
|
||||
Every file on [yetone/magpie-releases](https://github.com/yetone/magpie-releases/releases) carries a SLSA build provenance attestation, signed through Sigstore with the GitHub Actions run’s own identity and no key of ours. With the [GitHub CLI](https://cli.github.com): `gh attestation verify magpie-darwin-arm64.dmg -R yetone/magpie-releases`. It shows the workflow and run that built the file, and fails for a file that run didn’t produce. The same command works on the copy in yetone/magpie’s Releases. From v0.1.3891 on. The attestation names the magpie-releases repo and its commit, not the source commit in yetone/magpie. The app’s own updates check both: the release’s SHA-256 list carries an ed25519 signature, checked against a key built into magpie (offline, and also for a file from usemagpie.ai’s mirror), and from v0.1.3891 on the app also asks GitHub for the file’s attestation and refuses a file that GitHub has none for or whose attestation is not from this repo’s release workflow. When GitHub can’t be reached, the update goes on on the signature alone and the log says so. The same attestations are kept on usemagpie.ai, beside the mirrored files, so they are there when GitHub is not: `https://usemagpie.ai/files/v<version>/attestations.jsonl` holds one bundle per line for every file of the release. Download it with the file and check offline of the attestation API: `gh attestation verify magpie-darwin-arm64.dmg -R yetone/magpie-releases --bundle attestations.jsonl` (the bundles are Sigstore bundles; a release that is not among the newest on the mirror falls back to the command above).
|
||||
Every file on [yetone/magpie-releases](https://github.com/yetone/magpie-releases/releases) carries a SLSA build provenance attestation, signed through Sigstore with the GitHub Actions run’s own identity and no key of ours. With the [GitHub CLI](https://cli.github.com): `gh attestation verify magpie-darwin-arm64.dmg -R yetone/magpie-releases`. It shows the workflow and run that built the file, and fails for a file that run didn’t produce. The same command works on the copy in yetone/magpie’s Releases. From v0.1.3891 on. The attestation names the magpie-releases repo and its commit, not the source commit in yetone/magpie. The app’s own updates check both: the release’s SHA-256 list carries an ed25519 signature, checked against a key built into magpie (offline, and also for a file from usemagpie.ai’s mirror), and from v0.1.3891 on the app also checks the file’s attestation and refuses a file that has none or whose attestation is not from this repo’s release workflow. A file downloaded from usemagpie.ai has its attestation taken from usemagpie.ai too (the `attestations.jsonl` below), and from GitHub when the mirror doesn’t have it; wherever it comes from, it is checked the same way, against Sigstore’s root built into magpie, so the mirror only carries it. When it can’t be had, the update goes on on the signature alone and the log says so. The same attestations are kept on usemagpie.ai, beside the mirrored files, so they are there when GitHub is not: `https://usemagpie.ai/files/v<version>/attestations.jsonl` holds one bundle per line for every file of the release. Download it with the file and check offline of the attestation API: `gh attestation verify magpie-darwin-arm64.dmg -R yetone/magpie-releases --bundle attestations.jsonl` (the bundles are Sigstore bundles; a release that is not among the newest on the mirror falls back to the command above).
|
||||
|
||||
### Which build does the installer put on Linux?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user