Skip to content

Commit

Permalink
Marshal InstallEnterpriseApplication embedded manifest (#669)
Browse files Browse the repository at this point in the history
Marshal Assets of InstallEnterpriseApplication embedded manifest

Update to support SHA256, Metadata, and other related fields. Update tests to use and test for new fields.

Match JSON field names to the plist field names. The manifest field names don't follow typical CamelCase key names like normal Plists. It looks more like JSON. To avoid confusion just make them match. This makes it simpler to follow along with Apple's documentation when composing commands in JSON for the MicroMDM API. Otherwise we have to use our Go struct field names which are specific to us and nobody should need to figure that out (or really have to translate between the two). Update the test case to match.
  • Loading branch information
jessepeterson authored and groob committed Jun 21, 2020
1 parent f7ae36e commit 2b66390
Show file tree
Hide file tree
Showing 8 changed files with 521 additions and 252 deletions.
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -10,7 +10,7 @@ require (
github.com/go-sql-driver/mysql v1.4.0 // indirect
github.com/go-stack/stack v1.7.0 // indirect
github.com/gogo/protobuf v1.3.1
github.com/golang/protobuf v1.3.2
github.com/golang/protobuf v1.4.2
github.com/google/uuid v1.1.1
github.com/gorilla/context v1.1.1 // indirect
github.com/gorilla/mux v1.6.2
Expand Down
18 changes: 18 additions & 0 deletions go.sum
Expand Up @@ -22,6 +22,16 @@ github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
Expand Down Expand Up @@ -77,7 +87,15 @@ golang.org/x/sys v0.0.0-20180614134839-8883426083c0/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.2.0 h1:S0iUepdCWODXRvtE+gcRDd15L+k+k1AiHlMiMjefH24=
google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
gopkg.in/Masterminds/squirrel.v1 v1.0.0-20170825200431-a6b93000bd21 h1:GmGVIcDxdecAcVjcTp4IpK4VmCMxXhyZKwN2eIzsZ4Y=
gopkg.in/Masterminds/squirrel.v1 v1.0.0-20170825200431-a6b93000bd21/go.mod h1:8PH4rQjb7OdPC6OWDDuY6J/PT8iSNTiff3jmccc2m10=
29 changes: 16 additions & 13 deletions mdm/appmanifest/appmanifest.go
Expand Up @@ -15,34 +15,37 @@ const DefaultMD5Size = 10 << 20 // 10MB

// http://help.apple.com/deployment/osx/#/ior5df10f73a
type Manifest struct {
ManifestItems []Item `plist:"items"`
ManifestItems []Item `plist:"items" json:"items"`
}

type Item struct {
Assets []Asset `plist:"assets"`
Assets []Asset `plist:"assets" json:"assets"`
// Apple claims the metadata struct is required,
// but testing shows otherwise.
Metadata *Metadata `plist:"metadata,omitempty"`
Metadata *Metadata `plist:"metadata,omitempty" json:"metadata,omitempty"`
}

type Asset struct {
Kind string `plist:"kind"`
MD5Size int64 `plist:"md5-size"`
MD5s []string `plist:"md5s"`
URL string `plist:"url"`
Kind string `plist:"kind" json:"kind"`
MD5Size int64 `plist:"md5-size,omitempty" json:"md5-size,omitempty"`
MD5s []string `plist:"md5s,omitempty" json:"md5s,omitempty"`
SHA256Size int64 `plist:"sha256-size,omitempty" json:"sha256-size,omitempty"`
SHA256s []string `plist:"sha256s,omitempty" json:"sha256s,omitempty"`
URL string `plist:"url" json:"url"`
}

type Metadata struct {
BundleInfo
Items []BundleInfo `plist:"items,omitempty"`
Kind string `plist:"kind"`
Subtitle string `plist:"subtitle"`
Title string `plist:"title"`
Items []BundleInfo `plist:"items,omitempty" json:"items,omitempty"`
Kind string `plist:"kind" json:"kind"`
Subtitle string `plist:"subtitle" json:"subtitle"`
Title string `plist:"title" json:"title"`
SizeInBytes int64 `plist:"sizeInBytes,omitempty" json:"sizeInBytes,omitempty"`
}

type BundleInfo struct {
BundleIdentifier string `plist:"bundle-identifier"`
BundleVersion string `plist:"bundle-version"`
BundleIdentifier string `plist:"bundle-identifier" json:"bundle-identifier"`
BundleVersion string `plist:"bundle-version" json:"bundle-version"`
}

// File is an io.Reader which knows its size.
Expand Down

0 comments on commit 2b66390

Please sign in to comment.