cocoapods-bb-PodAssistant 0.3.17.8 → 0.3.18.1

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.
@@ -5,50 +5,16 @@ require 'cocoapods-bb-PodAssistant/helpers/pod_utils'
5
5
  module SecurityHardening
6
6
  # 经过安全评估和兼容性验证的自研组件名称
7
7
  DEFAULT_OMVLL_WHITELIST = [
8
- # 'BBGameModule',
9
- # 'BBAppGlobalComponent',
10
- # 'BBSVideoPlayer',
11
- # 'BBLogKit',
12
- # 'Aiolos',
13
- # 'YYCategories',
14
- # 'BBGameInterface',
15
- # 'CocoaLumberjack',
16
- # 'BBFoundation',
17
- # 'BBPay_Capability',
18
- # 'BBDownloader',
19
- # 'AliyunOSSiOS',
20
- # 'BBLogKit',
21
- # 'BBRouteManagerBusiness',
22
- # 'BBGameInterface',
23
- # 'BBUIComponents',
24
- # 'Protobuf',
25
- # 'BBPlayerSetting',
26
- # 'BBBaseSDK',
27
- # 'RxCocoa',
28
- # 'FMDB',
29
- # 'BBWebView_Capability',
30
- # 'YYCache',
31
- # 'BBUIKit',
32
- # 'BBWeb',
33
- # 'BBAnimationPlayer',
34
- # 'GYDataCenter',
35
- # 'SDWebImageSVGAPlugin',
36
- # 'SVGAPlayer',
37
- # 'Masonry',
38
- # 'BBDLNAKit',
39
- # 'BBAudioRecorder',
40
- # 'BBAccountModule',
41
8
  ].freeze
42
9
 
43
10
  module_function
44
11
 
45
- def apply_security_hardening(installer, enable_omvll=false, omvll_whitelist=[])
12
+ def apply_security_hardening(installer, enable_omvll=false, omvll_whitelist=[], enable_security_hardening=true, save_projects: true)
46
13
  omvll_whitelist = (
47
14
  DEFAULT_OMVLL_WHITELIST + Array(omvll_whitelist)
48
15
  ).uniq
49
- puts "omvll加固白名单 #{omvll_whitelist}"
50
- pod_apply_security_hardening(installer, enable_omvll, omvll_whitelist)
51
- app_apply_security_hardening(installer, enable_omvll)
16
+ puts "omvll加固白名单 #{omvll_whitelist}" if enable_omvll
17
+ app_apply_security_hardening(installer, enable_omvll, omvll_whitelist, enable_security_hardening, save_projects: save_projects)
52
18
  end
53
19
 
54
20
  private def resolve_omvll_plugin_oc_flag
@@ -77,17 +43,19 @@ module SecurityHardening
77
43
  end
78
44
 
79
45
  # omvll混淆、xcode自带混淆
80
- private def update_setting(config, omvll_oc_flag, omvll_swift_flag, enable_omvll=false)
46
+ private def update_setting(config, omvll_oc_flag, omvll_swift_flag, enable_omvll=false, enable_security_hardening=true, configure_symbol_visibility: false)
81
47
  settings = config.build_settings
82
- settings['ENABLE_STACK_PROTECTOR'] = 'YES'
83
- # 删除无用代码
84
- settings['DEAD_CODE_STRIPPING'] = 'YES'
85
- # 禁止测试能力
86
- settings['ENABLE_TESTABILITY'] = 'NO'
87
- # 禁止生产环境断言
88
- settings['ENABLE_NS_ASSERTIONS'] = 'NO'
89
- # 保留崩溃分析能力
90
- settings['DEBUG_INFORMATION_FORMAT'] = 'dwarf-with-dsym'
48
+ if enable_security_hardening
49
+ settings['ENABLE_STACK_PROTECTOR'] = 'YES'
50
+ # 删除无用代码
51
+ settings['DEAD_CODE_STRIPPING'] = 'YES'
52
+ # 禁止测试能力
53
+ settings['ENABLE_TESTABILITY'] = 'NO'
54
+ # 禁止生产环境断言
55
+ settings['ENABLE_NS_ASSERTIONS'] = 'NO'
56
+ # 保留崩溃分析能力
57
+ settings['DEBUG_INFORMATION_FORMAT'] = 'dwarf-with-dsym'
58
+ end
91
59
  # oc加固标记
92
60
  flags = Array(settings['OTHER_CFLAGS'] || '$(inherited)')
93
61
  # 栈溢出保护
@@ -96,44 +64,36 @@ module SecurityHardening
96
64
  end
97
65
  # O-MVLL 加固配置oc
98
66
  if enable_omvll == true
99
- settings['GCC_SYMBOLS_PRIVATE_EXTERN'] = 'YES' unless settings.key?('GCC_SYMBOLS_PRIVATE_EXTERN')
67
+ settings['GCC_SYMBOLS_PRIVATE_EXTERN'] = 'YES' if configure_symbol_visibility && !settings.key?('GCC_SYMBOLS_PRIVATE_EXTERN')
100
68
  flags << omvll_oc_flag unless flags.include?(omvll_oc_flag)
101
69
  else
102
- settings['GCC_SYMBOLS_PRIVATE_EXTERN'] = 'NO' unless settings.key?('GCC_SYMBOLS_PRIVATE_EXTERN')
70
+ settings['GCC_SYMBOLS_PRIVATE_EXTERN'] = 'NO' if configure_symbol_visibility && !settings.key?('GCC_SYMBOLS_PRIVATE_EXTERN')
103
71
  flags.delete(omvll_oc_flag)
104
72
  end
105
73
  settings['OTHER_CFLAGS'] = flags
106
74
 
107
75
  # swift加固标记
108
76
  swift_flags = Array(settings['OTHER_SWIFT_FLAGS'] || '$(inherited)')
109
- # O-MVLL 加固配置swift
77
+ .flat_map { |flag| flag.split(/\s+/) }
78
+ .reject(&:empty?)
79
+ # 清理历史重复的 O-MVLL 参数
80
+ swift_flags.delete(omvll_swift_flag)
81
+ # 根据开关重新添加
110
82
  if enable_omvll == true
111
- swift_flags << omvll_swift_flag unless swift_flags.include?(omvll_swift_flag)
112
- else
113
- swift_flags.delete(omvll_swift_flag)
83
+ swift_flags << omvll_swift_flag
84
+ # workaround = [
85
+ # '-Xfrontend',
86
+ # '-disable-round-trip-debug-types'
87
+ # ]
88
+ # unless swift_flags.each_cons(2).any? { |pair| pair == workaround }
89
+ # swift_flags.concat(workaround)
90
+ # end
114
91
  end
115
92
  settings['OTHER_SWIFT_FLAGS'] = swift_flags
116
93
  end
117
94
 
118
- # 工程配置
119
- private def app_apply_security_hardening(installer, enable_omvll)
120
- project = Xcodeproj::Project.open(BB::PodUtils.getXcodeprojPath)
121
- omvll_oc_flag=resolve_omvll_plugin_oc_flag
122
- omvll_swift_flag=resolve_omvll_plugin_swift_flag
123
- project.targets.each do |target|
124
- target.build_configurations.each do |config|
125
- next if config.name.match?(/debug/i)
126
- update_setting(config, omvll_oc_flag, omvll_swift_flag, enable_omvll)
127
- end
128
- end
129
- if enable_omvll == true
130
- project.save
131
- puts "[O-MVLL][App] 工程保存成功: #{project.path}"
132
- end
133
- end
134
-
135
- # pods配置原生加固
136
- private def pod_apply_security_hardening(installer, enable_omvll, omvll_whitelist)
95
+ # 工程配置(主app+pods)
96
+ private def app_apply_security_hardening(installer, enable_omvll, omvll_whitelist, enable_security_hardening, save_projects: true)
137
97
  # projects = if installer.respond_to?(:generated_projects)
138
98
  # Array(installer.generated_projects)
139
99
  # else
@@ -142,25 +102,28 @@ module SecurityHardening
142
102
  # projects << installer.pods_project if installer.respond_to?(:pods_project)
143
103
  # projects = projects.compact.uniq
144
104
  projects = ([installer.pods_project] + installer.pod_target_subprojects + installer.aggregate_targets.map(&:user_project)).compact.uniq
145
- count = 0
146
105
  omvll_oc_flag=resolve_omvll_plugin_oc_flag
147
106
  omvll_swift_flag=resolve_omvll_plugin_swift_flag
148
107
  projects.flat_map(&:targets).uniq.each do |target|
149
- pod_enable_omvll = (enable_omvll == true) && omvll_whitelist.include?(target.name)
108
+ # 加固总开关
109
+ effective_enable_omvll = enable_security_hardening && enable_omvll
110
+ # 主工程不去判断白名单
111
+ if target.respond_to?(:product_type) && target.product_type == 'com.apple.product-type.application'
112
+ pod_enable_omvll = effective_enable_omvll
113
+ else
114
+ pod_enable_omvll = effective_enable_omvll && omvll_whitelist.include?(target.name)
115
+ end
150
116
  target.build_configurations.each do |config|
151
117
  # 仅跳过 Debug 类构建配置,其余配置统一执行安全加固
152
118
  next if config.name.match?(/debug/i)
153
- update_setting(config, omvll_oc_flag, omvll_swift_flag, pod_enable_omvll)
154
- count += 1
119
+ update_setting(config, omvll_oc_flag, omvll_swift_flag, pod_enable_omvll, enable_security_hardening, configure_symbol_visibility: %w[cocos2dx UnityFramework].include?(target.name))
155
120
  end
156
121
  end
157
- Pod::UI.puts "[SecurityHardening] Configured #{count} non-Debug target configurations".yellow if defined?(Pod::UI)
158
- count
159
- installer.aggregate_targets.map(&:user_project).compact.uniq.each(&:save)
122
+ installer.aggregate_targets.map(&:user_project).compact.uniq.each(&:save) if save_projects
160
123
  end
161
124
  end
162
125
 
163
126
  # 保留 Podfile post_install 中直接调用的入口
164
- def apply_security_hardening(installer, enable_omvll=false, omvll_whitelist=[])
165
- SecurityHardening.apply_security_hardening(installer, enable_omvll, omvll_whitelist)
127
+ def apply_security_hardening(installer, enable_omvll=false, omvll_whitelist=[], enable_security_hardening=true, save_projects: true)
128
+ SecurityHardening.apply_security_hardening(installer, enable_omvll, omvll_whitelist, enable_security_hardening, save_projects: save_projects)
166
129
  end
@@ -13,3 +13,13 @@ require 'cocoapods-bb-PodAssistant/security/omvll_config'
13
13
  require 'cocoapods-bb-PodAssistant/security/omvll_environment'
14
14
  require 'cocoapods-bb-PodAssistant/security/omvll_hardening'
15
15
  require 'cocoapods-bb-PodAssistant/security/security_hardening'
16
+
17
+ # Molinillo 依赖解析性能优化
18
+ # BB_MOLINILLO_OPTIMIZATION=1 podin
19
+ require 'cocoapods-bb-PodAssistant/helpers/molinillo_performance_patch'
20
+
21
+ # CocoaPods 性能诊断
22
+ # BB_POD_PROFILE=1 podin
23
+ if ENV['BB_POD_PROFILE'] == '1'
24
+ require 'cocoapods-bb-PodAssistant/helpers/pod_performance_profiler'
25
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-bb-PodAssistant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.17.8
4
+ version: 0.3.18.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - humin
@@ -178,8 +178,11 @@ files:
178
178
  - lib/cocoapods-bb-PodAssistant/config/stable_specs.rb
179
179
  - lib/cocoapods-bb-PodAssistant/gem_version.rb
180
180
  - lib/cocoapods-bb-PodAssistant/helpers.rb
181
+ - lib/cocoapods-bb-PodAssistant/helpers/build_environment.rb
181
182
  - lib/cocoapods-bb-PodAssistant/helpers/git_cmd_helper.rb
183
+ - lib/cocoapods-bb-PodAssistant/helpers/molinillo_performance_patch.rb
182
184
  - lib/cocoapods-bb-PodAssistant/helpers/pod_module_helper.rb
185
+ - lib/cocoapods-bb-PodAssistant/helpers/pod_performance_profiler.rb
183
186
  - lib/cocoapods-bb-PodAssistant/helpers/pod_utils.rb
184
187
  - lib/cocoapods-bb-PodAssistant/helpers/stable_env_helper.rb
185
188
  - lib/cocoapods-bb-PodAssistant/helpers/stable_manager_helper.rb