fleet/orbit/pkg/table/codesign/codesign_darwin_test.go
Konstantin Sykulev a42167462f
Added SHA256 hash from mac apps on install paths (#29280)
https://github.com/fleetdm/fleet/issues/25545

- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.
- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for
new osquery data ingestion features.
- [x] Added/updated automated tests
- [x] Manual QA for all new/changed functionality
- For Orbit and Fleet Desktop changes:
- [ ] Make sure fleetd is compatible with the latest released version of
Fleet (see [Must
rule](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/workflows/fleetd-development-and-release-strategy.md)).
- [x] Orbit runs on macOS, Linux and Windows. Check if the orbit
feature/bugfix should only apply to one platform (`runtime.GOOS`).
- [x] Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.
- [ ] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).
2025-05-20 23:38:59 -05:00

38 lines
1.3 KiB
Go

package codesign
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestParseCodesignOutput(t *testing.T) {
output := []byte(`
Executable=/Applications/Xcode.app/Contents/MacOS/Xcode
Identifier=com.apple.dt.Xcode
Format=app bundle with Mach-O universal (x86_64 arm64)
CodeDirectory v=20400 size=790 flags=0x2000(library-validation) hashes=14+7 location=embedded
Hash type=sha256 size=32
CandidateCDHash sha1=21bbfcedb1ba1ed7078187432cf79234d65e290b
CandidateCDHashFull sha1=21bbfcedb1ba1ed7078187432cf79234d65e290b
CandidateCDHash sha256=cd1f004f0b0cd90c27d72375c7b9546b4c6df361
CandidateCDHashFull sha256=cd1f004f0b0cd90c27d72375c7b9546b4c6df3610868f18ae49ca50c8dfce2d9
Hash choices=sha1,sha256
CMSDigest=e4d43bc2286f60ee818e829f2f72b909c86b2235ec91a44290ec51fdc2f11897
CMSDigestType=2
CDHash=cd1f004f0b0cd90c27d72375c7b9546b4c6df361
Signature size=4797
Authority=Apple Mac OS Application Signing
Authority=Apple Worldwide Developer Relations Certification Authority
Authority=Apple Root CA
Info.plist entries=43
TeamIdentifier=59GAB85EFG
Sealed Resources version=2 rules=13 files=108583
Internal requirements count=1 size=220
`)
info := parseCodesignOutput(output)
require.Equal(t, "59GAB85EFG", info.teamIdentifier)
require.Equal(t, "cd1f004f0b0cd90c27d72375c7b9546b4c6df361", info.cdHash)
}