cocoapods-privacy 0.3.1 → 0.5.0

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: f53ab1a6e9bcc1fba9dd87e461f210987d811c275cf06e8a0d135fd26dde68d7
4
- data.tar.gz: b5052cb3dfa12e1a94d8dc388c0d477744198a2ac797fa663f016ef7e757ef1c
3
+ metadata.gz: af764f50aa1f71cc51ccaf244e74058ebc3cb3a3b98e7ecfe108b49735a4ebe8
4
+ data.tar.gz: d53d311a76e6d9da2db85111b6fdc2337aecdb9d3c7a2c27f4ad520877fc09e6
5
5
  SHA512:
6
- metadata.gz: 487d62cd0804642bd8cf744c20b2c454b2893568e52d640ceefcb62ef8175fbe09732b1afb7118f59535e825f993623b727a3929ed5c032bc3c9091285e8bd53
7
- data.tar.gz: c398225bbecd92614e5b99d63d5b520c66ba6d0ff6cd270db6674724b6d56e6c492d4b4284e3dd3f23bdf38d77525ef63f35efeafbc8ce13d05de7991bb8243d
6
+ metadata.gz: 20cc27ab523c135e09b55fcf8fdaedc59c9f7847000c737a55c9bc565c8a9373be829e26a0c1f590e0e33dcef6f97008ddf76c88bf24b7332103a935fcb092bf
7
+ data.tar.gz: 890d80538261123f23019dffb0726d04997a6ecfed5f0b42ef04f45768b86e34b782f0d0d051d60dbf2d27eac56f526bb68bf63cc41d80afde757a06d7712293
@@ -4,6 +4,8 @@ module Pod
4
4
  class Config
5
5
  attr_accessor :privacy_folds
6
6
  attr_accessor :is_privacy
7
+ attr_accessor :is_query
8
+ attr_accessor :is_all
7
9
  end
8
10
  end
9
11
 
@@ -16,6 +18,8 @@ module Pod
16
18
  [
17
19
  ['--privacy', '使用该参数,会自动生成并更新PrivacyInfo.xcprivacy'],
18
20
  ['--privacy-folds=folds', '指定文件夹检索,多个文件夹使用逗号","分割'],
21
+ ['--query', '仅查询隐私api,不做写入'],
22
+ ['--all', '忽略黑名单和白名单限制,查询工程所有组件'],
19
23
  ].concat(origin_options)
20
24
  end
21
25
  end
@@ -24,10 +28,14 @@ module Pod
24
28
  def initialize(argv)
25
29
  privacy_folds = argv.option('privacy-folds', '').split(',')
26
30
  is_privacy = argv.flag?('privacy',false)
31
+ is_query = argv.flag?('query',false)
32
+ is_all = argv.flag?('all',false)
27
33
  privacy_origin_initialize(argv)
28
34
  instance = Pod::Config.instance
29
35
  instance.privacy_folds = privacy_folds
30
36
  instance.is_privacy = is_privacy
37
+ instance.is_query = is_query
38
+ instance.is_all = is_all
31
39
  end
32
40
  end
33
41
  end
@@ -13,11 +13,18 @@ module Pod
13
13
  def self.options
14
14
  [
15
15
  ["--folds=folds", '传入自定义搜索文件夹,多个文件目录使用“,”分割'],
16
+ ['--query', '仅查询隐私api,不做写入'],
17
+ ['--all', '忽略黑名单和白名单限制,查询工程所有组件'],
16
18
  ].concat(super)
17
19
  end
18
20
 
19
21
  def initialize(argv)
20
22
  @folds = argv.option('folds', '').split(',')
23
+ is_query = argv.flag?('query',false)
24
+ is_all = argv.flag?('all',false)
25
+ instance = Pod::Config.instance
26
+ instance.is_query = is_query
27
+ instance.is_all = is_all
21
28
  super
22
29
  end
23
30
 
@@ -1,3 +1,3 @@
1
1
  module CocoapodsPrivacy
2
- VERSION = "0.3.1"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -77,6 +77,10 @@ module PrivacyHunter
77
77
 
78
78
 
79
79
  def self.write_to_privacy(json_data,privacy_path)
80
+
81
+ # 如果指定了--query 参数,那么不进行写入操作,仅用来查询
82
+ return if Pod::Config.instance.is_query
83
+
80
84
  # 转换 JSON 为 plist 格式
81
85
  plist_data = `echo '#{json_data}' | plutil -convert xml1 - -o -`
82
86
 
@@ -227,7 +231,7 @@ module PrivacyHunter
227
231
  apis_found = {}
228
232
  all_files.each_with_index do |file_path, index|
229
233
  api_contains = contains_apis?(file_path, apis)
230
- apis_found = apis_found.merge(api_contains)
234
+ apis_found = apis_found.merge(api_contains) unless Pod::Config.instance.is_query # 如果指定了--query 参数,那么不进行写入操作,仅用来查询
231
235
 
232
236
  unless api_contains.empty?
233
237
  log = "File #{file_path} contains the keyword '#{api_contains.keys}'.\n"
@@ -28,10 +28,20 @@ module Pod
28
28
  return false
29
29
  end
30
30
 
31
+ # 如果指定了--all 参数,那么忽略黑名单白名单,全部检索
32
+ return true if Pod::Config.instance.is_all
33
+
31
34
  # 判断域名白名单 和 黑名单,确保该组件是自己的组件,第三方sdk不做检索
32
35
  config = Privacy::Config.instance
33
- git_source_whitelisted = config.source_white_list.any? { |item| git_source.include?(item) }
36
+
37
+ ## 规则:
38
+ ## 1、白名单/黑名单是通过组件podspec 中 source 字段的值来匹配,包含关键词即为命中,所有可以是git关键的域名,也可以是完整的git链接
39
+ ## 2、白名单:当白名单为空数组时:默认为全部组件都为白名单!!!; 当白名单不为空时,仅检索白名单数组内的组件
40
+ git_source_whitelisted = config.source_white_list.empty? ? true : config.source_white_list.any? { |item| git_source.include?(item) }
41
+
42
+ ## 3、黑名单:在白名单基础上,需要排除的组件
34
43
  git_source_blacklisted = config.source_black_list.any? { |item| git_source.include?(item) }
44
+ ## 4、最终检索的范围:白名单 - 黑名单
35
45
  git_source_whitelisted && !git_source_blacklisted
36
46
  end
37
47
 
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.3.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - youhui
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-08 00:00:00.000000000 Z
11
+ date: 2024-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler