cocoapods-privacy 0.2.0 → 0.2.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aca165884812e22b5b99ff4220a5a87129f9b56f5940b95f32cea856418e8c32
|
4
|
+
data.tar.gz: fcfbee202add9d50cff29d74c5bf8b1558855daca7278905a25922d9674c40c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c61d2467300415d231fab11762e54c8a5e17ec7fb91f47af5f3aff9db72c85b30353d505354642e420513059bd7227bcb88a31f921d44929a9ba66150e626c7
|
7
|
+
data.tar.gz: 90718eb044f351c618a7a7c9490f156e010053083668aad75f31f6b5b7b95fca4142785193286b8b92008a3b7cc954b7724a7c1bc04a05786929ec290016aabb
|
@@ -108,13 +108,11 @@ module PrivacyHunter
|
|
108
108
|
|
109
109
|
# 删除临时文件
|
110
110
|
File.delete(temp_plist)
|
111
|
-
|
112
111
|
end
|
113
112
|
|
114
113
|
|
115
114
|
private
|
116
115
|
|
117
|
-
|
118
116
|
def self.fetch_template_plist_file
|
119
117
|
|
120
118
|
unless File.exist?(PrivacyUtils.cache_config_file)
|
@@ -200,6 +198,8 @@ module PrivacyHunter
|
|
200
198
|
|
201
199
|
#搜索所有子文件夹
|
202
200
|
def self.search_files(folder_paths, apis)
|
201
|
+
#清除上一次log
|
202
|
+
clean_log()
|
203
203
|
|
204
204
|
# 获取文件夹下所有文件(包括子文件夹)
|
205
205
|
all_files = []
|
@@ -218,10 +218,33 @@ module PrivacyHunter
|
|
218
218
|
# 遍历文件进行检索
|
219
219
|
apis_found = {}
|
220
220
|
all_files.uniq.each_with_index do |file_path, index|
|
221
|
-
|
222
|
-
|
221
|
+
api_contains = contains_apis?(file_path, apis)
|
222
|
+
apis_found = apis_found.merge(api_contains)
|
223
|
+
|
224
|
+
unless api_contains.empty?
|
225
|
+
log = "File #{file_path} contains the keyword '#{api_contains.keys}'.\n"
|
226
|
+
write_log(log)
|
227
|
+
end
|
223
228
|
end
|
229
|
+
puts "详细log请查看 #{PrivacyUtils.cache_log_file} 文件"
|
224
230
|
apis_found
|
225
231
|
end
|
232
|
+
|
233
|
+
def self.write_log(log)
|
234
|
+
log_file_path = PrivacyUtils.cache_log_file
|
235
|
+
is_create = PrivacyUtils.create_file_and_fold_if_no_exit(log_file_path,log)
|
236
|
+
unless is_create
|
237
|
+
File.open(log_file_path, "a") do |file|
|
238
|
+
file << log
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
def self.clean_log()
|
244
|
+
File.open(PrivacyUtils.cache_log_file, "w") do |file|
|
245
|
+
# 写入空字符串,清空文件内容
|
246
|
+
file.write("")
|
247
|
+
end
|
248
|
+
end
|
226
249
|
end
|
227
250
|
|
@@ -71,6 +71,11 @@ module PrivacyUtils
|
|
71
71
|
config_file = File.join(cache_privacy_fold, 'config.json')
|
72
72
|
end
|
73
73
|
|
74
|
+
# config.json 文件
|
75
|
+
def self.cache_log_file
|
76
|
+
config_file = File.join(cache_privacy_fold, 'privacy.log')
|
77
|
+
end
|
78
|
+
|
74
79
|
# 创建默认隐私协议文件
|
75
80
|
def self.create_privacy_if_empty(file_path)
|
76
81
|
# 文件内容
|
@@ -88,33 +88,29 @@ module Pod
|
|
88
88
|
pod_folds = modules.map{ |spec|
|
89
89
|
name = spec.name.split('/').first
|
90
90
|
fold = File.join(@sandbox.root,name)
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
if
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
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
|
107
|
-
end
|
91
|
+
podspec_file_path_develop = validate_development_pods(name)
|
92
|
+
# 先验证是否是指向本地的组件(发现有的情况下 组件指向本地Pods 下依旧还是会有该组件,所以这里先判断本地的)
|
93
|
+
if podspec_file_path_develop
|
94
|
+
podspec_fold_path = File.dirname(podspec_file_path_develop)
|
95
|
+
source_files = spec.attributes_hash['source_files']
|
96
|
+
if source_files && !source_files.empty?
|
97
|
+
if source_files.is_a?(String) && !source_files.empty?
|
98
|
+
development_folds << File.join(podspec_fold_path,source_files)
|
99
|
+
elsif source_files.is_a?(Array)
|
100
|
+
source_files.each do |file|
|
101
|
+
development_folds << File.join(podspec_fold_path,file)
|
108
102
|
end
|
109
103
|
end
|
110
104
|
end
|
111
105
|
nil
|
106
|
+
elsif Dir.exist?(fold)
|
107
|
+
formatter_search_fold(fold)
|
112
108
|
end
|
113
109
|
}.compact
|
114
110
|
|
115
111
|
|
116
112
|
pod_folds += development_folds # 拼接本地调试和远端的pod目录
|
117
|
-
pod_folds += [PrivacyUtils.project_code_fold].compact # 拼接工程同名主目录
|
113
|
+
pod_folds += [formatter_search_fold(PrivacyUtils.project_code_fold)].compact # 拼接工程同名主目录
|
118
114
|
pod_folds += custom_folds || [] # 拼接外部传入的自定义目录
|
119
115
|
pod_folds = pod_folds.uniq # 去重
|
120
116
|
|
@@ -126,5 +122,22 @@ module Pod
|
|
126
122
|
end
|
127
123
|
puts "👆👆👆👆👆👆 End analysis project privacy 👆👆👆👆👆👆"
|
128
124
|
end
|
125
|
+
|
126
|
+
private
|
127
|
+
def formatter_search_fold(fold)
|
128
|
+
File.join(fold,"**","*.{m,c,swift,mm,hap,hpp,cpp}")
|
129
|
+
end
|
130
|
+
|
131
|
+
def validate_development_pods(name)
|
132
|
+
result = nil
|
133
|
+
development_pods = @sandbox.development_pods
|
134
|
+
if name && !name.empty? development_pods && !development_pods.empty?
|
135
|
+
podspec_file_path = development_pods[name]
|
136
|
+
if podspec_file_path && !podspec_file_path.empty?
|
137
|
+
result = podspec_file_path
|
138
|
+
end
|
139
|
+
end
|
140
|
+
result
|
141
|
+
end
|
129
142
|
end
|
130
143
|
end
|