Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/update-catalog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ jobs:
git fetch --quiet origin main
git reset --quiet --hard FETCH_HEAD
go run ./cmd/update-catalog "${args[@]}"
if git diff --quiet -- manifest.json; then
git add -- manifest.json releases
if git diff --cached --quiet -- manifest.json releases; then
echo "The catalog already lists ${PLUGIN_REPO}@${PLUGIN_TAG}."
exit 0
fi
git add manifest.json
git commit --quiet -m "chore: update catalog for ${PLUGIN_REPO}@${PLUGIN_TAG}"
if git push origin HEAD:main; then
exit 0
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ none of the Go files touched by your change may appear in the output; do not add
to the output, and report what remains. For catalog output changes, inspect the
complete `manifest.json` diff and verify repository URLs, versions, platforms,
the checksum URL, the bundle URL when the release is signed, capabilities, and
presentation metadata against the source release. The catalog stores a URL for
`checksums.txt`, not the checksum values themselves, so also confirm that the
release asset exists and covers every published binary.
presentation metadata against the source release. Confirm that the
`checksums.txt` asset and the frozen digest cover every published binary. Review
the matching descriptor under `releases/` in the same change.

Changes to `update-catalog`'s refusal rules (input validation, the plugin
table, version order, asset URLs, the commit binding, or signature policy)
Expand Down
67 changes: 53 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ call `repository_dispatch` on `Silo-Server/silo-plugins`.
`manifest.json` names that ID. Adding a first-party plugin means adding it
there, and to the matching table in Silo server.
- The version is newer than the plugin's listed version. Re-running for the
listed version does nothing and succeeds. A deliberate rollback needs the
listed version verifies it again and succeeds if the release is identical.
A deliberate rollback needs the
`allow_rollback` input of a manual `workflow_dispatch` run; a
`repository_dispatch` cannot set it.
- The release is published for exactly that tag and is neither a draft nor a
Expand All @@ -37,8 +38,9 @@ signature names for a signed release, or the commit the tag points at
A signed release also carries `plugin.sigstore.json`: a Sigstore bundle with
one SLSA provenance attestation covering every `plugin-<os>-<arch>` binary,
produced by the shared `plugin-release.yml` workflow in `Silo-Server/.github`.
The catalog entry then gains a package-level `bundle_url` beside
`checksums_url`. Before writing the entry, `update-catalog` checks each binary
The catalog entry records the `bundle_url` and each binary's SHA-256 digest.
`update-catalog` compares each downloaded binary with `checksums.txt` and checks
its attestation
with `gh attestation verify`, requiring the certificate identity
`https://github.com/Silo-Server/.github/.github/workflows/plugin-release.yml@refs/heads/main`,
the issuer `https://token.actions.githubusercontent.com`, the plugin's bound
Expand All @@ -52,6 +54,21 @@ The workflow has no concurrency group. Runs race on the push, and each retry
rebuilds the entry on the current `main`, so a duplicate run is a no-op and an
older release that loses the race to a newer one is refused.

The same commit writes the current `manifest.json` entry and
`releases/<plugin-id>/<version>.json`. The descriptor records the repository,
tag, source commit, platform digests and bundle URL. An attempt to change a
published descriptor fails, including during a rollback. Older servers can
continue to discover the current version through `manifest.json`.

To withdraw a release, run the updater with `-repo`, `-tag` and `-withdraw`.
Review the resulting entry in the `withdrawals` array in `manifest.json`.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
Commit that file on a branch and open a pull request against `main`. Merging
the pull request publishes the withdrawal. Servers with withdrawal support skip that version for new installations and
replacements, including when a declaration pins it. Existing installations
keep their stored archive. Publish a supported release or explicitly roll
back the discovery entry to a supported version if the withdrawal affects
the current release.

`silo-plugins` uses `CATALOG_PUSH_TOKEN` to push catalog updates. Reading a
plugin's release metadata and its tagged `manifest.json` needs no extra
credential: every catalogued plugin repository is public, so the workflow's own
Expand All @@ -67,23 +84,45 @@ go run ./cmd/update-catalog \
-tag vX.Y.Z
```

`vX.Y.Z` must be a published release newer than the listed version. The listed
version does nothing and an older one is refused. To try the tool against a
release the catalog already lists, rebuild that entry in a copy of the catalog:
`vX.Y.Z` must be a published release at least as recent as the listed version.
To regenerate a historical descriptor in a copy of the catalog, use
`-history-only`:

```sh
catalog_copy="$(mktemp)"
cp manifest.json "$catalog_copy"
catalog_copy="$(mktemp -d)"
cp manifest.json "$catalog_copy/manifest.json"
go run ./cmd/update-catalog \
-repo Silo-Server/silo-plugin-metadata-tmdb \
-tag v1.2.29 \
-allow-rollback \
-manifest "$catalog_copy"
-repo Silo-Server/silo-plugin-auth-oidc \
-tag v0.1.1 \
-history-only \
-manifest "$catalog_copy/manifest.json"
```

For a private source repository, provide `GITHUB_TOKEN` through your normal
secret-injection workflow. The command rewrites `manifest.json`; review or
discard that diff after the check.
secret injection workflow.

## History coverage

The initial backfill covers the 32 published releases across 14 official
plugin repositories that carried a verified signature bundle on November 19,
2026. It includes OIDC `0.1.1` and `0.1.2`. OIDC `0.1.0` predates release
signing. The archived Trakt repository had no eligible release.

To reproduce these descriptors, read each descriptor's repository and tag
and run `-history-only` against a copy of the catalog:

```sh
catalog_copy="$(mktemp -d)"
cp manifest.json "$catalog_copy/manifest.json"
go build -o "$catalog_copy/update-catalog" ./cmd/update-catalog
jq -r '[(.repo_url | ltrimstr("https://github.com/")), .tag] | @tsv' \
releases/*/*.json | sort -u |
while read -r repo tag; do
"$catalog_copy/update-catalog" -history-only -repo "$repo" -tag "$tag" \
-manifest "$catalog_copy/manifest.json" || exit 1
done
diff -r releases "$catalog_copy/releases"
```

## Development

Expand Down
13 changes: 11 additions & 2 deletions catalog/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ type Release struct {
}

type PlatformBinary struct {
URL string `json:"url"`
URL string `json:"url"`
Checksum string `json:"checksum,omitempty"`
}

type CatalogPackage struct {
Expand All @@ -35,10 +36,18 @@ type CatalogPackage struct {
ChecksumsURL string `json:"checksums_url,omitempty"`
BundleURL string `json:"bundle_url,omitempty"`
Binaries map[string]PlatformBinary `json:"binaries,omitempty"`
Tag string `json:"tag,omitempty"`
SourceCommit string `json:"source_commit,omitempty"`
}

type RepositoryIndex struct {
Plugins []CatalogPackage `json:"plugins"`
Plugins []CatalogPackage `json:"plugins"`
Withdrawals []Withdrawal `json:"withdrawals,omitempty"`
}

type Withdrawal struct {
PluginID string `json:"plugin_id"`
Version string `json:"version"`
}

func DecodeSourceManifest(data []byte) (*SourceManifest, error) {
Expand Down
37 changes: 37 additions & 0 deletions catalog/catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package catalog
import (
"encoding/json"
"slices"
"strings"
"testing"

pluginv1 "github.com/Silo-Server/silo-plugin-sdk/pkg/pluginproto/silo/plugin/v1"
Expand Down Expand Up @@ -565,6 +566,14 @@ func TestParseReleaseAssets(t *testing.T) {
}
})
}
for _, asset := range valid[:3] {
t.Run("duplicate "+asset.Name, func(t *testing.T) {
release := Release{TagName: "v1.2.3", Assets: append(slices.Clone(valid), asset)}
if _, err := ParseReleaseAssets(repo, release); err == nil {
t.Fatalf("accepted duplicate asset %s", asset.Name)
}
})
}
}

func TestCheckVersion(t *testing.T) {
Expand Down Expand Up @@ -596,3 +605,31 @@ func TestCheckVersion(t *testing.T) {
})
}
}

func TestCheckReleaseDigest(t *testing.T) {
const asset = "plugin-linux-amd64"
digest := strings.Repeat("a", 64)
for _, tc := range []struct {
name, checksums string
wantErr bool
}{
{name: "matching", checksums: digest + " *" + asset + "\n"},
{name: "missing", checksums: digest + " plugin-linux-arm64\n", wantErr: true},
{name: "mismatch", checksums: strings.Repeat("0", 64) + " " + asset + "\n", wantErr: true},
{name: "duplicate", checksums: strings.Repeat(digest+" "+asset+"\n", 2), wantErr: true},
} {
t.Run(tc.name, func(t *testing.T) {
if err := CheckReleaseDigest(tc.checksums, asset, digest); (err != nil) != tc.wantErr {
t.Fatalf("CheckReleaseDigest() = %v, want error %v", err, tc.wantErr)
}
})
}
}

func TestWithdrawReleaseKeepsOtherReleasesAvailable(t *testing.T) {
index := WithdrawRelease(RepositoryIndex{}, "silo.auth.oidc", "0.1.1")
index = WithdrawRelease(index, "silo.auth.oidc", "0.1.1")
if len(index.Withdrawals) != 1 || !index.IsWithdrawn("silo.auth.oidc", "0.1.1") || index.IsWithdrawn("silo.auth.oidc", "0.1.2") {
t.Fatalf("unexpected withdrawal set: %+v", index.Withdrawals)
}
}
58 changes: 57 additions & 1 deletion catalog/release.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package catalog

import (
"cmp"
"fmt"
"net/url"
"path/filepath"
"regexp"
"slices"
"strings"

"golang.org/x/mod/semver"
Expand Down Expand Up @@ -44,6 +47,50 @@ func VersionFromTag(tag string) string {
return strings.TrimPrefix(tag, "v")
}

func ReleasePath(root, repo, tag string) (string, error) {
if err := ValidateInputs(repo, tag); err != nil {
return "", err
}
pluginID, err := OfficialPluginID(repo)
if err != nil {
return "", err
}
return filepath.Join(root, "releases", pluginID, VersionFromTag(tag)+".json"), nil
}

func (index RepositoryIndex) IsWithdrawn(pluginID, version string) bool {
return slices.Contains(index.Withdrawals, Withdrawal{PluginID: pluginID, Version: version})
}

func WithdrawRelease(index RepositoryIndex, pluginID, version string) RepositoryIndex {
if index.IsWithdrawn(pluginID, version) {
return index
}
index.Withdrawals = append(slices.Clone(index.Withdrawals), Withdrawal{PluginID: pluginID, Version: version})
slices.SortFunc(index.Withdrawals, func(a, b Withdrawal) int {
return cmp.Or(cmp.Compare(a.PluginID, b.PluginID), cmp.Compare(a.Version, b.Version))
})
return index
}

func CheckReleaseDigest(checksums, assetName, digest string) error {
found := false
for line := range strings.SplitSeq(checksums, "\n") {
fields := strings.Fields(line)
if len(fields) != 2 || strings.TrimPrefix(fields[1], "*") != assetName {
continue
}
if found || !strings.EqualFold(fields[0], digest) {
return fmt.Errorf("checksums.txt does not uniquely match the SHA-256 digest of %s", assetName)
}
found = true
}
if !found {
return fmt.Errorf("checksums.txt has no entry for %s", assetName)
}
return nil
}

// FindPackage returns the catalog entry for pluginID, or nil.
func FindPackage(index RepositoryIndex, pluginID string) *CatalogPackage {
for i := range index.Plugins {
Expand All @@ -58,7 +105,7 @@ func FindPackage(index RepositoryIndex, pluginID string) *CatalogPackage {
// version, so a dispatch cannot replace the current entry with an older
// release. alreadyListed reports a re-run for the listed version, which the
// caller treats as a successful no-op. allowRollback, set only for a
// deliberate manual run, accepts an older version and rewrites an equal one.
// deliberate manual run, also accepts an older version.
func CheckVersion(current *CatalogPackage, version string, allowRollback bool) (alreadyListed bool, err error) {
if current == nil || current.Manifest == nil {
return false, nil
Expand Down Expand Up @@ -120,10 +167,19 @@ func ParseReleaseAssets(repo string, release Release) (ReleaseAssets, error) {
}
switch {
case isBinary:
if _, exists := assets.Binaries[platform]; exists {
return ReleaseAssets{}, fmt.Errorf("duplicate release binary for %s", platform)
}
assets.Binaries[platform] = asset.BrowserDownloadURL
case asset.Name == BundleAssetName:
if assets.BundleURL != "" {
return ReleaseAssets{}, fmt.Errorf("duplicate release asset %s", asset.Name)
}
assets.BundleURL = asset.BrowserDownloadURL
default:
if assets.ChecksumsURL != "" {
return ReleaseAssets{}, fmt.Errorf("duplicate release asset %s", asset.Name)
}
assets.ChecksumsURL = asset.BrowserDownloadURL
}
}
Expand Down
Loading