Files
Dj GilcreaseandClaude Fable 5.1 62f72a6783 feat(msix): default publisher from the signing certificate or vendor (#1135)
* chore(deps): bump go-msix to v1.0.1 and go-pkcs12 to v0.7.3

go-msix v1.0.1 carries the Authenticode signing fixes needed for packages
signed on Linux to validate on Windows; go-pkcs12 becomes a direct
dependency for the signing tests.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015Hnro326ZTAu2EqUTGGkCB

* feat(msix): default publisher from the signing certificate or vendor

`msix.publisher` is no longer required. When signing is configured it
defaults to the certificate subject, which Windows requires to byte-match
on signed packages; otherwise it becomes a CN= distinguished name built
from the root vendor, falling back to the maintainer name (with RFC 2253
escaping). `publisher_display_name` prefers vendor/maintainer over the
package name, `$NFPM_PASSPHRASE` now also feeds the MSIX signer, and the
root `scripts` block is reported as ignored instead of silently dropped.

The vendor/maintainer fallback lives in internal/maintainer so the MSI
packager can share it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015Hnro326ZTAu2EqUTGGkCB

* ci: validate nfpm-signed MSIX on real Windows

Build and Authenticode-sign the MSIX on Linux with nfpm's pure-Go signer
and a throwaway openssl certificate, then validate the signature with the
real Windows trust stack (Get-AuthenticodeSignature, signtool verify) and
deploy it with Add-AppxPackage on a Windows runner. The existing
signtool-signed job remains as the control, and the install script now
also runs the installed executable.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015Hnro326ZTAu2EqUTGGkCB

* ci: integrate MSIX signature validation with merge queue checks

* fix(msix): derive publishers using Windows DN syntax

* fix: preserve address-only maintainer fallback

* fix(msix): Preserve signing errors without publisher defaults

Return the PFX loading failure before publisher validation when no vendor or maintainer fallback exists. Cover corrupt and missing PFX files and incorrect passphrases with and without fallback metadata.

* test(msix): Remove duplicate publisher display name test

* fix(msix): Validate publisher defaults and isolate signing attempts

Reject unsupported certificate subjects and invalid publisher metadata. Keep derived identities local to each packaging attempt, load signing credentials once, and reject explicit certificate mismatches. Honor explicitly empty MSIX passphrases in the standard environment parsers.

Cover signing retries, successful Info reuse, metadata boundaries, passwordless PFX files, and Windows SDK validation with signed positive and negative controls.

* test(msix): Cover parser entry points and invalid certificate subjects

* fix(msix): Match Windows T61 decoding and validate derived DNs

Preserve certificate ASN.1 value tags and apply Windows UTF-8-first decoding for T.61 strings, with the existing 8-bit fallback. Pass vendor values through only when the complete value is a valid Windows DN; otherwise quote them as CN values.

Cover raw T.61 subjects in native comparisons and signed packaging with derived and explicit publishers. Isolate the global-passphrase test from empty and nonempty ambient MSIX overrides.

* fix(msix): Fall back for invalid derived display names

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-12 01:15:55 +00:00

36 lines
1.3 KiB
Go

package maintainer_test
import (
"testing"
"github.com/goreleaser/nfpm/v2/internal/maintainer"
"github.com/stretchr/testify/require"
)
func TestName(t *testing.T) {
for in, want := range map[string]string{
"Jane Doe <jane@example.com>": "Jane Doe",
"Jane Doe": "Jane Doe",
" Jane Doe ": "Jane Doe",
"<jane@example.com>": "",
"jane@example.com": "jane@example.com",
`"Jane Doe" <jane@example.com>`: "Jane Doe",
`"Jane <Ops>" <jane@example.com>`: "Jane <Ops>",
`"Jane \"Ops\"" <jane@example.com>`: `Jane "Ops"`,
"": "",
} {
t.Run(in, func(t *testing.T) {
require.Equal(t, want, maintainer.Name(in))
})
}
}
func TestVendorOrMaintainer(t *testing.T) {
require.Equal(t, "ACME", maintainer.VendorOrMaintainer("ACME", "Jane Doe <jane@example.com>"))
require.Equal(t, "Jane Doe", maintainer.VendorOrMaintainer("", "Jane Doe <jane@example.com>"))
require.Equal(t, "ACME", maintainer.VendorOrMaintainer(" ACME\t", "Jane Doe <jane@example.com>"))
require.Equal(t, "Jane Doe", maintainer.VendorOrMaintainer(" \t ", "Jane Doe <jane@example.com>"))
require.Empty(t, maintainer.VendorOrMaintainer(" \t ", ""))
require.Empty(t, maintainer.VendorOrMaintainer("", ""))
}