cocoapods-privacy 0.1.5 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cba814ac41f376631ff6ad61aa17f9079504ffdeca70d67745fbff6ba66a7f9a
4
- data.tar.gz: bc663a8c5bb09bdf7a63bda133bc9cef5a5b519a4abe63ddfc3a8581a23074ad
3
+ metadata.gz: 160e1e50e0b10ceb9008703a37b624861e89e48aa7626ba69db17d5958f57d11
4
+ data.tar.gz: 4d2f9bc6b15442f8759f22d3609716349281a2c33460bbfd55433d04362ae2a2
5
5
  SHA512:
6
- metadata.gz: 87fafdd3717866fa0bb684f5e836c8de9ede0f21d69e979f0c2335977e26bdd9c8ee68af46277be567735b64e3a9330090756f176f8e148eab70e9a776f47eb3
7
- data.tar.gz: d4021c5931c8439e21cfb45c99bb2d4a1601de30721e3fa0a636066aea9d614b83001163027ef346617de7e982ca7d0c94a347a430654938fe4fc844b4b4f2c9
6
+ metadata.gz: 040723e52f2c23ee4fbfe2f33469194faf9d48c6d6af0cc8aa901966ad15e89830e97f9e227a05565c2e988776bef53ab3ae8d789aacc860bb2bed6a365c441a
7
+ data.tar.gz: 3d239ca8ed9639bf88647ab5fb6802e55bfe011fa61417a26325806ca91b4f1dd5e9dc0ee4dffdd37f08c7803326f7401018d939067ed746a2745fb5c79686e4
data/README.md CHANGED
@@ -1,11 +1,84 @@
1
1
  # cocoapods-privacy
2
2
 
3
- A description of cocoapods-privacy.
3
+ Apple 2024 will review the App's privacy list in the spring, and any apps that don't submit a privacy list may be called back. For now, the privacy list is broken down by component, to facilitate the maintenance of component privacy, cocoapods-privacy is developed for management.
4
+ [Click to view details on Apple](https://developer.apple.com/documentation/bundleresources/privacy_manifest_files)
4
5
 
5
6
  ## Installation
6
-
7
- $ gem install cocoapods-privacy
7
+ ```
8
+ $ gem install cocoapods-privacy
9
+ ```
8
10
 
9
11
  ## Usage
12
+ #### init
13
+ First of all, you must set a json config to cocoapods-privacy, this is a defalut config.json
14
+ ```
15
+ $ pod privacy config https://raw.githubusercontent.com/ymoyao/cocoapods-privacy/main/resources/config.json
16
+ ```
17
+
18
+ There has 3 keys in defalut config, you should custom it!
19
+ * source.white.list : a white list of source, defalut is empty, so, you should add you self component sources, and it work in command 'pod privacy install' or 'pod install --privacy', will search white list for NSPrivacyAccessedAPITypes.
20
+ * source.black.list : a black list of source, defalut is empty, it work in command 'pod privacy install' or 'pod install --privacy'.
21
+ * api.template.url : its required, a template for search NSPrivacyAccessedAPITypes
22
+ ```
23
+ "source.white.list": ["replace me with yourserver"],
24
+ "source.black.list": ["replace me such as github.com"],
25
+ "api.template.url": "https://raw.githubusercontent.com/ymoyao/cocoapods-privacy/main/resources/NSPrivacyAccessedAPITypes.plist"
26
+ ```
27
+
28
+ #### To Component
29
+ ```
30
+ $ pod privacy spec [podspec_file_path]
31
+ ```
32
+ This command will auto create privacy file, and search the path of podspec' source_files' define relate to NSPrivacyAccessedAPITypes, finaly, write to PrivacyInfo.xcprivacy file.
33
+ if your component has much subspec, all subspec that define ‘source_files’ will create PrivacyInfo.xcprivacy, and auto modify .podspec link .xcprivacy to 'resource_bundle' key.
34
+ For example
35
+ * origin podspec
36
+
37
+ ```
38
+ Pod::Spec.new do |s|
39
+ s.name = 'Demo'
40
+ ...
41
+ s.source_files = 'xxxx'
42
+ s.subspec 'idfa' do |sp|
43
+ sp.source_files = 'xxxxx'
44
+ end
45
+ s.subspec 'noidfa' do |sp|
46
+ end
47
+ end
48
+
49
+ ```
50
+
51
+ * podspec after commad 👇👇👇👇👇👇
52
+ ```
53
+ Pod::Spec.new do |s|
54
+ s.name = 'Demo'
55
+ ...
56
+ s.source_files = 'xxxx'
57
+ s.resource_bundle = {"Demo.privacy"=>"Pod/Privacy/Demo/PrivacyInfo.xcprivacy"}
58
+ s.subspec 'idfa' do |sp|
59
+ sp.source_files = 'xxxxx'
60
+ sp.resource_bundle = {"Demo.idfa.privacy"=>"Pod/Privacy/Demo.idfa/PrivacyInfo.xcprivacy"}
61
+ end
62
+ s.subspec 'noidfa' do |sp|
63
+ end
64
+ end
65
+ ```
66
+ <img width="961" alt="截屏2024-02-02 11 23 21" src="https://github.com/ymoyao/cocoapods-privacy/assets/13619221/a6678c8e-c4aa-4f7d-8881-657c6d703657">
67
+
68
+
69
+
70
+ #### To Project
71
+ ```
72
+ $ pod install --privacy
73
+ or
74
+ $ pod privacy install
75
+ ```
76
+ <img width="298" alt="截屏2024-02-02 10 59 59" src="https://github.com/ymoyao/cocoapods-privacy/assets/13619221/c6f10e36-0f62-497a-93d4-f8b336dc8df4">
77
+
78
+ After command, a PrivacyInfo.xcprivacy will create to you project Resources if empty. and it will search component that configuration files allow and do not have their own privacy manifest file.
79
+
80
+ ## Notice
81
+ The plugin is focus on NSPrivacyAccessedAPITypes and automatically search and create workflow.
82
+ you should manager NSPrivacyCollectedDataTypes by yourself!
83
+
10
84
 
11
- $ pod spec privacy POD_NAME
@@ -1,3 +1,3 @@
1
1
  module CocoapodsPrivacy
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.7"
3
3
  end
@@ -116,35 +116,54 @@ module PrivacyHunter
116
116
  local_file_path = File.join(PrivacyUtils.cache_privacy_fold, 'NSPrivacyAccessedAPITypes.plist')
117
117
 
118
118
  # 获取远程文件更新时间
119
- remote_file_time = remoteFileTime?(template_url)
119
+ remote_file_time,etag = remoteFile?(template_url)
120
120
 
121
121
  # 判断本地文件的最后修改时间是否与远端文件一致,如果一致则不进行下载
122
- if File.exist?(local_file_path) && file_identical?(local_file_path, remote_file_time)
122
+ if File.exist?(local_file_path) && file_identical?(local_file_path, remote_file_time,etag)
123
123
  else
124
124
  # 使用 curl 下载文件
125
125
  system("curl -o #{local_file_path} #{template_url}")
126
126
  puts "隐私清单模版文件已更新到: #{local_file_path}"
127
127
 
128
- # 同步远程文件时间到本地文件
129
- syncFileTime?(local_file_path,remote_file_time)
128
+ # 同步远程文件标识(时间或者etag)
129
+ syncFile?(local_file_path,remote_file_time,etag)
130
130
  end
131
131
 
132
132
  local_file_path
133
133
  end
134
134
 
135
135
  # 获取远程文件更新时间
136
- def self.remoteFileTime?(remote_url)
136
+ def self.remoteFile?(remote_url)
137
137
  uri = URI.parse(remote_url)
138
138
  http = Net::HTTP.new(uri.host, uri.port)
139
139
  http.use_ssl = (uri.scheme == 'https')
140
140
  response = http.request_head(uri.path)
141
141
 
142
- response['Last-Modified']
142
+ last_modified = response['Last-Modified']
143
+ etag = response['ETag']
144
+
145
+ [last_modified,etag]
143
146
  end
144
147
 
145
148
  # 判断本地文件的最后修改时间与远端文件的最后修改时间是否一致
146
- def self.file_identical?(local_file_path, remote_file_time)
147
- remote_file_time && Time.parse(remote_file_time) == File.mtime(local_file_path)
149
+ def self.file_identical?(local_file_path, remote_file_time, etag)
150
+ if remote_file_time
151
+ remote_file_time && Time.parse(remote_file_time) == File.mtime(local_file_path)
152
+ elsif etag
153
+ File.exist?(File.join(PrivacyUtils.cache_privacy_etag_fold,etag))
154
+ else
155
+ false
156
+ end
157
+ end
158
+
159
+
160
+ # 同步文件标识
161
+ def self.syncFile?(local_file_path, remote_file_time, etag)
162
+ if remote_file_time
163
+ syncFileTime?(local_file_path,remote_file_time)
164
+ elsif etag
165
+ PrivacyUtils.create_file_and_fold_if_no_exit(File.join(PrivacyUtils.cache_privacy_etag_fold,etag))
166
+ end
148
167
  end
149
168
 
150
169
  # 同步远程文件时间到本地文件
@@ -174,11 +174,13 @@ module PrivacyModule
174
174
 
175
175
  # 处理组件
176
176
  def self.load_module(podspec_file_path)
177
+ puts "👇👇👇👇👇👇 Start analysis component privacy 👇👇👇👇👇👇"
177
178
  privacy_hash = PrivacyModule.check(podspec_file_path)
178
179
  privacy_hash.each do |privacy_file_path, source_files|
179
180
  data = PrivacyHunter.search_pricacy_apis(source_files)
180
181
  PrivacyHunter.write_to_privacy(data,privacy_file_path) unless data.empty?
181
182
  end
183
+ puts "👆👆👆👆👆👆 End analysis component privacy 👆👆👆👆👆👆"
182
184
  end
183
185
 
184
186
  def self.check(podspec_file_path)
@@ -61,6 +61,12 @@ module PrivacyUtils
61
61
  target_directory
62
62
  end
63
63
 
64
+ # etag 文件夹
65
+ def self.cache_privacy_etag_fold
66
+ File.join(cache_privacy_fold,'etag')
67
+ end
68
+
69
+ # config.json 文件
64
70
  def self.cache_config_file
65
71
  config_file = File.join(cache_privacy_fold, 'config.json')
66
72
  end
@@ -74,6 +74,8 @@ module Pod
74
74
 
75
75
 
76
76
  def privacy_handle(custom_folds)
77
+
78
+ puts "👇👇👇👇👇👇 Start analysis project privacy 👇👇👇👇👇👇"
77
79
  # 过滤出自身组件 && 自身没有隐私协议文件的spec
78
80
  modules = @analysis_result.specifications.select {
79
81
  |obj| obj.is_need_search_module && !obj.has_privacy
@@ -96,8 +98,12 @@ module Pod
96
98
  podspec_fold_path = File.dirname(podspec_file_path)
97
99
  source_files = spec.attributes_hash['source_files']
98
100
  if source_files && !source_files.empty?
99
- source_files.each do |file|
100
- development_folds << File.join(podspec_fold_path,file)
101
+ if source_files.is_a?(String) && !source_files.empty?
102
+ development_folds << File.join(podspec_fold_path,source_files)
103
+ elsif source_files.is_a?(Array)
104
+ source_files.each do |file|
105
+ development_folds << File.join(podspec_fold_path,file)
106
+ end
101
107
  end
102
108
  end
103
109
  end
@@ -118,6 +124,7 @@ module Pod
118
124
  # 处理工程隐私协议
119
125
  PrivacyModule.load_project(pod_folds)
120
126
  end
127
+ puts "👆👆👆👆👆👆 End analysis project privacy 👆👆👆👆👆👆"
121
128
  end
122
129
  end
123
130
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-privacy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - youhui
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-01 00:00:00.000000000 Z
11
+ date: 2024-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler