feat: support Protocol Buffers payload inspection - #81
Conversation
기존 String/JSON 경로를 유지하면서 앱 주입 decoder, 메타데이터 저장, UI·export 표시를 추가한다.
📝 WalkthroughWalkthroughThe PR adds runtime-agnostic Protocol Buffers interception. It decodes byte-array payloads through an app-provided decoder, stores decode metadata and original sizes, and exposes the data in persistence, UI, exports, tests, and documentation. ChangesProtocol Buffers inspection
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant WebView
participant DefaultDariInterceptor
participant ProtobufPayloadRenderer
participant MessageRepository
participant DariDetailActivity
WebView->>DefaultDariInterceptor: Send protobuf request or response bytes
DefaultDariInterceptor->>ProtobufPayloadRenderer: Decode and create metadata
ProtobufPayloadRenderer-->>DefaultDariInterceptor: Return rendered text and raw preview
DefaultDariInterceptor->>MessageRepository: Insert or update message metadata
MessageRepository-->>DariDetailActivity: Provide stored message entry
DariDetailActivity-->>WebView: Display decoded or raw payload view
Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@dari/src/main/kotlin/com/easyhooon/dari/data/local/DariDatabase.kt`:
- Line 11: Add a Room Migration(3, 4) for DariDatabase that alters the existing
messages table to add the new nullable metadata columns, and register it with
the database builder. Preserve existing rows and avoid relying solely on
fallbackToDestructiveMigration(dropAllTables = true) for schema-3 upgrades.
In
`@dari/src/main/kotlin/com/easyhooon/dari/interceptor/DefaultDariInterceptor.kt`:
- Around line 202-204: Update DefaultDariInterceptor’s protobuf rendering path,
especially renderProtobuf, to handle a null protobufDecoder without throwing.
Return an unavailable rendered payload using
PayloadDecodeStatus.DECODER_UNAVAILABLE while preserving the existing
placeholder text and metadata; keep normal decoding unchanged when the decoder
is present.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: cb7c395f-d897-4e97-b4a2-9ffa26952091
📒 Files selected for processing (25)
README.mddari-core/src/main/kotlin/com/easyhooon/dari/DariConfig.ktdari-core/src/main/kotlin/com/easyhooon/dari/MessageEntry.ktdari-core/src/main/kotlin/com/easyhooon/dari/MessagePayloadMetadata.ktdari-core/src/main/kotlin/com/easyhooon/dari/interceptor/ProtobufDariInterceptor.ktdari-noop/src/main/kotlin/com/easyhooon/dari/Dari.ktdari/src/main/kotlin/com/easyhooon/dari/Dari.ktdari/src/main/kotlin/com/easyhooon/dari/data/MessageRepository.ktdari/src/main/kotlin/com/easyhooon/dari/data/local/Converters.ktdari/src/main/kotlin/com/easyhooon/dari/data/local/DariDatabase.ktdari/src/main/kotlin/com/easyhooon/dari/data/local/MessageDao.ktdari/src/main/kotlin/com/easyhooon/dari/data/local/MessageEntity.ktdari/src/main/kotlin/com/easyhooon/dari/export/DariExporter.ktdari/src/main/kotlin/com/easyhooon/dari/export/ExportableMessage.ktdari/src/main/kotlin/com/easyhooon/dari/interceptor/DefaultDariInterceptor.ktdari/src/main/kotlin/com/easyhooon/dari/interceptor/ProtobufPayloadRenderer.ktdari/src/main/kotlin/com/easyhooon/dari/ui/DariDetailActivity.ktdari/src/test/kotlin/com/easyhooon/dari/MessageEntryTest.ktdari/src/test/kotlin/com/easyhooon/dari/data/local/MessageEntityTest.ktdari/src/test/kotlin/com/easyhooon/dari/export/ExportableMessageTest.ktdari/src/test/kotlin/com/easyhooon/dari/interceptor/ProtobufPayloadRendererTest.ktdocumentation/content/docs/index.mdxdocumentation/content/docs/interceptor.mdxdocumentation/content/docs/ko/index.mdxdocumentation/content/docs/ko/interceptor.mdx
🤖 CodeRabbit Review ResolutionTotal unresolved: 2 | Applied: 2 | Declined: 0 ✅ Applied
❌ DeclinedNone. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@sample/src/main/java/com/easyhooon/dari/sample/MainActivity.kt`:
- Around line 141-167: Wrap the Base64.decode call in onProtobufBridgeRequest
with the existing runCatching flow so decoding failures are handled before
protobuf parsing. On any decode failure, produce a generic unsuccessful protobuf
response and ensure both onWebToAppProtobufResponse and callProtobufJs are still
invoked with success=false; preserve the current parsed-response behavior for
valid decoded data.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: bd926b1d-b74f-4a50-aba9-7150b0010f4a
📒 Files selected for processing (24)
README.mddari-core/src/main/kotlin/com/easyhooon/dari/MessagePayloadMetadata.ktdari/src/main/kotlin/com/easyhooon/dari/RawPayloadFormatter.ktdari/src/main/kotlin/com/easyhooon/dari/data/MessageRepository.ktdari/src/main/kotlin/com/easyhooon/dari/data/local/DariDatabase.ktdari/src/main/kotlin/com/easyhooon/dari/data/local/MessageDao.ktdari/src/main/kotlin/com/easyhooon/dari/data/local/MessageEntity.ktdari/src/main/kotlin/com/easyhooon/dari/export/DariExporter.ktdari/src/main/kotlin/com/easyhooon/dari/export/ExportableMessage.ktdari/src/main/kotlin/com/easyhooon/dari/interceptor/DefaultDariInterceptor.ktdari/src/main/kotlin/com/easyhooon/dari/interceptor/ProtobufPayloadRenderer.ktdari/src/main/kotlin/com/easyhooon/dari/ui/DariDetailActivity.ktdari/src/main/kotlin/com/easyhooon/dari/ui/components/JsonViewer.ktdari/src/test/kotlin/com/easyhooon/dari/RawPayloadFormatterTest.ktdari/src/test/kotlin/com/easyhooon/dari/data/local/MessageEntityTest.ktdari/src/test/kotlin/com/easyhooon/dari/export/DariExporterTest.ktdari/src/test/kotlin/com/easyhooon/dari/export/ExportableMessageTest.ktdari/src/test/kotlin/com/easyhooon/dari/interceptor/ProtobufPayloadRendererTest.ktdocumentation/content/docs/interceptor.mdxdocumentation/content/docs/ko/interceptor.mdxgradle/libs.versions.tomlsample/build.gradle.ktssample/src/main/assets/sample.htmlsample/src/main/java/com/easyhooon/dari/sample/MainActivity.kt
🚧 Files skipped from review as they are similar to previous changes (10)
- dari/src/main/kotlin/com/easyhooon/dari/data/MessageRepository.kt
- documentation/content/docs/ko/interceptor.mdx
- dari/src/test/kotlin/com/easyhooon/dari/export/ExportableMessageTest.kt
- dari/src/test/kotlin/com/easyhooon/dari/data/local/MessageEntityTest.kt
- README.md
- dari/src/main/kotlin/com/easyhooon/dari/interceptor/ProtobufPayloadRenderer.kt
- dari/src/main/kotlin/com/easyhooon/dari/data/local/MessageDao.kt
- dari/src/main/kotlin/com/easyhooon/dari/data/local/MessageEntity.kt
- dari/src/main/kotlin/com/easyhooon/dari/interceptor/DefaultDariInterceptor.kt
- documentation/content/docs/interceptor.mdx
| @JavascriptInterface | ||
| fun onProtobufBridgeRequest(requestId: String, base64Data: String) { | ||
| val requestData = Base64.decode(base64Data, Base64.NO_WRAP) | ||
| interceptor?.onWebToAppProtobufRequest(PROTOBUF_HANDLER, requestId, requestData) | ||
|
|
||
| val result = runCatching { | ||
| val request = StringValue.parseFrom(requestData) | ||
| StringValue.newBuilder() | ||
| .setValue("Android received: ${request.value}") | ||
| .build() | ||
| } | ||
| val response = result.getOrElse { error -> | ||
| StringValue.newBuilder() | ||
| .setValue("Invalid protobuf: ${error.message}") | ||
| .build() | ||
| } | ||
| val success = result.isSuccess | ||
| val responseData = response.toByteArray() | ||
|
|
||
| interceptor?.onWebToAppProtobufResponse( | ||
| PROTOBUF_HANDLER, | ||
| requestId, | ||
| responseData, | ||
| success, | ||
| ) | ||
| callProtobufJs(requestId, success, responseData) | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Handle Base64 decoding failures before capture.
At Line 143, Base64.decode runs before runCatching. If base64Data has invalid padding, it throws IllegalArgumentException, exits the JavaScript interface method, and does not send onProtobufBridgeResponse. Catch this failure, create a generic protobuf failure response, and call callProtobufJs. (developer.android.com)
This conflicts with the malformed-payload handling objective.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@sample/src/main/java/com/easyhooon/dari/sample/MainActivity.kt` around lines
141 - 167, Wrap the Base64.decode call in onProtobufBridgeRequest with the
existing runCatching flow so decoding failures are handled before protobuf
parsing. On any decode failure, produce a generic unsuccessful protobuf response
and ensure both onWebToAppProtobufResponse and callProtobufJs are still invoked
with success=false; preserve the current parsed-response behavior for valid
decoded data.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@README.md`:
- Around line 176-177: Add concise, descriptive alt attributes to both img
elements for protobuf_decoded.png and protobuf_raw.png, while preserving their
existing sources and dimensions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6b252728-5f7e-41b0-9c9f-52a936a1dbb5
⛔ Files ignored due to path filters (2)
screenshots/protobuf_decoded.pngis excluded by!**/*.pngscreenshots/protobuf_raw.pngis excluded by!**/*.png
📒 Files selected for processing (1)
README.md
| <td><img src="screenshots/protobuf_decoded.png" width="320" /></td> | ||
| <td><img src="screenshots/protobuf_raw.png" width="320" /></td> |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add alternative text to both screenshots.
The <img> elements on Lines 176 and 177 have no alt attributes. Add concise descriptions for screen-reader users.
Proposed fix
- <td><img src="screenshots/protobuf_decoded.png" width="320" /></td>
- <td><img src="screenshots/protobuf_raw.png" width="320" /></td>
+ <td><img src="screenshots/protobuf_decoded.png" alt="Protobuf decoded payload view" width="320" /></td>
+ <td><img src="screenshots/protobuf_raw.png" alt="Protobuf raw bytes view" width="320" /></td>📝 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.
| <td><img src="screenshots/protobuf_decoded.png" width="320" /></td> | |
| <td><img src="screenshots/protobuf_raw.png" width="320" /></td> | |
| <td><img src="screenshots/protobuf_decoded.png" alt="Protobuf decoded payload view" width="320" /></td> | |
| <td><img src="screenshots/protobuf_raw.png" alt="Protobuf raw bytes view" width="320" /></td> |
🧰 Tools
🪛 markdownlint-cli2 (0.23.1)
[warning] 176-176: Images should have alternate text (alt text)
(MD045, no-alt-text)
[warning] 177-177: Images should have alternate text (alt text)
(MD045, no-alt-text)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@README.md` around lines 176 - 177, Add concise, descriptive alt attributes to
both img elements for protobuf_decoded.png and protobuf_raw.png, while
preserving their existing sources and dimensions.
Source: Linters/SAST tools
Summary
ProtobufDariInterceptorand app-provided decoder without introducing a protobuf runtime dependencyCompatibility
DariInterceptorString/JSON methods remain unchangedcreateInterceptoroverload1.5.1; the feature is intended for the next minor releaseTesting
./gradlew clean check :sample:assembleDebug :sample:assembleRelease./gradlew :dari:assembleReleasecd documentation && npm run buildCloses #80
Summary by CodeRabbit
New Features
Documentation