Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Setting] 난독화 #233

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

[Setting] 난독화 #233

wants to merge 2 commits into from

Conversation

HI-JIN2
Copy link
Member

@HI-JIN2 HI-JIN2 commented Oct 25, 2024

Summary

난독화 코드 추가

Summary by CodeRabbit

  • 새로운 기능
    • APK 크기를 줄이고 코드 난독화를 위한 최적화 설정이 추가되었습니다.
  • 버그 수정
    • 해당 변경 사항은 없음.
  • 문서화
    • 해당 변경 사항은 없음.
  • 리팩토링
    • 해당 변경 사항은 없음.
  • 스타일
    • 해당 변경 사항은 없음.
  • 테스트
    • 해당 변경 사항은 없음.
  • 잡일
    • 해당 변경 사항은 없음.
  • 되돌리기
    • 해당 변경 사항은 없음.

Copy link

coderabbitai bot commented Oct 25, 2024

Walkthrough

이 변경 사항은 Android 애플리케이션의 build.gradle.kts 파일에 여러 수정을 도입합니다. 주로 release 빌드 유형의 설정이 변경되어 리소스 축소 및 코드 축소가 활성화되었습니다. isMinifyEnabledshrinkResources가 각각 true로 설정되었으며, debug 빌드 유형은 이전 구성 그대로 유지됩니다. 전체 구조는 변경되지 않았고, 의존성 부분도 추가되거나 제거된 라이브러리가 없습니다.

Changes

파일 경로 변경 요약
app/build.gradle.kts release 빌드 유형에서 isMinifyEnabledshrinkResourcestrue로 변경. debug 빌드는 변경 없음. 전체 구조 및 의존성 부분은 변경 없음.
app/proguard-rules.pro 여러 ProGuard 규칙 추가: Retrofit2, OkHttp, Hilt, Firebase Analytics, Gson, Coroutines, AndroidX 관련 클래스 및 인터페이스 유지.

Poem

🐰 변화의 바람이 불어와
APK가 가벼워져 기뻐라!
코드가 숨겨지고 빛나니,
최적화의 길로 나아가네.
작은 발자국으로 큰 꿈을,
토끼의 희망이 여기 있네! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@HI-JIN2 HI-JIN2 self-assigned this Oct 25, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1f4a727 and 4a2653d.

📒 Files selected for processing (1)
  • app/build.gradle.kts (1 hunks)
🔇 Additional comments (2)
app/build.gradle.kts (2)

48-49: 난독화 및 리소스 축소 설정이 활성화되었습니다.

코드 난독화와 리소스 축소 설정이 올바르게 적용되었습니다. 이는 앱의 보안성을 향상시키고 APK 크기를 최적화하는데 도움이 될 것입니다.


48-51: 릴리즈 빌드 테스트 권장사항

난독화를 활성화한 후에는 다음 기능들에 대한 철저한 테스트가 필요합니다:

  1. Kakao 로그인
  2. 서버 API 통신
  3. Firebase 크래시 리포팅
  4. 딥링크 처리

이러한 기능들이 프로젝트에서 사용되는지 확인:

#!/bin/bash
# Description: Verify usage of critical features that need testing
echo "Checking for critical feature usage..."
rg -l "KakaoSdk" .
rg -l "Retrofit" .
rg -l "FirebaseAnalytics" .
rg -l "android:scheme" app/src/main/AndroidManifest.xml

Comment on lines +48 to 51
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")

var shrinkResources = false
var minifyEnabled = false
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

ProGuard 규칙이 불완전합니다. 추가 규칙이 필요합니다.

현재 proguard-rules.pro 파일에는 Kakao SDK에 대한 규칙만 포함되어 있습니다. 다음 라이브러리들에 대한 ProGuard 규칙이 누락되어 있습니다:

  • Retrofit2 및 OkHttp
  • Hilt
  • Firebase Analytics
  • Gson
  • Coroutines
  • AndroidX 컴포넌트

특히 다음 규칙들의 추가가 필요합니다:

  • Retrofit 인터페이스와 데이터 모델 클래스 보존
  • Hilt 의존성 주입 관련 클래스 보존
  • Coroutines 관련 클래스 보존
  • Firebase Analytics 이벤트 추적 클래스 보존
🔗 Analysis chain

ProGuard 규칙 검증이 필요합니다.

현재 프로젝트에서 사용 중인 주요 라이브러리들에 대한 ProGuard 규칙이 필요합니다:

  • Retrofit 인터페이스
  • Hilt 의존성 주입
  • Kakao SDK
  • Firebase Analytics
  • Kotlin Serialization

다음 사항들을 확인해주세요:

  1. proguard-rules.pro 파일에 필요한 keep 규칙들이 모두 포함되어 있는지 검토
  2. 테스트 빌드를 통해 런타임 오류가 발생하지 않는지 확인
  3. 난독화 후에도 주요 기능들이 정상 동작하는지 검증
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify ProGuard rules existence and content
echo "Checking ProGuard rules file..."
if [ -f "app/proguard-rules.pro" ]; then
    echo "Content of proguard-rules.pro:"
    cat app/proguard-rules.pro
else
    echo "Warning: proguard-rules.pro file not found!"
fi

Length of output: 971


Script:

#!/bin/bash
# Let's check for the proguard rules file and its content
echo "Checking proguard-rules.pro..."
find . -name "proguard-rules.pro" -type f -exec cat {} \;

# Check for Hilt usage
echo -e "\nChecking Hilt usage..."
rg -l "dagger.hilt" .

# Check for Kotlin Serialization usage
echo -e "\nChecking Kotlin Serialization usage..."
rg -l "@Serializable" .

# Check build.gradle files for dependencies
echo -e "\nChecking dependencies in build files..."
find . -name "build.gradle*" -type f -exec cat {} \;

Length of output: 8422

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4a2653d and ee18cfe.

📒 Files selected for processing (1)
  • app/proguard-rules.pro (1 hunks)
🔇 Additional comments (3)
app/proguard-rules.pro (3)

61-65: 코루틴 규칙이 적절히 구성되어 있습니다.

코루틴 관련 클래스와 멤버를 보존하는 규칙이 잘 설정되어 있습니다.


48-54: Firebase 커스텀 이벤트 사용 여부를 확인하세요.

주석 처리된 FirebaseEvent 규칙이 필요한지 확인이 필요합니다.

다음 스크립트로 Firebase 커스텀 이벤트 사용 여부를 확인할 수 있습니다:


40-47: Hilt ActivityComponent 규칙의 필요성을 확인하세요.

주석 처리된 ActivityComponent 규칙이 실제로 필요하지 않은지 확인이 필요합니다.

다음 스크립트로 Hilt Activity 사용 여부를 확인할 수 있습니다:

✅ Verification successful

ActivityComponent 규칙은 제거해도 안전합니다

코드베이스 검사 결과, Hilt의 ActivityComponent를 사용하는 Activity가 없는 것으로 확인되었습니다. 주석 처리된 ProGuard 규칙을 완전히 제거해도 안전합니다.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Hilt Activity 사용 여부 확인
rg "@AndroidEntryPoint" -l | xargs rg "extends.*Activity"

Length of output: 57


Script:

#!/bin/bash
# Search for Activity classes with Hilt annotations using different approaches
echo "Searching for Activities with Hilt annotations:"
rg -l "extends.*Activity" | xargs rg "@AndroidEntryPoint"

echo -e "\nSearching for Hilt Activity component usage:"
rg -l "ActivityComponent|@AndroidEntryPoint" | xargs rg "class.*extends.*Activity"

echo -e "\nSearching for any Hilt related Activity patterns:"
ast-grep --pattern 'class $_ extends Activity { $$$ }'

Length of output: 611

Comment on lines +55 to +60
# Gson 보존 (필드명 직렬화/역직렬화 보호)
-keep class com.google.gson.** { *; }
-keepattributes Signature
-keepattributes *Annotation*
-dontwarn com.google.gson.**

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

중복된 Signature 속성 규칙이 있습니다.

-keepattributes Signature 규칙이 32번 줄과 57번 줄에 중복되어 있습니다.

다음과 같이 중복된 규칙을 제거하세요:

 # Gson 보존 (필드명 직렬화/역직렬화 보호)
 -keep class com.google.gson.** { *; }
--keepattributes Signature
 -keepattributes *Annotation*
 -dontwarn com.google.gson.**
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Gson 보존 (필드명 직렬화/역직렬화 보호)
-keep class com.google.gson.** { *; }
-keepattributes Signature
-keepattributes *Annotation*
-dontwarn com.google.gson.**
# Gson 보존 (필드명 직렬화/역직렬화 보호)
-keep class com.google.gson.** { *; }
-keepattributes *Annotation*
-dontwarn com.google.gson.**

Comment on lines +66 to +69
# AndroidX 관련 보존
-keep class androidx.** { *; }
-dontwarn androidx.**

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

AndroidX 규칙을 더 구체적으로 지정하는 것이 좋습니다.

현재 모든 AndroidX 클래스를 보존하고 있어 APK 크기가 불필요하게 커질 수 있습니다.

실제로 사용하는 AndroidX 컴포넌트만 보존하도록 규칙을 수정하는 것을 추천합니다. 예시:

-# AndroidX 관련 보존
--keep class androidx.** { *; }
--dontwarn androidx.**
+# AndroidX 필수 컴포넌트 보존
+-keep class androidx.core.** { *; }
+-keep class androidx.appcompat.** { *; }
+-keep class androidx.fragment.app.** { *; }
+-dontwarn androidx.**
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# AndroidX 관련 보존
-keep class androidx.** { *; }
-dontwarn androidx.**
# AndroidX 필수 컴포넌트 보존
-keep class androidx.core.** { *; }
-keep class androidx.appcompat.** { *; }
-keep class androidx.fragment.app.** { *; }
-dontwarn androidx.**

Comment on lines +27 to +34
# Retrofit2 인터페이스와 데이터 모델 클래스 보존
-keep interface com.eatssu.android.data.service.** { *; }
-keep class com.eatssu.android.data.dto.** { *; }
-dontwarn retrofit2.**
-dontwarn okhttp3.**
-keepattributes Signature
-keepattributes Exceptions

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Signature와 Exceptions 속성 규칙을 더 구체적으로 지정하세요.

현재 구성은 기본적인 보호를 제공하지만, Retrofit 관련 속성을 더 명확하게 지정하면 좋을 것 같습니다.

다음과 같이 수정하는 것을 고려해보세요:

 -keepattributes Signature
 -keepattributes Exceptions
+-keepattributes InnerClasses
+-keepattributes EnclosingMethod
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Retrofit2 인터페이스와 데이터 모델 클래스 보존
-keep interface com.eatssu.android.data.service.** { *; }
-keep class com.eatssu.android.data.dto.** { *; }
-dontwarn retrofit2.**
-dontwarn okhttp3.**
-keepattributes Signature
-keepattributes Exceptions
# Retrofit2 인터페이스와 데이터 모델 클래스 보존
-keep interface com.eatssu.android.data.service.** { *; }
-keep class com.eatssu.android.data.dto.** { *; }
-dontwarn retrofit2.**
-dontwarn okhttp3.**
-keepattributes Signature
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes EnclosingMethod

Comment on lines +70 to +80
# Retrofit의 어노테이션 보존
-keepattributes RuntimeVisibleAnnotations
-keepattributes RuntimeVisibleParameterAnnotations

# 일반적인 자바 어노테이션 보존
-keepattributes *Annotation*

# 모든 직렬화된 클래스 보존
-keepclassmembers class * {
@com.google.gson.annotations.SerializedName <fields>;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

중복된 어노테이션 속성 규칙을 통합하세요.

-keepattributes *Annotation* 규칙이 58번 줄과 75번 줄에 중복되어 있습니다. 또한, 어노테이션 관련 규칙들을 한 곳에 모으면 가독성이 향상될 것 같습니다.

다음과 같이 어노테이션 관련 규칙을 통합하세요:

+# 어노테이션 관련 규칙
+-keepattributes *Annotation*
+-keepattributes RuntimeVisibleAnnotations
+-keepattributes RuntimeVisibleParameterAnnotations

 # Retrofit의 어노테이션 보존
--keepattributes RuntimeVisibleAnnotations
--keepattributes RuntimeVisibleParameterAnnotations

 # 일반적인 자바 어노테이션 보존
--keepattributes *Annotation*
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Retrofit의 어노테이션 보존
-keepattributes RuntimeVisibleAnnotations
-keepattributes RuntimeVisibleParameterAnnotations
# 일반적인 자바 어노테이션 보존
-keepattributes *Annotation*
# 모든 직렬화된 클래스 보존
-keepclassmembers class * {
@com.google.gson.annotations.SerializedName <fields>;
}
# 어노테이션 관련 규칙
-keepattributes *Annotation*
-keepattributes RuntimeVisibleAnnotations
-keepattributes RuntimeVisibleParameterAnnotations
# 모든 직렬화된 클래스 보존
-keepclassmembers class * {
@com.google.gson.annotations.SerializedName <fields>;
}

Comment on lines +35 to +39
# OkHttp 보존
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

중복된 OkHttp 경고 무시 규칙이 있습니다.

-dontwarn okhttp3.** 규칙이 31번 줄과 38번 줄에 중복되어 있습니다.

다음과 같이 중복된 규칙을 제거하세요:

 # OkHttp 보존
 -keep class okhttp3.** { *; }
 -keep interface okhttp3.** { *; }
--dontwarn okhttp3.**
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# OkHttp 보존
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**
# OkHttp 보존
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant