apple-data 1.0.650 → 1.0.651

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2dc425f46f36d461a492ecf9f1a95df5c7e3a9675b88b08647e2530b9cc901a
4
- data.tar.gz: 3111575be969f6d1a531a4e58ad62065131ffe4280e695192ec439682feb2fd9
3
+ metadata.gz: e0c08f469c75dfae827884566fe4ce755af8498b7796c3386fa480a069146ac0
4
+ data.tar.gz: 4a024ac00342adc29f4a51e9db9e8db1569873e619cefd72801fc712c8b5e91d
5
5
  SHA512:
6
- metadata.gz: 85861d964d97dff7e43c569fbe5c4dc0b77dc04ac8ba21f0eb52fa71b17815dac627285822b25893fab0756654b51ca752c46a6aceef884c1981305d851a3648
7
- data.tar.gz: bb377aea5b290a06069c533625353f0de2826cf6c387ad283f092002c8b5e728913b4ecda9d9abb35c0e3835e188da1d6b25842e68bbaed6200d6f13cb374afb
6
+ metadata.gz: c7b8ff4a5926f27d734326b1c824036038b74480852033d7a44de883456c87ef49e4d4833c4942bfab685e42d9aaff349ee03c46ad8961f88bc3d39d6542fed0
7
+ data.tar.gz: 06c32e5eb6fa6ac49a7711381bd6269e032f53f3abb82acd83c29f564c797dedb0cab57c71fc0c6a3b4a8019f543f198aa4806b5fb60b18931c6bfb0a28ab619
@@ -1,17 +1,31 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/all'
4
- require 'jsonpath'
5
-
6
3
  module AppleData
7
4
  # Base class for all data files
8
5
  class DataFile
6
+ def self.define(&)
7
+ dsl = AppleData::DSL::DataFileDefinition.new
8
+ dsl.instance_eval(&)
9
+ dsl.build!
10
+ end
11
+
12
+ def self.inherited(klass)
13
+ super
14
+ @data_files ||= []
15
+ @data_files << klass
16
+ end
17
+
18
+ def self.all
19
+ @data_files
20
+ end
21
+
9
22
  attr_reader :data
10
23
 
11
24
  def initialize(*parts)
12
25
  @parts = parts
26
+ @parts = [self.class.const_get(:DEFAULT_FILENAME)] if @parts.empty?
13
27
  @collections = {}
14
- load_file(*parts)
28
+ load_file(*@parts)
15
29
  ensure_metadata
16
30
  end
17
31
 
@@ -27,11 +41,12 @@ module AppleData
27
41
  end
28
42
 
29
43
  def load_file(*parts)
30
- parts[-1] = "#{parts[-1]}.yaml" unless T.must(parts[-1]).end_with? '.yaml'
31
- @filename = File.join(AppleData.data_location, T.unsafe(File).join(*parts))
44
+ parts[-1] = "#{parts[-1]}.yaml" unless parts[-1].end_with? '.yaml'
45
+ @filename = File.join(AppleData.data_location, File.join(*parts))
32
46
  @data = {}
33
47
  @data = YAML.load_file @filename if File.exist? @filename
34
- @data.with_indifferent_access
48
+ @data.deep_symbolize_keys!
49
+ @data = @data.with_indifferent_access
35
50
  end
36
51
 
37
52
  def save!
@@ -120,5 +135,31 @@ module AppleData
120
135
  end
121
136
  end
122
137
  end
138
+
139
+ def construct_array(collection_definition, value)
140
+ value.data.map do |item|
141
+ if collection_definition.mapper
142
+ collection_definition.mapper.from_hash(item)
143
+ else
144
+ item
145
+ end
146
+ end
147
+ end
148
+
149
+ def construct_hash(collection_definition, value)
150
+ result = value.data.map do |key, item|
151
+ instance = if item
152
+ if collection_definition.mapper
153
+ collection_definition.mapper.from_hash(item)
154
+ else
155
+ item
156
+ end
157
+ end
158
+ instance.key = key if instance.respond_to? :key=
159
+ [key, instance]
160
+ end
161
+
162
+ result.to_h
163
+ end
123
164
  end
124
165
  end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppleData
4
+ module DSL
5
+ # A definition of a collection of objects, with a particular schema
6
+ class CollectionDefinition
7
+ attr_reader :name
8
+ attr_accessor :mapper
9
+
10
+ def initialize(name, mapper)
11
+ @name = name
12
+ @mapper = mapper
13
+ end
14
+
15
+ # Builds the collection into the given data file class
16
+ def build!(klass)
17
+ name = @name
18
+ klass.instance_eval do
19
+ define_method(name) do
20
+ @mapped_collections ||= {}
21
+ if @mapped_collections[name].nil?
22
+ collection_definition = self.class.const_get(:COLLECTIONS)[name]
23
+
24
+ value = collection(name.to_s)
25
+ result = case value.data
26
+ when Hash
27
+ construct_hash(collection_definition, value)
28
+ when Array
29
+ construct_array(collection_definition, value)
30
+ else
31
+ value.data
32
+ end
33
+
34
+ @mapped_collections[name] = result
35
+ end
36
+
37
+ @mapped_collections[name]
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppleData
4
+ module DSL
5
+ # The DSL that is used when defining a data file
6
+ class DataFileDefinition
7
+ def initialize
8
+ @collections = {}
9
+ end
10
+
11
+ def collection(name, mapper = nil, &)
12
+ @collections[name] = AppleData::DSL::CollectionDefinition.new(name, mapper)
13
+ if block_given? && @collections[name].mapper.nil?
14
+ @collections[name].mapper = Class.new(AppleData::SchemaBase)
15
+ @collections[name].mapper.class_eval(&)
16
+ end
17
+ @collections[name]
18
+ end
19
+
20
+ attr_writer :default_filename
21
+
22
+ def build!
23
+ klass = Class.new(DataFile)
24
+
25
+ klass.const_set(:DEFAULT_FILENAME, @default_filename)
26
+ klass.const_set(:COLLECTIONS, @collections)
27
+
28
+ @collections.each_value do |collection_definition|
29
+ collection_definition.build!(klass)
30
+ end
31
+
32
+ klass
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppleData
4
+ module Models
5
+ module IMG4
6
+ # IMG4 "objects" are either a reference to a file, or some other structured set of properties
7
+ class Object < AppleData::Models::IMG4::Tag
8
+ attribute :encoding, :string
9
+ attribute :firmware_name, :string
10
+ attribute :recovery, :boolean
11
+ attribute :restore, :boolean
12
+ attribute :firmware, :boolean
13
+ attribute :subtype, :string
14
+ attribute :manifest, :boolean
15
+ attribute :nullable, :boolean
16
+ attribute :roots, :string, collection: true
17
+ attribute :metadata, :string, collection: true
18
+ attribute :values, :string, collection: true
19
+ attribute :width, :integer
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppleData
4
+ module Models
5
+ module IMG4
6
+ # An IMG4 property is a name and a value
7
+ class Property < AppleData::Models::IMG4::Tag
8
+ attribute :roots, :string, collection: true
9
+ attribute :example, :string
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppleData
4
+ module Models
5
+ module IMG4
6
+ # Generic IMG4 DER "tag"
7
+ class Tag < Shale::Mapper
8
+ attr_accessor :key
9
+
10
+ attribute :name, :string
11
+ attribute :description, :string
12
+ attribute :title, :string
13
+ attribute :alias, :string, collection: true
14
+ attribute :example, :string
15
+ attribute :type, :string
16
+
17
+ def to_s
18
+ name || title || description || key
19
+ end
20
+
21
+ def to_sym
22
+ to_s.to_sym
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppleData
4
+ module Models
5
+ # The metadata common to all Apple Data models
6
+ class Metadata < AppleData::SchemaBase
7
+ attribute :credits, :string, collection: true
8
+ attribute :description, :string
9
+ attribute :auto_sort, :boolean
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppleData
4
+ class SchemaBase < Shale::Mapper
5
+ end
6
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ AppleData::Schemas::FactoryDataRestore = AppleData::DataFile.define do
4
+ self.default_filename = 'fdr'
5
+
6
+ collection :fdr_modes do
7
+ attribute :description, :string
8
+ end
9
+
10
+ collection :fdr_objects, AppleData::Models::IMG4::Object
11
+
12
+ collection :fdr_properties, AppleData::Models::IMG4::Property
13
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ AppleData::Schemas::IMG4 = AppleData::DataFile.define do
4
+ self.default_filename = 'img4'
5
+
6
+ collection :unmapped
7
+
8
+ collection :core, AppleData::Models::IMG4::Tag
9
+ collection :lpol_properties, AppleData::Models::IMG4::Property
10
+ collection :cryptex_properties, AppleData::Models::IMG4::Property
11
+ collection :cryptex_objects, AppleData::Models::IMG4::Object
12
+ collection :manifest_properties, AppleData::Models::IMG4::Property
13
+ collection :objects, AppleData::Models::IMG4::Object
14
+ collection :img4_tags, AppleData::Models::IMG4::Tag
15
+
16
+ collection :types do
17
+ attribute :description, :string
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ AppleData::Schemas::LocalPolicy = AppleData::DataFile.define do
4
+ self.default_filename = 'local_policy'
5
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ AppleData::Schemas::PKI = AppleData::DataFile.define do
4
+ self.default_filename = 'pki'
5
+
6
+ collection :certificate_names do
7
+ attribute :key, :string
8
+ attribute :name, :string
9
+ attribute :issuer, :string
10
+ end
11
+
12
+ collection :keys do
13
+ attribute :title, :string
14
+ attribute :certificates, :string, collection: true
15
+ end
16
+
17
+ collection :oids do
18
+ attribute :title, :string
19
+ attribute :type, :string
20
+ attribute :description, :string
21
+ attribute :apple_description, :string
22
+ attribute :found_in, :string, collection: true
23
+ attribute :issuers, :string, collection: true
24
+ attribute :ous, :string, collection: true
25
+ end
26
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AppleData
4
- VERSION = '1.0.650'
4
+ VERSION = '1.0.651'
5
5
  end
data/lib/apple_data.rb CHANGED
@@ -1,7 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'active_support/all'
4
+ require 'shale'
5
+ require 'zeitwerk'
6
+ require 'jsonpath'
7
+
3
8
  # Base Namespace for AppleData gem
4
9
  module AppleData
10
+ LOADER = Zeitwerk::Loader.new.tap do |loader|
11
+ loader.push_dir(__dir__)
12
+ loader.tag = 'apple-data'
13
+ loader.inflector.tap do |inflector|
14
+ inflector.inflect 'dsl' => 'DSL'
15
+ inflector.inflect 'img4' => 'IMG4'
16
+ inflector.inflect 'pki' => 'PKI'
17
+ end
18
+ loader.setup
19
+
20
+ loader.eager_load_dir(File.join(__dir__, 'apple_data/schemas'))
21
+ end
22
+
5
23
  DEFAULT_APPLE_DATA_SHARE = File.join(File.dirname(__FILE__), '../share/')
6
24
 
7
25
  def get_data(file)
@@ -16,9 +34,3 @@ module AppleData
16
34
  @apple_data || AppleData::DEFAULT_APPLE_DATA_SHARE
17
35
  end
18
36
  end
19
-
20
- require 'apple_data/data_file'
21
- require 'apple_data/factory_data_reset'
22
- require 'apple_data/io_reg'
23
- require 'apple_data/lockdown'
24
- require 'apple_data/keybag'
data/share/fdr.yaml CHANGED
@@ -5,7 +5,7 @@ metadata:
5
5
  collections:
6
6
  - fdr_properties
7
7
  fdr_modes:
8
- '':
8
+ base:
9
9
  description: Objects for the device directly, indicates no factory process or
10
10
  mode in use.
11
11
  mansta:
@@ -97,7 +97,7 @@ fdr_properties:
97
97
  comb:
98
98
  description: Combined FDR object
99
99
  dCfg:
100
- description: Display LCD
100
+ description:
101
101
  contexts:
102
102
  - base
103
103
  - mansta
@@ -152,11 +152,12 @@ fdr_properties:
152
152
  - base
153
153
  - mansta
154
154
  meid:
155
- description: Mobile Equipment Identifier (CMDA)
155
+ title: Mobile Equipment Identifier (CMDA)
156
156
  mft2:
157
157
  mlb#:
158
- description: Main Logic Board Serial Number
158
+ title: Main Logic Board Serial Number
159
159
  mmap:
160
+ title: Memory Map
160
161
  description: The memory map passed from the iBoot loader to the Kernel
161
162
  nuid:
162
163
  description:
@@ -204,7 +205,8 @@ fdr_properties:
204
205
  title: Recovery SSL
205
206
  description: Root SSL / TLS certificate
206
207
  rvok:
207
- description: Trust Object Revocation
208
+ title: Revocation List
209
+ description: FDR trust object list of revoked certificates / public keys
208
210
  scrt:
209
211
  description: SEP Certificate
210
212
  contexts:
@@ -213,7 +215,9 @@ fdr_properties:
213
215
  description: Point Compressed Elliptic Curve point sering as the master Public
214
216
  Key for the SE
215
217
  seal:
216
- description:
218
+ title: FDR Sealing Object
219
+ description: Used to provide a cryptographic seal of the data that is restored
220
+ to the device via FDR to prevent tampering with said data.
217
221
  contexts:
218
222
  - base
219
223
  secb:
@@ -231,7 +235,9 @@ fdr_properties:
231
235
  title: Trusted Public Keys
232
236
  description: Trusted Public Key
233
237
  trst:
234
- description: Trust Object
238
+ title: Trust Object
239
+ description: The various data required to connect to FDR, includes the remote
240
+ SSL root, revocation list, and trusted public keys
235
241
  tsid:
236
242
  description:
237
243
  vcrt:
data/share/img4.yaml CHANGED
@@ -1019,7 +1019,7 @@ objects:
1019
1019
  rdtr:
1020
1020
  title: Restore Device Tree
1021
1021
  description:
1022
- firmware_name: RestoreDeviceTree
1022
+ firmware_name: RestoreDeviceTree
1023
1023
  recm:
1024
1024
  description: Recovery Mode
1025
1025
  firmware_name: RecoveryMode
data/share/pki.yaml CHANGED
@@ -7,18 +7,27 @@ metadata:
7
7
  - keys
8
8
  - oids
9
9
  certificate_names:
10
- dcrt: Device Identity Certificate
11
- dcrt-oid: Device Owner Identity Certificate
12
- lcrt: Lynx / Secure Storage for SEP Certificate
13
- pcrt: product/production certificate?
14
- rcrt: remote/recovery certificate?
15
- scrt: SEP Certificate
16
- sdcrt: SEP Device Certificate
17
- tcrt: test certificate?
10
+ dcrt:
11
+ name: Device Identity Certificate
12
+ dcrt-oid:
13
+ name: Device Owner Identity Certificate
14
+ lcrt:
15
+ name: Lynx / Secure Storage for SEP Certificate
16
+ pcrt:
17
+ name: Protected Certificate
18
+ rcrt:
19
+ name: remote/recovery certificate?
20
+ scrt:
21
+ name: SEP Certificate
22
+ sdcrt:
23
+ name: SEP Device Certificate
24
+ tcrt:
25
+ name: test certificate?
18
26
  ucrt:
19
27
  name: User Identity Certificate
20
28
  issuer: Basic Attestation User Root CA
21
- vcrt: virtual certificate?
29
+ vcrt:
30
+ name: virtual certificate?
22
31
  keys:
23
32
  oik:
24
33
  title: Owner Identity Key
metadata CHANGED
@@ -1,14 +1,84 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apple-data
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.650
4
+ version: 1.0.651
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rick Mark
8
8
  bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
- dependencies: []
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: activesupport
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: jsonpath
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: pathutil
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: shale
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: zeitwerk
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ type: :runtime
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
12
82
  description: |2
13
83
  This package includes machine readable data about Apple platforms maintained by hack-different.
14
84
 
@@ -21,14 +91,24 @@ extra_rdoc_files:
21
91
  - README.md
22
92
  files:
23
93
  - README.md
24
- - lib/apple-data.rb
25
94
  - lib/apple_data.rb
26
95
  - lib/apple_data/data_file.rb
96
+ - lib/apple_data/dsl/collection_definition.rb
97
+ - lib/apple_data/dsl/data_file_definition.rb
27
98
  - lib/apple_data/factory_data_reset.rb
28
99
  - lib/apple_data/io_reg.rb
29
100
  - lib/apple_data/ipsw.rb
30
101
  - lib/apple_data/keybag.rb
31
102
  - lib/apple_data/lockdown.rb
103
+ - lib/apple_data/models/img4/object.rb
104
+ - lib/apple_data/models/img4/property.rb
105
+ - lib/apple_data/models/img4/tag.rb
106
+ - lib/apple_data/models/metadata.rb
107
+ - lib/apple_data/schema_base.rb
108
+ - lib/apple_data/schemas/factory_data_restore.rb
109
+ - lib/apple_data/schemas/img4.rb
110
+ - lib/apple_data/schemas/local_policy.rb
111
+ - lib/apple_data/schemas/pki.rb
32
112
  - lib/apple_data/version.rb
33
113
  - share/apns.yaml
34
114
  - share/backup.yaml
@@ -288,7 +368,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
288
368
  requirements:
289
369
  - - ">="
290
370
  - !ruby/object:Gem::Version
291
- version: '3.1'
371
+ version: '3.3'
292
372
  required_rubygems_version: !ruby/object:Gem::Requirement
293
373
  requirements:
294
374
  - - ">="
data/lib/apple-data.rb DELETED
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'apple_data'