1:添加cos的混淆规则

This commit is contained in:
2025-12-18 10:28:46 +08:00
parent df499aaa6c
commit 952621baaa
2 changed files with 143 additions and 12 deletions

View File

@@ -105,7 +105,7 @@ android {
}
buildTypes {
release {
minifyEnabled false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
@@ -129,7 +129,7 @@ android {
debug {
debuggable true
minifyEnabled false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug

151
app/proguard-rules.pro vendored
View File

@@ -921,19 +921,23 @@ public static java.lang.String TABLENAME;
-keepclassmembers class com.xscm.moduleutil.event.MqttBean** {
*;
}
-keep class com.xscm.moduleutil.bean.GiftBean** {*;}
-keepclassmembers class com.xscm.moduleutil.bean.GiftBean** {
*;
}
-keep class com.xscm.moduleutil.bean.XLHBean** {*;}
-keepclassmembers class com.xscm.moduleutil.bean.XLHBean** {
*;
}
-keep class com.xscm.moduleutil.bean.RedBean** {*;}
-keepclassmembers class com.xscm.moduleutil.bean.RedBean** {
-keep class com.xscm.moduleutil.event.RedBean** {*;}
-keepclassmembers class com.xscm.moduleutil.event.RedBean** {
*;
}
-keep class com.xscm.moduleutil.bean.HourlyBean** {*;}
-keepclassmembers class com.xscm.moduleutil.bean.HourlyBean** {
-keep class com.xscm.moduleutil.event.HourlyBean** {*;}
-keepclassmembers class com.xscm.moduleutil.event.HourlyBean** {
*;
}
@@ -945,9 +949,136 @@ public static java.lang.String TABLENAME;
-keep class **.R$string { *; }
-keep class com.qcloud.cos.** { *; }
-dontwarn com.qcloud.cos.**
-keep class com.qcloud.cos.model.** { *; }
-keep class * implements com.qcloud.cos.** { *; }
-keepattributes Signature, *Annotation*
-keep class com.qcloud.cos.**$* { *; }
# ========== 腾讯云COS SDK 混淆规则 ==========
# COS SDK混淆规则
-dontwarn com.tencent.cos.**
-keep class com.tencent.cos.xml.**{*;}
-keep class com.tencent.qcloud.cos.**{*;}
# 相关依赖库保留
-keep class com.tencent**qimei.** { *;}
-keep class com.tencent.qmsp.oaid2.** {*;}
-keep class com.tencent.beacon.** { *;}
-keep class com.xscm.moduleutil.utils.cos.** {
*;
}
-keep class com.xscm.moduleutil.utils.cos.TempKeyBean {
*;
}
-keep class com.xscm.moduleutil.utils.cos.Credentials {
*;
}
# ========== 针对临时密钥 (SessionQCloudCredentials) 的增强规则 ==========
# 1. 精确保护引发错误的类及其所有成员(字段、方法)
#-keep class com.tencent.qcloud.core.auth.SessionQCloudCredentials {
# *;
#}
## 额外保护其所有内部类(如果有)
#-keep class com.tencent.qcloud.core.auth.SessionQCloudCredentials$* {
# *;
#}
#
## 2. 保护可能相关的其他凭证类和模型类
#-keep class com.tencent.qcloud.core.auth.** {
# *;
#}
#-keep class com.tencent.qcloud.cos.model.** {
# *;
#}
#
## 3. 关键:保护所有类中的所有时间戳字段(按常见命名)
## 这可以防止JSON库因字段名被混淆而无法正确赋值
#-keepclassmembers class ** {
# long beginTime;
# long startTime;
# long expiredTime;
# long expiration;
# java.util.Date beginTime;
# java.util.Date startTime;
# java.util.Date expiredTime;
# java.util.Date expiration;
#}
#
## 4. 保护所有setter/getter方法确保序列化正常
#-keepclassmembers class com.tencent.qcloud.** {
# public void set*(***);
# public *** get*();
#}
#
## 5. 保留所有注解和泛型这对JSON解析至关重要
#-keepattributes Signature, InnerClasses, EnclosingMethod
#-keepattributes *Annotation*
#
## ========== 针对COS服务初始化及请求构造的增强规则 ==========
#
## 1. 精确保护服务配置类CosXmlServiceConfig等这是设置Bucket、Region的地方
#-keep class com.tencent.qcloud.cos.**.CosXmlServiceConfig {
# *;
#}
#-keep class com.tencent.qcloud.cos.**.COSBucket {
# *;
#}
## 保护所有可能存储地域、AppId、BucketName等配置的类
#-keep class * implements com.tencent.qcloud.core.common.QCloudClientConfig {
# *;
#}
#
## 2. 保护所有与“主机”、“域名”、“端点”相关的字段和方法(使用模糊匹配)
#-keepclassmembers class com.tencent.qcloud.** {
# # 保护所有可能是字符串类型的配置字段
# java.lang.String bucketName;
# java.lang.String bucket;
# java.lang.String region;
# java.lang.String appid;
# java.lang.String endpoint;
# java.lang.String host;
# java.lang.String suffix;
# # 保护这些字段的getter/setter方法
# public void set*(***);
# public *** get*();
#}
#
## 3. 保护所有用于构建请求、URL的Builder类或相关类
#-keep class com.tencent.qcloud.cos.**.builder.** {
# *;
#}
#-keep class com.tencent.qcloud.cos.transfer.** {
# *;
#}
#
## 4. 【关键】保留所有注解很多SDK使用注解来标记配置
#-keepattributes *Annotation*
## 保留所有可能用于序列化配置的类成员
#-keepclassmembers class ** {
# @com.tencent.qcloud.core.auth.SensitiveData *;
#}
#
## 1. 直接保护出错堆栈中的核心类 CosXmlBaseService 及其一切
#-keep class com.tencent.cos.xml.CosXmlBaseService {
# *;
#}
## 2. 保护其所有内部类和父类/子类
#-keep class * extends com.tencent.cos.xml.CosXmlBaseService {
# *;
#}
## 3. 保护所有可能用于存储Bucket、Region等配置的模型类
#-keep class com.tencent.cos.xml.model.** {
# *;
#}
## 4. 额外保护所有涉及“host”、“endpoint”、“bucket”、“region”字符串的字段无论它在哪个类
#-keepclassmembers class ** {
# @com.tencent.qcloud.core.auth.SensitiveData <fields>;
# java.lang.String *bucket*;
# java.lang.String *region*;
# java.lang.String *endpoint*;
# java.lang.String *host*;
# java.lang.String *appid*;
#}
#-keep class com.qcloud.cos.model.** { *; }
#-keep class * implements com.qcloud.cos.** { *; }
#-keepattributes Signature, *Annotation*
#-keep class com.qcloud.cos.**$* { *; }