From d1a85ba8ddbf9decac368b5daa0914f645ab4694 Mon Sep 17 00:00:00 2001 From: Victor Irzak Date: Sat, 28 Nov 2026 22:19:29 -0500 Subject: [PATCH 1/3] Build provenance for release archives and the image --- .github/workflows/release.yml | 20 +++++++++++++++++++- README.md | 9 +++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a5b2192..7547d73 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,9 @@ name: Release # Builds plugctl for each platform and publishes a GitHub release with the archives, plus the -# container image ghcr.io/zompinc/plugctl built from the Linux binaries. +# container image ghcr.io/zompinc/plugctl built from the Linux binaries. Both carry build +# provenance: `gh attestation verify -R zompinc/plugctl` (or oci://) checks that +# this workflow built them, and from which commit. # # - Run it from the Actions tab (workflow_dispatch) on master: it tags the commit with the # version Nerdbank.GitVersioning calculates and publishes. @@ -124,6 +126,9 @@ jobs: permissions: contents: read packages: write + # For the provenance attestation: a GitHub OIDC token to sign it, and the right to store it. + id-token: write + attestations: write steps: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 @@ -161,6 +166,7 @@ jobs: username: ${{ github.actor }} password: ${{ github.token }} - uses: docker/build-push-action@v6 + id: push with: context: . platforms: linux/amd64,linux/arm64 @@ -173,6 +179,12 @@ jobs: org.opencontainers.image.version=${{ needs.version.outputs.version }} org.opencontainers.image.licenses=MIT org.opencontainers.image.description=Switch or power-cycle smart plugs by MAC + - uses: actions/attest-build-provenance@v4 + if: ${{ github.event_name != 'pull_request' }} + with: + subject-name: ghcr.io/${{ github.repository }} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true publish: needs: [version, build, image] @@ -180,12 +192,18 @@ jobs: runs-on: ubuntu-latest permissions: contents: write + id-token: write + attestations: write steps: - uses: actions/download-artifact@v4 with: path: dist merge-multiple: true + - uses: actions/attest-build-provenance@v4 + with: + subject-path: dist/* + - name: Publish env: GH_TOKEN: ${{ github.token }} diff --git a/README.md b/README.md index a0438f0..246d93b 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,15 @@ TP-Link Kasa plugs come first, including firmware that only accepts KLAP (the en Download the archive for your platform from [Releases](https://github.com/zompinc/plugctl/releases) and put `plugctl` (or `plugctl.exe`) on your `PATH`. There are static Linux builds for x86_64 and aarch64 (which also run on aarch64 OpenWrt routers), Windows x86_64, and macOS on Apple silicon and Intel. `SHA256SUMS` lists each archive's checksum. +Each archive and image carries a build provenance attestation, which shows that this repository's release workflow built it and from which commit: + +```sh +gh attestation verify plugctl--.tar.gz -R zompinc/plugctl +gh attestation verify oci://ghcr.io/zompinc/plugctl: -R zompinc/plugctl +``` + +The binaries are not code-signed. On macOS, a binary downloaded with a browser needs `xattr -d com.apple.quarantine plugctl` before it runs. + ### Container Each release is also an image for linux/amd64 and linux/arm64, `ghcr.io/zompinc/plugctl:` (`latest` follows stable releases only). It keeps the config and the off-time log in `/config`, and takes the login from the environment, since there is no keyring in a container: From 2c56fd2d3a2b3037787d4f82665cbc23feaef70d Mon Sep 17 00:00:00 2001 From: Victor Irzak Date: Sat, 28 Nov 2026 22:27:55 -0500 Subject: [PATCH 2/3] Sign plugctl.exe with Artifact Signing --- .github/workflows/release.yml | 30 ++++++++++++++++++++++++++++++ README.md | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7547d73..a7a163c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -73,6 +73,9 @@ jobs: # Hosted runners: this repository is public. runs-on: ${{ matrix.os }} + env: + # Whether the signing secrets are available, without putting them in every step's env. + CAN_SIGN: ${{ secrets.AZURE_SIGNER_CLIENT_SECRET != '' }} steps: - uses: actions/checkout@v4 @@ -100,6 +103,33 @@ jobs: cargo build --release --locked --target ${{ matrix.target }} fi + # Authenticode-signs plugctl.exe with Zomp's Azure Artifact Signing (formerly Trusted + # Signing) account, so SmartScreen and Smart App Control see a known publisher. The + # secrets are organization secrets, which pull requests from forks do not get, so those + # build unsigned. The sign tool's stable-looking 1.x on nuget.org is a different package; + # the real one is still in prerelease. + - name: Sign + if: ${{ runner.os == 'Windows' && !env.ACT && env.CAN_SIGN == 'true' }} + shell: pwsh + # The default Azure credential chain reads these. + env: + AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} + AZURE_CLIENT_ID: ${{ secrets.AZURE_SIGNER_CLIENT_ID }} + AZURE_CLIENT_SECRET: ${{ secrets.AZURE_SIGNER_CLIENT_SECRET }} + run: | + dotnet tool install sign --version 0.9.1-beta.26552.4 --tool-path "$env:RUNNER_TEMP/sign" + $exe = "target/${{ matrix.target }}/release/plugctl.exe" + & "$env:RUNNER_TEMP/sign/sign" code artifact-signing $exe ` + --artifact-signing-endpoint "${{ secrets.TRUSTED_SIGNING_ENDPOINT }}" ` + --artifact-signing-account "${{ secrets.TRUSTED_SIGNING_ACCOUNT }}" ` + --artifact-signing-certificate-profile "${{ secrets.TRUSTED_SIGNING_CERTIFICATE_PROFILE }}" ` + --description plugctl --description-url "https://github.com/${{ github.repository }}" ` + -v information + if ($LASTEXITCODE) { exit $LASTEXITCODE } + $sig = Get-AuthenticodeSignature $exe + "$($sig.Status): $($sig.SignerCertificate.Subject)" + if ($sig.Status -ne 'Valid') { exit 1 } + - name: Package shell: bash run: | diff --git a/README.md b/README.md index 246d93b..b20d996 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ gh attestation verify plugctl--.tar.gz -R zompinc/plugctl gh attestation verify oci://ghcr.io/zompinc/plugctl: -R zompinc/plugctl ``` -The binaries are not code-signed. On macOS, a binary downloaded with a browser needs `xattr -d com.apple.quarantine plugctl` before it runs. +The Windows binary is Authenticode-signed by Zomp Inc.; the macOS binaries are not signed yet. On macOS, a binary downloaded with a browser needs `xattr -d com.apple.quarantine plugctl` before it runs. ### Container From 51fd1f60aa49d5c476cea64e819239061e878087 Mon Sep 17 00:00:00 2001 From: Victor Irzak Date: Sat, 28 Nov 2026 22:30:23 -0500 Subject: [PATCH 3/3] Sign with sign-universal --- .github/workflows/release.yml | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a7a163c..0570ff4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -103,29 +103,30 @@ jobs: cargo build --release --locked --target ${{ matrix.target }} fi - # Authenticode-signs plugctl.exe with Zomp's Azure Artifact Signing (formerly Trusted - # Signing) account, so SmartScreen and Smart App Control see a known publisher. The - # secrets are organization secrets, which pull requests from forks do not get, so those - # build unsigned. The sign tool's stable-looking 1.x on nuget.org is a different package; - # the real one is still in prerelease. + # Authenticode-signs plugctl.exe with Zomp's Azure Trusted Signing account, so SmartScreen + # and Smart App Control see a known publisher. sign-universal is Zomp's own signer + # (github.com/zompinc/sign-universal). The secrets are organization secrets, which pull + # requests from forks do not get, so those build unsigned. - name: Sign if: ${{ runner.os == 'Windows' && !env.ACT && env.CAN_SIGN == 'true' }} shell: pwsh - # The default Azure credential chain reads these. + # sign-universal reads these, as DefaultAzureCredential does. env: AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} AZURE_CLIENT_ID: ${{ secrets.AZURE_SIGNER_CLIENT_ID }} AZURE_CLIENT_SECRET: ${{ secrets.AZURE_SIGNER_CLIENT_SECRET }} run: | - dotnet tool install sign --version 0.9.1-beta.26552.4 --tool-path "$env:RUNNER_TEMP/sign" + dotnet tool install SignUniversal.Cli --version 1.0.39 --tool-path "$env:RUNNER_TEMP/sign" + $su = "$env:RUNNER_TEMP/sign/sign-universal" $exe = "target/${{ matrix.target }}/release/plugctl.exe" - & "$env:RUNNER_TEMP/sign/sign" code artifact-signing $exe ` - --artifact-signing-endpoint "${{ secrets.TRUSTED_SIGNING_ENDPOINT }}" ` - --artifact-signing-account "${{ secrets.TRUSTED_SIGNING_ACCOUNT }}" ` - --artifact-signing-certificate-profile "${{ secrets.TRUSTED_SIGNING_CERTIFICATE_PROFILE }}" ` - --description plugctl --description-url "https://github.com/${{ github.repository }}" ` - -v information + & $su sign $exe ` + --trusted-signing-endpoint "${{ secrets.TRUSTED_SIGNING_ENDPOINT }}" ` + --trusted-signing-account "${{ secrets.TRUSTED_SIGNING_ACCOUNT }}" ` + --trusted-signing-certificate-profile "${{ secrets.TRUSTED_SIGNING_CERTIFICATE_PROFILE }}" if ($LASTEXITCODE) { exit $LASTEXITCODE } + & $su verify $exe + if ($LASTEXITCODE) { exit $LASTEXITCODE } + # verify leaves trust to Windows; this asks Windows whether it trusts the chain. $sig = Get-AuthenticodeSignature $exe "$($sig.Status): $($sig.SignerCertificate.Subject)" if ($sig.Status -ne 'Valid') { exit 1 }