cocoapods-bb-PodAssistant 0.3.16.9 → 0.3.17.0
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/business/babybus_install_environment.rb +53 -28
- data/lib/cocoapods-bb-PodAssistant/babybus/installer/post_install_hooks.rb +18 -1
- data/lib/cocoapods-bb-PodAssistant/gem_version.rb +1 -1
- data/lib/cocoapods-bb-PodAssistant/security/omvll_config.rb +35 -0
- data/lib/cocoapods-bb-PodAssistant/security/omvll_environment.rb +104 -0
- data/lib/cocoapods-bb-PodAssistant/security/omvll_hardening.rb +30 -0
- data/lib/cocoapods-bb-PodAssistant/security/security_hardening.rb +127 -0
- data/lib/cocoapods_plugin.rb +5 -0
- metadata +5 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 15e433b2c397312291b454148d05e1d2117d5ae31097c527076545c5fd9debc1
|
|
4
|
+
data.tar.gz: 1d205ed8dab8a31aa48627543a0a15cfa5b2f3dd84965179f3c204d4539d1316
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4a84e7bddcc1ad0776fad2e18c6f39d37688958cefd571928e222e92af46d11f5506bc0125bc0820bc5df6c80d6318bcab58b5b9e09bacca4892da94cde6fd15
|
|
7
|
+
data.tar.gz: 18fc72226f51be2069409fb69db04a3ed33a495a2bb44879261003b94b4fcd4c09be082d9b22df53db590be8ce72a2a271d4169ef7c56cceceb988bc7d63e952
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# Author = Min Hu
|
|
3
3
|
|
|
4
4
|
require 'cocoapods-bb-PodAssistant/babybus/helpers/babybus_info_plist_helper'
|
|
5
|
+
require 'fileutils'
|
|
5
6
|
|
|
6
7
|
class BabybusInstallEnv
|
|
7
8
|
#https://v3.bbcloud.babybus.com/team/184/wiki/11667
|
|
@@ -54,40 +55,64 @@ class BabybusInstallEnv
|
|
|
54
55
|
puts "===拷贝3D产物文件操作===>".yellow
|
|
55
56
|
rootPath = getProjectRootPath
|
|
56
57
|
bundleIdentifier = getProjectBundleIdentifier
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
58
|
+
formats = %w[xcframework framework]
|
|
59
|
+
locations = [
|
|
60
|
+
[File.join(rootPath, 'Configs', bundleIdentifier), 'UnityFramework'],
|
|
61
|
+
[File.join(rootPath, 'Configs/UnityFramework', bundleIdentifier), 'UnityFramework'],
|
|
62
|
+
[File.join(rootPath, 'Configs/UnityFramework'), "#{bundleIdentifier}_UnityFramework"],
|
|
63
|
+
[File.join(rootPath, 'Configs/UnityFramework'), 'UnityFramework']
|
|
64
|
+
]
|
|
65
|
+
path = nil
|
|
66
|
+
locations.each do |directory, name|
|
|
67
|
+
formats.each do |format|
|
|
68
|
+
candidate = File.join(directory, "#{name}.#{format}")
|
|
69
|
+
puts "查找UnityFramework产物:#{candidate}"
|
|
70
|
+
if File.directory?(candidate)
|
|
71
|
+
path = candidate
|
|
72
|
+
break
|
|
68
73
|
end
|
|
69
74
|
end
|
|
75
|
+
break if path
|
|
70
76
|
end
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
unless path
|
|
78
|
+
puts "找不到UnityFramework产物文件,替换失败".red
|
|
79
|
+
return
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
format = File.extname(path)
|
|
83
|
+
podsPath = File.join("./", 'Pods/BBUnityFramework')
|
|
84
|
+
# podsPath = File.join(rootPath, 'Pods/BBUnityFramework')
|
|
85
|
+
replaceFilePath = File.join(podsPath, "UnityFramework#{format}")
|
|
86
|
+
unless File.directory?(replaceFilePath)
|
|
87
|
+
raise "UnityFramework产物格式与Pod依赖不匹配: #{path} -> #{replaceFilePath},请检查BBUnityFramework的vendored_frameworks配置"
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
require 'tmpdir'
|
|
91
|
+
Dir.mktmpdir('unity-replacement-', podsPath) do |tempPath|
|
|
92
|
+
stagedPath = File.join(tempPath, "UnityFramework#{format}")
|
|
93
|
+
FileUtils.cp_r(path, stagedPath, preserve: true)
|
|
94
|
+
if format == '.framework'
|
|
95
|
+
FileUtils.cp(File.join(replaceFilePath, 'Info.plist'), File.join(stagedPath, 'Info.plist'), preserve: true)
|
|
96
|
+
%w[Modules Headers].each do |name|
|
|
97
|
+
oldPath = File.join(replaceFilePath, name)
|
|
98
|
+
newPath = File.join(stagedPath, name)
|
|
99
|
+
FileUtils.cp_r(oldPath, newPath, preserve: true) if !File.exist?(newPath) && File.directory?(oldPath)
|
|
100
|
+
end
|
|
101
|
+
else
|
|
102
|
+
unless File.file?(File.join(stagedPath, 'Info.plist'))
|
|
103
|
+
raise "XCFramework缺少Info.plist: #{path}"
|
|
104
|
+
end
|
|
79
105
|
end
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
106
|
+
backupPath = File.join(tempPath, 'backup')
|
|
107
|
+
File.rename(replaceFilePath, backupPath)
|
|
108
|
+
begin
|
|
109
|
+
File.rename(stagedPath, replaceFilePath)
|
|
110
|
+
rescue StandardError
|
|
111
|
+
File.rename(backupPath, replaceFilePath)
|
|
112
|
+
raise
|
|
84
113
|
end
|
|
85
|
-
system "chmod 755 #{replaceFilePath}"
|
|
86
|
-
system "rm -rf #{replaceFilePath}; cp -af #{path} #{replaceFilePath}"
|
|
87
|
-
puts "替换UnityFramework文件成功".yellow
|
|
88
|
-
else
|
|
89
|
-
puts "找不到UnityFramework产物文件,替换失败".red
|
|
90
114
|
end
|
|
115
|
+
puts "替换UnityFramework文件成功:#{replaceFilePath}".yellow
|
|
91
116
|
end
|
|
92
117
|
# 2D母包替换
|
|
93
118
|
def copyCocosPackage
|
|
@@ -6,6 +6,7 @@ require 'cocoapods-bb-PodAssistant/babybus/helpers/babybus_info_plist_helper'
|
|
|
6
6
|
require 'cocoapods-bb-PodAssistant/babybus/business/babybus_install_environment'
|
|
7
7
|
require 'cocoapods-bb-PodAssistant/helpers/pod_utils'
|
|
8
8
|
require 'fileutils'
|
|
9
|
+
require 'cocoapods-bb-PodAssistant/security/security_hardening'
|
|
9
10
|
|
|
10
11
|
class PodPostInstaller
|
|
11
12
|
# 安装pod hook操作 进行环境修复,处理 Pods target
|
|
@@ -15,7 +16,8 @@ class PodPostInstaller
|
|
|
15
16
|
# filter_targets 过滤工程target,多个使用[]
|
|
16
17
|
# is_matrix 是否矩阵产品,默认true,debug场景会进行配置替换操作
|
|
17
18
|
# is_replaceMinVersionForMultiTarget 多target产品,是否需要替换最低版本支持,默认false
|
|
18
|
-
|
|
19
|
+
# omvll_whitelist 加固白名单,只有添加白名单组件才会进行加固
|
|
20
|
+
def initialize(lib, deployment_target=nil, filter_targets=["test"], is_matrix=true, is_replaceMinVersionForMultiTarget=false, omvll_whitelist=[])
|
|
19
21
|
@lib = lib
|
|
20
22
|
if deployment_target.nil?
|
|
21
23
|
is_xcode27 = BB::PodUtils.above_xcode_27_version
|
|
@@ -44,6 +46,19 @@ class PodPostInstaller
|
|
|
44
46
|
else
|
|
45
47
|
puts "当前Unity SDK 不支持 Simulator".yellow
|
|
46
48
|
end
|
|
49
|
+
# 是否开启加固,由业务方设置为1开启,默认关闭
|
|
50
|
+
@enable_omvll = ENV['ENABLE_OMVLL'] == '1'
|
|
51
|
+
if @enable_omvll
|
|
52
|
+
puts "当前工程开启Xcode编译加固功能".yellow
|
|
53
|
+
else
|
|
54
|
+
puts "当前工程没有开启Xcode编译加固功能".yellow
|
|
55
|
+
end
|
|
56
|
+
# 是否开启omvll加固
|
|
57
|
+
if omvll_whitelist.is_a? Array
|
|
58
|
+
@omvll_whitelist = omvll_whitelist # 过滤target
|
|
59
|
+
elsif omvll_whitelist.is_a? String
|
|
60
|
+
@omvll_whitelist = [omvll_whitelist] # 过滤target
|
|
61
|
+
end
|
|
47
62
|
end
|
|
48
63
|
private def filterTargetName(target_name)
|
|
49
64
|
for name in @filter_targets
|
|
@@ -379,5 +394,7 @@ install_framework()
|
|
|
379
394
|
project.save if should_save
|
|
380
395
|
# 修正Xcode16不能po问题
|
|
381
396
|
# fix_above_xcode16_no_po() # xcode27不需要
|
|
397
|
+
# Xcode 原生加固安全编译参数
|
|
398
|
+
apply_security_hardening(@lib, @enable_omvll, @omvll_whitelist)
|
|
382
399
|
end
|
|
383
400
|
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# 加固策略解析:仅解析并校验已有的 Python 策略文件,不执行策略。
|
|
2
|
+
require 'pathname'
|
|
3
|
+
|
|
4
|
+
module OMVLLConfig
|
|
5
|
+
module_function
|
|
6
|
+
|
|
7
|
+
def resolve_omvll_config(config_path: ENV['OMVLL_CONFIG_PATH'],
|
|
8
|
+
profile: ENV.fetch('OMVLL_PROFILE', 'default'),
|
|
9
|
+
config_dir: ENV.fetch('OMVLL_CONFIG_DIR', File.join(Dir.home, 'omvll', 'config')))
|
|
10
|
+
if config_path && !config_path.strip.empty?
|
|
11
|
+
path = normalize_path(config_path)
|
|
12
|
+
else
|
|
13
|
+
unless profile.is_a?(String) && profile.match?(/\A[a-zA-Z0-9][a-zA-Z0-9_-]*\z/)
|
|
14
|
+
raise ArgumentError, "Invalid O-MVLL profile: #{profile.inspect}"
|
|
15
|
+
end
|
|
16
|
+
path = File.join(normalize_path(config_dir), "#{profile}.py")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
unless File.extname(path) == '.py' && File.file?(path) && File.readable?(path)
|
|
20
|
+
raise ArgumentError, "O-MVLL configuration must be a readable Python file: #{path}"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
File.realpath(path)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def normalize_path(path)
|
|
27
|
+
unless path.is_a?(String) && !path.strip.empty?
|
|
28
|
+
raise ArgumentError, 'O-MVLL path must not be empty'
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
expanded = path.sub(/\A(?:\$HOME|\$\{HOME\})(?=\/|\z)/) { Dir.home }
|
|
32
|
+
File.expand_path(expanded)
|
|
33
|
+
end
|
|
34
|
+
private_class_method :normalize_path
|
|
35
|
+
end
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# 读取、校验 Shell 提供的环境信息,不负责安装或切换工具链。
|
|
2
|
+
require 'json'
|
|
3
|
+
require 'open3'
|
|
4
|
+
|
|
5
|
+
module OMVLLEnvironment
|
|
6
|
+
class Error < StandardError; end
|
|
7
|
+
|
|
8
|
+
SCHEMA_VERSION = 1
|
|
9
|
+
REQUIRED_FIELDS = %w[toolchain_version xcode_version xcode_build_version developer_dir clang_version host_arch plugin_path].freeze
|
|
10
|
+
|
|
11
|
+
module_function
|
|
12
|
+
|
|
13
|
+
def load_omvll_environment(env_file: ENV['OMVLL_ENV_FILE'])
|
|
14
|
+
if env_file.nil? || env_file.strip.empty?
|
|
15
|
+
root = ENV['WORKSPACE'] || Dir.pwd
|
|
16
|
+
env_file = File.join(root, '.build', 'security', 'omvll_environment.json')
|
|
17
|
+
end
|
|
18
|
+
path = normalize_path(env_file)
|
|
19
|
+
unless File.file?(path) && File.readable?(path)
|
|
20
|
+
raise Error, "O-MVLL environment file not found or unreadable: #{path}. Run omvllctl prepare first."
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
data = JSON.parse(File.read(path))
|
|
24
|
+
validate_omvll_environment(data)
|
|
25
|
+
rescue JSON::ParserError, SystemCallError => e
|
|
26
|
+
raise Error, "Unable to load O-MVLL environment: #{e.message}"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def validate_omvll_environment(data)
|
|
30
|
+
unless data.is_a?(Hash) && data['schema_version'] == SCHEMA_VERSION
|
|
31
|
+
raise Error, 'Unsupported O-MVLL environment schema'
|
|
32
|
+
end
|
|
33
|
+
REQUIRED_FIELDS.each do |key|
|
|
34
|
+
value = data[key]
|
|
35
|
+
unless value.is_a?(String) && !value.strip.empty?
|
|
36
|
+
raise Error, "Missing or invalid O-MVLL environment field: #{key}"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
unless data['environment_verified'] == true
|
|
40
|
+
raise Error, 'O-MVLL environment has not been verified. Run omvllctl prepare first.'
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
result = data.dup
|
|
44
|
+
result['plugin_path'] = checked_path(data['plugin_path'], :file)
|
|
45
|
+
result['developer_dir'] = checked_path(data['developer_dir'], :directory)
|
|
46
|
+
if data.key?('runtime_path') && !data['runtime_path'].nil?
|
|
47
|
+
result['runtime_path'] = checked_path(data['runtime_path'], :either)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
active_dir = ENV['DEVELOPER_DIR']
|
|
51
|
+
active_dir = run_command('/usr/bin/xcode-select', '-p') if active_dir.nil? || active_dir.strip.empty?
|
|
52
|
+
active_dir = normalize_path(active_dir)
|
|
53
|
+
active_dir = File.join(active_dir, 'Contents', 'Developer') if active_dir.end_with?('.app')
|
|
54
|
+
unless checked_path(active_dir, :directory) == result['developer_dir']
|
|
55
|
+
raise Error, 'O-MVLL developer_dir does not match the active Xcode'
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
xcode_info = run_command('/usr/bin/xcodebuild', '-version')
|
|
59
|
+
xcode_version = xcode_info[/^Xcode\s+(.+)$/, 1]&.strip
|
|
60
|
+
build_version = xcode_info[/^Build version\s+(.+)$/, 1]&.strip
|
|
61
|
+
unless xcode_version == data['xcode_version'] && build_version == data['xcode_build_version']
|
|
62
|
+
raise Error, "O-MVLL Xcode mismatch: expected #{data['xcode_version']} (#{data['xcode_build_version']}), got #{xcode_version} (#{build_version})"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
host_arch = run_command('/usr/bin/uname', '-m')
|
|
66
|
+
unless host_arch == data['host_arch']
|
|
67
|
+
raise Error, "O-MVLL host architecture mismatch: expected #{data['host_arch']}, got #{host_arch}"
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
result.freeze
|
|
71
|
+
rescue SystemCallError => e
|
|
72
|
+
raise Error, "O-MVLL environment validation failed: #{e.message}"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def normalize_path(path)
|
|
76
|
+
unless path.is_a?(String) && !path.strip.empty?
|
|
77
|
+
raise Error, 'Invalid O-MVLL path'
|
|
78
|
+
end
|
|
79
|
+
File.expand_path(path.sub(/\A(?:\$HOME|\$\{HOME\})(?=\/|\z)/) { Dir.home })
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def checked_path(path, kind)
|
|
83
|
+
expanded = normalize_path(path)
|
|
84
|
+
valid = case kind
|
|
85
|
+
when :file then File.file?(expanded)
|
|
86
|
+
when :directory then File.directory?(expanded)
|
|
87
|
+
else File.file?(expanded) || File.directory?(expanded)
|
|
88
|
+
end
|
|
89
|
+
unless valid && File.readable?(expanded)
|
|
90
|
+
raise Error, "Invalid or unreadable O-MVLL #{kind} path: #{expanded}"
|
|
91
|
+
end
|
|
92
|
+
File.realpath(expanded)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def run_command(*args)
|
|
96
|
+
stdout, stderr, status = Open3.capture3(*args)
|
|
97
|
+
unless status.success?
|
|
98
|
+
raise Error, "Command failed (#{args.join(' ')}): #{stderr.strip}"
|
|
99
|
+
end
|
|
100
|
+
stdout.strip
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
private_class_method :normalize_path, :checked_path, :run_command
|
|
104
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# O-MVLL 工程配置
|
|
2
|
+
require_relative 'omvll_environment'
|
|
3
|
+
require_relative 'omvll_config'
|
|
4
|
+
|
|
5
|
+
module OMVLLHardening
|
|
6
|
+
module_function
|
|
7
|
+
|
|
8
|
+
def omvll_enabled?
|
|
9
|
+
ENV.fetch('OMVLL_ENABLED', 'false').strip.downcase == 'true'
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def resolve_context
|
|
13
|
+
return nil unless omvll_enabled?
|
|
14
|
+
|
|
15
|
+
environment = OMVLLEnvironment.load_omvll_environment
|
|
16
|
+
config_path = OMVLLConfig.resolve_omvll_config
|
|
17
|
+
|
|
18
|
+
{
|
|
19
|
+
environment: environment,
|
|
20
|
+
plugin_path: environment.fetch('plugin_path'),
|
|
21
|
+
config_path: config_path
|
|
22
|
+
}.freeze
|
|
23
|
+
rescue OMVLLEnvironment::Error, ArgumentError => e
|
|
24
|
+
raise Pod::Informative, "[O-MVLL] #{e.message}"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def eligible_configuration?(configuration)
|
|
28
|
+
!configuration.name.match?(/debug/i)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Xcode 原生加固安全编译参数
|
|
2
|
+
require 'cocoapods-bb-PodAssistant/helpers/pod_utils'
|
|
3
|
+
|
|
4
|
+
# Set OMVLL_SCRIPT_DIR to the directory containing the management scripts.
|
|
5
|
+
module SecurityHardening
|
|
6
|
+
# 经过安全评估和兼容性验证的自研组件名称
|
|
7
|
+
DEFAULT_OMVLL_WHITELIST = [
|
|
8
|
+
'Masonry',
|
|
9
|
+
'BBGameModule',
|
|
10
|
+
'BBAppGlobalComponent',
|
|
11
|
+
'BBSVideoPlayer',
|
|
12
|
+
'BBLogKit',
|
|
13
|
+
'Aiolos',
|
|
14
|
+
'YYCategories',
|
|
15
|
+
'BBGameInterface',
|
|
16
|
+
'CocoaLumberjack',
|
|
17
|
+
'BBFoundation',
|
|
18
|
+
'BBPay_Capability',
|
|
19
|
+
'BBDownloader',
|
|
20
|
+
'AliyunOSSiOS',
|
|
21
|
+
'BBLogKit',
|
|
22
|
+
'BBRouteManagerBusiness',
|
|
23
|
+
'BBGameInterface',
|
|
24
|
+
'BBUIComponents',
|
|
25
|
+
'Protobuf',
|
|
26
|
+
'BBPlayerSetting',
|
|
27
|
+
'BBBaseSDK',
|
|
28
|
+
'RxCocoa',
|
|
29
|
+
'FMDB',
|
|
30
|
+
'BBWebView_Capability',
|
|
31
|
+
'ReactiveObjC',
|
|
32
|
+
'YYCache',
|
|
33
|
+
'BBUIKit',
|
|
34
|
+
'BBWeb',
|
|
35
|
+
'BBAnimationPlayer',
|
|
36
|
+
'GYDataCenter',
|
|
37
|
+
'SDWebImageSVGAPlugin',
|
|
38
|
+
'SVGAPlayer',
|
|
39
|
+
].freeze
|
|
40
|
+
|
|
41
|
+
module_function
|
|
42
|
+
|
|
43
|
+
def apply_security_hardening(installer, enable_omvll=false, omvll_whitelist=[])
|
|
44
|
+
omvll_whitelist = (
|
|
45
|
+
DEFAULT_OMVLL_WHITELIST + Array(omvll_whitelist)
|
|
46
|
+
).uniq
|
|
47
|
+
puts "omvll加固白名单 #{omvll_whitelist}"
|
|
48
|
+
app_apply_security_hardening(installer, enable_omvll)
|
|
49
|
+
pod_apply_security_hardening(installer, enable_omvll, omvll_whitelist)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
private def resolve_omvll_plugin_flag
|
|
53
|
+
omvll_plugin = ENV.fetch('OMVLL_SCRIPT_DIR', File.join(Dir.home, 'omvll', 'current', 'omvll-xcode.dylib'))
|
|
54
|
+
raise "[O-MVLL] 插件不存在: #{omvll_plugin}(先运行:% omvllctl install)" unless File.exist?(omvll_plugin)
|
|
55
|
+
"-fpass-plugin=#{omvll_plugin}"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# omvll混淆、xcode自带混淆
|
|
59
|
+
private def update_setting(config, omvll_flag, enable_omvll=false)
|
|
60
|
+
settings = config.build_settings
|
|
61
|
+
settings['ENABLE_STACK_PROTECTOR'] = 'YES'
|
|
62
|
+
settings['GCC_SYMBOLS_PRIVATE_EXTERN'] = 'YES' unless settings.key?('GCC_SYMBOLS_PRIVATE_EXTERN')
|
|
63
|
+
# 删除无用代码
|
|
64
|
+
settings['DEAD_CODE_STRIPPING'] = 'YES'
|
|
65
|
+
# 禁止测试能力
|
|
66
|
+
settings['ENABLE_TESTABILITY'] = 'NO'
|
|
67
|
+
# 禁止生产环境断言
|
|
68
|
+
settings['ENABLE_NS_ASSERTIONS'] = 'NO'
|
|
69
|
+
# 保留崩溃分析能力
|
|
70
|
+
settings['DEBUG_INFORMATION_FORMAT'] = 'dwarf-with-dsym'
|
|
71
|
+
# 栈溢出保护
|
|
72
|
+
flags = Array(settings['OTHER_CFLAGS'] || '$(inherited)')
|
|
73
|
+
unless flags.include?('-fstack-protector-strong')
|
|
74
|
+
flags << '-fstack-protector-strong'
|
|
75
|
+
end
|
|
76
|
+
# O-MVLL 加固配置
|
|
77
|
+
if enable_omvll == true
|
|
78
|
+
flags << omvll_flag unless flags.include?(omvll_flag)
|
|
79
|
+
else
|
|
80
|
+
flags.delete(omvll_flag)
|
|
81
|
+
end
|
|
82
|
+
settings['OTHER_CFLAGS'] = flags
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# 工程配置
|
|
86
|
+
private def app_apply_security_hardening(installer, enable_omvll)
|
|
87
|
+
project = Xcodeproj::Project.open(BB::PodUtils.getXcodeprojPath)
|
|
88
|
+
omvll_flag=resolve_omvll_plugin_flag
|
|
89
|
+
project.targets.each do |target|
|
|
90
|
+
target.build_configurations.each do |config|
|
|
91
|
+
next if config.name.match?(/debug/i)
|
|
92
|
+
update_setting(config, omvll_flag, enable_omvll)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# pods配置原生加固
|
|
98
|
+
private def pod_apply_security_hardening(installer, enable_omvll, omvll_whitelist)
|
|
99
|
+
# projects = if installer.respond_to?(:generated_projects)
|
|
100
|
+
# Array(installer.generated_projects)
|
|
101
|
+
# else
|
|
102
|
+
# []
|
|
103
|
+
# end
|
|
104
|
+
# projects << installer.pods_project if installer.respond_to?(:pods_project)
|
|
105
|
+
# projects = projects.compact.uniq
|
|
106
|
+
projects = ([installer.pods_project] + installer.pod_target_subprojects + installer.aggregate_targets.map(&:user_project)).compact.uniq
|
|
107
|
+
count = 0
|
|
108
|
+
omvll_flag=resolve_omvll_plugin_flag
|
|
109
|
+
projects.flat_map(&:targets).uniq.each do |target|
|
|
110
|
+
pod_enable_omvll = (enable_omvll == true) && omvll_whitelist.include?(target.name)
|
|
111
|
+
target.build_configurations.each do |config|
|
|
112
|
+
# 仅跳过 Debug 类构建配置,其余配置统一执行安全加固
|
|
113
|
+
next if config.name.match?(/debug/i)
|
|
114
|
+
update_setting(config, omvll_flag, pod_enable_omvll)
|
|
115
|
+
count += 1
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
Pod::UI.puts "[SecurityHardening] Configured #{count} non-Debug target configurations".yellow if defined?(Pod::UI)
|
|
119
|
+
count
|
|
120
|
+
installer.aggregate_targets.map(&:user_project).compact.uniq.each(&:save)
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# 保留 Podfile post_install 中直接调用的入口
|
|
125
|
+
def apply_security_hardening(installer, enable_omvll=false, omvll_whitelist=[])
|
|
126
|
+
SecurityHardening.apply_security_hardening(installer, enable_omvll, omvll_whitelist)
|
|
127
|
+
end
|
data/lib/cocoapods_plugin.rb
CHANGED
|
@@ -8,3 +8,8 @@ require 'cocoapods-bb-PodAssistant/babybus/installer/post_install_hooks'
|
|
|
8
8
|
require 'cocoapods-bb-PodAssistant/babybus/installer/post_integrate_hooks'
|
|
9
9
|
|
|
10
10
|
require 'cocoapods-bb-PodAssistant/command'
|
|
11
|
+
|
|
12
|
+
require 'cocoapods-bb-PodAssistant/security/omvll_config'
|
|
13
|
+
require 'cocoapods-bb-PodAssistant/security/omvll_environment'
|
|
14
|
+
require 'cocoapods-bb-PodAssistant/security/omvll_hardening'
|
|
15
|
+
require 'cocoapods-bb-PodAssistant/security/security_hardening'
|
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.
|
|
4
|
+
version: 0.3.17.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- humin
|
|
@@ -186,6 +186,10 @@ files:
|
|
|
186
186
|
- lib/cocoapods-bb-PodAssistant/helpers/yaml_files_helper.rb
|
|
187
187
|
- lib/cocoapods-bb-PodAssistant/native/installer.rb
|
|
188
188
|
- lib/cocoapods-bb-PodAssistant/podfile.rb
|
|
189
|
+
- lib/cocoapods-bb-PodAssistant/security/omvll_config.rb
|
|
190
|
+
- lib/cocoapods-bb-PodAssistant/security/omvll_environment.rb
|
|
191
|
+
- lib/cocoapods-bb-PodAssistant/security/omvll_hardening.rb
|
|
192
|
+
- lib/cocoapods-bb-PodAssistant/security/security_hardening.rb
|
|
189
193
|
- lib/cocoapods-bb-PodAssistant/source_provider_hook.rb
|
|
190
194
|
- lib/cocoapods-bb-PodAssistant/tools.rb
|
|
191
195
|
- lib/cocoapods-bb-PodAssistant/tools/class_unuse_finder.rb
|