cocoapods-bb-PodAssistant 0.3.18.0 → 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.
- checksums.yaml +4 -4
- data/lib/cocoapods-bb-PodAssistant/babybus/installer/post_install_hooks.rb +419 -185
- data/lib/cocoapods-bb-PodAssistant/babybus/installer/post_integrate_hooks.rb +9 -0
- data/lib/cocoapods-bb-PodAssistant/gem_version.rb +1 -1
- data/lib/cocoapods-bb-PodAssistant/helpers/build_environment.rb +69 -0
- data/lib/cocoapods-bb-PodAssistant/helpers/molinillo_performance_patch.rb +89 -0
- data/lib/cocoapods-bb-PodAssistant/helpers/pod_performance_profiler.rb +372 -0
- data/lib/cocoapods-bb-PodAssistant/security/security_hardening.rb +31 -77
- data/lib/cocoapods_plugin.rb +10 -0
- metadata +4 -1
|
@@ -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
|
-
|
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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,10 +64,10 @@ module SecurityHardening
|
|
|
96
64
|
end
|
|
97
65
|
# O-MVLL 加固配置oc
|
|
98
66
|
if enable_omvll == true
|
|
99
|
-
settings['GCC_SYMBOLS_PRIVATE_EXTERN'] = 'YES'
|
|
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'
|
|
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
|
|
@@ -124,25 +92,8 @@ module SecurityHardening
|
|
|
124
92
|
settings['OTHER_SWIFT_FLAGS'] = swift_flags
|
|
125
93
|
end
|
|
126
94
|
|
|
127
|
-
#
|
|
128
|
-
private def app_apply_security_hardening(installer, enable_omvll)
|
|
129
|
-
project = Xcodeproj::Project.open(BB::PodUtils.getXcodeprojPath)
|
|
130
|
-
omvll_oc_flag=resolve_omvll_plugin_oc_flag
|
|
131
|
-
omvll_swift_flag=resolve_omvll_plugin_swift_flag
|
|
132
|
-
project.targets.each do |target|
|
|
133
|
-
target.build_configurations.each do |config|
|
|
134
|
-
next if config.name.match?(/debug/i)
|
|
135
|
-
update_setting(config, omvll_oc_flag, omvll_swift_flag, enable_omvll)
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
if enable_omvll == true
|
|
139
|
-
project.save
|
|
140
|
-
puts "[O-MVLL][App] 工程保存成功: #{project.path}"
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
# pods配置原生加固
|
|
145
|
-
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)
|
|
146
97
|
# projects = if installer.respond_to?(:generated_projects)
|
|
147
98
|
# Array(installer.generated_projects)
|
|
148
99
|
# else
|
|
@@ -151,25 +102,28 @@ module SecurityHardening
|
|
|
151
102
|
# projects << installer.pods_project if installer.respond_to?(:pods_project)
|
|
152
103
|
# projects = projects.compact.uniq
|
|
153
104
|
projects = ([installer.pods_project] + installer.pod_target_subprojects + installer.aggregate_targets.map(&:user_project)).compact.uniq
|
|
154
|
-
count = 0
|
|
155
105
|
omvll_oc_flag=resolve_omvll_plugin_oc_flag
|
|
156
106
|
omvll_swift_flag=resolve_omvll_plugin_swift_flag
|
|
157
107
|
projects.flat_map(&:targets).uniq.each do |target|
|
|
158
|
-
|
|
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
|
|
159
116
|
target.build_configurations.each do |config|
|
|
160
117
|
# 仅跳过 Debug 类构建配置,其余配置统一执行安全加固
|
|
161
118
|
next if config.name.match?(/debug/i)
|
|
162
|
-
update_setting(config, omvll_oc_flag, omvll_swift_flag, pod_enable_omvll)
|
|
163
|
-
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))
|
|
164
120
|
end
|
|
165
121
|
end
|
|
166
|
-
|
|
167
|
-
count
|
|
168
|
-
installer.aggregate_targets.map(&:user_project).compact.uniq.each(&:save)
|
|
122
|
+
installer.aggregate_targets.map(&:user_project).compact.uniq.each(&:save) if save_projects
|
|
169
123
|
end
|
|
170
124
|
end
|
|
171
125
|
|
|
172
126
|
# 保留 Podfile post_install 中直接调用的入口
|
|
173
|
-
def apply_security_hardening(installer, enable_omvll=false, omvll_whitelist=[])
|
|
174
|
-
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)
|
|
175
129
|
end
|
data/lib/cocoapods_plugin.rb
CHANGED
|
@@ -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.18.
|
|
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
|