reproto 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl
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.
- .git/COMMIT_EDITMSG +1 -30
- .git/index +0 -0
- .git/logs/HEAD +4 -0
- .git/logs/refs/heads/iyue +4 -0
- .git/logs/refs/remotes/gitlab/iyue +4 -0
- .git/logs/refs/remotes/origin/iyue +4 -0
- .git/objects/00/81a7e1ec3251cc192ed2b73d5be897593fb872 +0 -0
- .git/objects/00/885cebf557ff261574deb93cb96449d06db01c +0 -0
- .git/objects/02/33f5b60263e5dc6d041c0b223a0724eb650faa +0 -0
- .git/objects/07/557fbd1d149ce51af8e98e8ca8590757a89dfa +0 -0
- .git/objects/08/760c38a9f9a4b5d4de0a1df0d197b27c1592d6 +0 -0
- .git/objects/12/f9cc4ad0b4f0af4f7bae379f281b2cebe7cc7f +0 -0
- .git/objects/22/316ec4a32601c236f997552e9600b7b40e3162 +0 -0
- .git/objects/24/d78e796570a8572a03bc1dd26608a7cfb506f8 +2 -0
- .git/objects/2a/fe93d8bcbeab9e136d8b6766604c32b3610314 +0 -0
- .git/objects/2d/8a0da260a710010ae62be134ac1cea6ceecfd1 +0 -0
- .git/objects/2d/e8ecbb5ab5de1a032bef3f4606ce5fa7c6c4e8 +0 -0
- .git/objects/30/9347e5681d80bd3c7949882e27090dd9070d16 +0 -0
- .git/objects/33/633c9df669ff8cf38638717937a54990814268 +0 -0
- .git/objects/39/993e3600bf4ab82aa361b738ee97a108787450 +0 -0
- .git/objects/3b/ab663710fd6b43d9372313fced9043c4cb07dd +0 -0
- .git/objects/3e/b3f1273caf6814dfa69325ccbd9fd1340cf20a +0 -0
- .git/objects/3f/ac4973433ec0116d2348fe7a748a0002702efb +0 -0
- .git/objects/40/c6c8816b3ebd8cac4fa36f20454c84aa5929d1 +0 -0
- .git/objects/45/fbc774dedb61c7c205ea732f59a8dca8d13555 +3 -0
- .git/objects/5d/3e5b3d75b03eba63deda0dcac7ca304d41e4da +0 -0
- .git/objects/60/5cb6fd6a9f8894ad4d43a9b8e4785c1b3b0e17 +1 -0
- .git/objects/60/f61a0ea50091eac8d344c86597375cbdfc2785 +0 -0
- .git/objects/63/ddda2a403efaab3f4c6597b3a73a7b1147adb5 +0 -0
- .git/objects/66/6c5c5fc30435228116fa08c9d821bebaaa8926 +0 -0
- .git/objects/7c/ef0adfb28fd774bc78061c6f088e1ef9b050f6 +0 -0
- .git/objects/7d/dc129188a10c68ab756ef2cacb292c76920403 +0 -0
- .git/objects/80/17038e0f7818a44a742f77c86f4f88ed768fcd +0 -0
- .git/objects/87/c7db6c91c17a2df84b56d30bd24a0f6b9dbdd9 +0 -0
- .git/objects/90/6b05fdb9211a7d32515bb2da31e58e4ca89916 +0 -0
- .git/objects/92/984cf67b2c25d435468a8218daa26ba0466054 +0 -0
- .git/objects/93/140b54b1fb9116ee214afee8abf2c72a232487 +0 -0
- .git/objects/93/68f2c32f83054ab072b7c9686d8baa0bad7f12 +4 -0
- .git/objects/9a/5ad062be9f6e001f4237a598a08981aba731e6 +0 -0
- .git/objects/a1/655e0cb323c300562f97dcc67d5a446908c8ec +0 -0
- .git/objects/a5/38cc82cef7c49500d3522220f0f60a9ebc1ae6 +0 -0
- .git/objects/a9/41063a7ce89c353fa24378ec7c3f12f08f9df8 +0 -0
- .git/objects/ac/5c983d949d8c928bb022badf801e45e75e785e +0 -0
- .git/objects/b0/82ca2c1b5a03edff25da3c2b2b573d049877e9 +0 -0
- .git/objects/b2/a941b669991d7e0f9bdc35f1014897a933f4e2 +1 -0
- .git/objects/bc/e98bdb71c8681acb460195fdcbbe5d36290976 +0 -0
- .git/objects/c1/87d5e047eca86cfd8d444be2987aaa3f62c4d6 +0 -0
- .git/objects/c4/c2da96b0bb8db2acb0e6615cf340c7e51af26b +0 -0
- .git/objects/c5/13a96e7584636b20b12280c029750d5bc3da1e +0 -0
- .git/objects/c7/c34283697bd3cce07db53953eda25ee7cc371e +0 -0
- .git/objects/c9/d60d922a04b87587cd67b0abf9fe5a7b7b76cd +0 -0
- .git/objects/d2/69b1676dbf32f76a7c405d0b4ea6a70ac3a626 +0 -0
- .git/objects/d3/5a918b1d9125ad35d60e08b181323df3246f1a +0 -0
- .git/objects/d8/eaf86669fbfd10497570c1784db1ed2696b588 +0 -0
- .git/objects/d9/90e6d553577d37ebce8b28b3015ecbde038b42 +0 -0
- .git/objects/da/13cc15bcd8ee39c81f36dee7f179a569ecab0b +0 -0
- .git/objects/e4/4c1d8a90207ac082d8ab7ff0db66708e2ebc31 +0 -0
- .git/objects/e6/5ff9bea681f0b8f409ec27761935883c1f0cc9 +0 -0
- .git/objects/f8/ed595d25bd9d500e765a792c513878f7ddb1f7 +0 -0
- .git/refs/heads/iyue +1 -1
- .git/refs/remotes/gitlab/iyue +1 -1
- .git/refs/remotes/origin/iyue +1 -1
- README.md +104 -190
- core/__init__.py +23 -0
- core/info_decoder.py +13 -4
- core/reconstructor.py +25 -16
- generation/__init__.py +17 -0
- generation/proto_generator.py +11 -5
- main.py +59 -56
- models/__init__.py +31 -24
- parsing/__init__.py +22 -0
- parsing/enum_parser.py +10 -2
- parsing/java_parser.py +7 -1
- pyproject.toml +2 -1
- reproto-0.1.4.dist-info/METADATA +210 -0
- {reproto-0.1.2.dist-info → reproto-0.1.4.dist-info}/RECORD +85 -31
- requirements.txt +3 -1
- utils/__init__.py +55 -0
- utils/builtin_proto.py +8 -1
- utils/file_cache.py +8 -1
- utils/report_utils.py +71 -0
- utils/type_index.py +8 -1
- utils/version_checker.py +311 -0
- core/bytecode_parser.py +0 -274
- reproto-0.1.2.dist-info/METADATA +0 -295
- {reproto-0.1.2.dist-info → reproto-0.1.4.dist-info}/WHEEL +0 -0
- {reproto-0.1.2.dist-info → reproto-0.1.4.dist-info}/entry_points.txt +0 -0
.git/COMMIT_EDITMSG
CHANGED
@@ -1,30 +1 @@
|
|
1
|
-
feat:
|
2
|
-
|
3
|
-
🎯 主要改进:
|
4
|
-
- 完全移除硬编码字段标签映射,实现完全基于Java源码的动态分析
|
5
|
-
- 修复oneof结构解析问题,正确处理复杂的混合字段结构
|
6
|
-
- 解决字段标签重复分配问题,避免类引用冲突
|
7
|
-
- 添加内部类和匿名类的原始Java类名注释功能
|
8
|
-
|
9
|
-
🔧 核心技术突破:
|
10
|
-
- 智能字段-类型配对识别:正确区分字段类型和独立类引用
|
11
|
-
- 完善的oneof检测算法:支持普通字段+oneof混合结构
|
12
|
-
- 动态字段标签匹配:支持多种命名模式的智能转换
|
13
|
-
- 已使用标签冲突检测:防止重复分配字段标签
|
14
|
-
|
15
|
-
✅ 解决的关键问题:
|
16
|
-
- 零WARNING日志:完全消除"无法找到类XXX的字段标签"警告
|
17
|
-
- oneof结构完整性:正确生成包含所有选项的oneof字段
|
18
|
-
- 字段标签唯一性:彻底解决重复标签问题
|
19
|
-
- 引用一致性:oneof字段类型名与实际消息名完全匹配
|
20
|
-
|
21
|
-
📝 新增功能:
|
22
|
-
- 原始Java类名注释:为内部类/匿名类添加可追溯性注释
|
23
|
-
- Google Protobuf内置类型支持:完整的well-known types集成
|
24
|
-
- 智能类名清理:正确处理
|
25
|
-
|
26
|
-
🎉 最终成果:
|
27
|
-
- CompleteOnboardingRequest: 5个普通字段 + 完整oneof结构
|
28
|
-
- SearchResult: 纯oneof结构,无多余字段
|
29
|
-
- Business: 13个字段,零重复标签,零WARNING
|
30
|
-
- 所有生成的proto文件都具有完美的引用一致性和可追溯性
|
1
|
+
feat(version): :fire: check version
|
.git/index
CHANGED
Binary file
|
.git/logs/HEAD
CHANGED
@@ -13,3 +13,7 @@ e41e5aa2bc3074c2014d01ab1f603f69c327a83f b07a43f0462bf25a8b1f4c0ca60c1b533dae1dd
|
|
13
13
|
b07a43f0462bf25a8b1f4c0ca60c1b533dae1dde 3d3cc6aab4eefed46c77dda27503bebcce88962c iyue <ys1231@126.com> 1751011389 +0800 commit: release: v2.1.0 - 重大性能优化和功能增强
|
14
14
|
3d3cc6aab4eefed46c77dda27503bebcce88962c 7e5935774ee7a85f2523427c9100f9c578ac172f iyue <ys1231@126.com> 1751011558 +0800 commit: feat(build): update version
|
15
15
|
7e5935774ee7a85f2523427c9100f9c578ac172f 07b71df33935c14ddf99e3480c04eca4685028bc iyue <ys1231@126.com> 1751093937 +0800 commit: feat: 完善proto重构系统 - 硬编码移除与智能分析优化
|
16
|
+
07b71df33935c14ddf99e3480c04eca4685028bc 12f9cc4ad0b4f0af4f7bae379f281b2cebe7cc7f iyue <ys1231@126.com> 1751096494 +0800 commit: feat: 代码优化
|
17
|
+
12f9cc4ad0b4f0af4f7bae379f281b2cebe7cc7f 9368f2c32f83054ab072b7c9686d8baa0bad7f12 iyue <ys1231@126.com> 1751101028 +0800 commit: 重构: 将print_results_summary函数移动到utils.report_utils模块
|
18
|
+
9368f2c32f83054ab072b7c9686d8baa0bad7f12 2de8ecbb5ab5de1a032bef3f4606ce5fa7c6c4e8 iyue <ys1231@126.com> 1751103208 +0800 commit: feat: 实施智能导入系统并优化README
|
19
|
+
2de8ecbb5ab5de1a032bef3f4606ce5fa7c6c4e8 b2a941b669991d7e0f9bdc35f1014897a933f4e2 iyue <ys1231@126.com> 1751105571 +0800 commit: feat(version): :fire: check version
|
.git/logs/refs/heads/iyue
CHANGED
@@ -13,3 +13,7 @@ e41e5aa2bc3074c2014d01ab1f603f69c327a83f b07a43f0462bf25a8b1f4c0ca60c1b533dae1dd
|
|
13
13
|
b07a43f0462bf25a8b1f4c0ca60c1b533dae1dde 3d3cc6aab4eefed46c77dda27503bebcce88962c iyue <ys1231@126.com> 1751011389 +0800 commit: release: v2.1.0 - 重大性能优化和功能增强
|
14
14
|
3d3cc6aab4eefed46c77dda27503bebcce88962c 7e5935774ee7a85f2523427c9100f9c578ac172f iyue <ys1231@126.com> 1751011558 +0800 commit: feat(build): update version
|
15
15
|
7e5935774ee7a85f2523427c9100f9c578ac172f 07b71df33935c14ddf99e3480c04eca4685028bc iyue <ys1231@126.com> 1751093937 +0800 commit: feat: 完善proto重构系统 - 硬编码移除与智能分析优化
|
16
|
+
07b71df33935c14ddf99e3480c04eca4685028bc 12f9cc4ad0b4f0af4f7bae379f281b2cebe7cc7f iyue <ys1231@126.com> 1751096494 +0800 commit: feat: 代码优化
|
17
|
+
12f9cc4ad0b4f0af4f7bae379f281b2cebe7cc7f 9368f2c32f83054ab072b7c9686d8baa0bad7f12 iyue <ys1231@126.com> 1751101028 +0800 commit: 重构: 将print_results_summary函数移动到utils.report_utils模块
|
18
|
+
9368f2c32f83054ab072b7c9686d8baa0bad7f12 2de8ecbb5ab5de1a032bef3f4606ce5fa7c6c4e8 iyue <ys1231@126.com> 1751103208 +0800 commit: feat: 实施智能导入系统并优化README
|
19
|
+
2de8ecbb5ab5de1a032bef3f4606ce5fa7c6c4e8 b2a941b669991d7e0f9bdc35f1014897a933f4e2 iyue <ys1231@126.com> 1751105571 +0800 commit: feat(version): :fire: check version
|
@@ -12,3 +12,7 @@ e41e5aa2bc3074c2014d01ab1f603f69c327a83f b07a43f0462bf25a8b1f4c0ca60c1b533dae1dd
|
|
12
12
|
b07a43f0462bf25a8b1f4c0ca60c1b533dae1dde 3d3cc6aab4eefed46c77dda27503bebcce88962c iyue <ys1231@126.com> 1751011478 +0800 update by push
|
13
13
|
3d3cc6aab4eefed46c77dda27503bebcce88962c 7e5935774ee7a85f2523427c9100f9c578ac172f iyue <ys1231@126.com> 1751011568 +0800 update by push
|
14
14
|
7e5935774ee7a85f2523427c9100f9c578ac172f 07b71df33935c14ddf99e3480c04eca4685028bc iyue <ys1231@126.com> 1751094024 +0800 update by push
|
15
|
+
07b71df33935c14ddf99e3480c04eca4685028bc 12f9cc4ad0b4f0af4f7bae379f281b2cebe7cc7f iyue <ys1231@126.com> 1751096510 +0800 update by push
|
16
|
+
12f9cc4ad0b4f0af4f7bae379f281b2cebe7cc7f 9368f2c32f83054ab072b7c9686d8baa0bad7f12 iyue <ys1231@126.com> 1751101083 +0800 update by push
|
17
|
+
9368f2c32f83054ab072b7c9686d8baa0bad7f12 2de8ecbb5ab5de1a032bef3f4606ce5fa7c6c4e8 iyue <ys1231@126.com> 1751103234 +0800 update by push
|
18
|
+
2de8ecbb5ab5de1a032bef3f4606ce5fa7c6c4e8 b2a941b669991d7e0f9bdc35f1014897a933f4e2 iyue <ys1231@126.com> 1751105581 +0800 update by push
|
@@ -12,3 +12,7 @@ e41e5aa2bc3074c2014d01ab1f603f69c327a83f b07a43f0462bf25a8b1f4c0ca60c1b533dae1dd
|
|
12
12
|
b07a43f0462bf25a8b1f4c0ca60c1b533dae1dde 3d3cc6aab4eefed46c77dda27503bebcce88962c iyue <ys1231@126.com> 1751011447 +0800 update by push
|
13
13
|
3d3cc6aab4eefed46c77dda27503bebcce88962c 7e5935774ee7a85f2523427c9100f9c578ac172f iyue <ys1231@126.com> 1751011577 +0800 update by push
|
14
14
|
7e5935774ee7a85f2523427c9100f9c578ac172f 07b71df33935c14ddf99e3480c04eca4685028bc iyue <ys1231@126.com> 1751093982 +0800 update by push
|
15
|
+
07b71df33935c14ddf99e3480c04eca4685028bc 12f9cc4ad0b4f0af4f7bae379f281b2cebe7cc7f iyue <ys1231@126.com> 1751096519 +0800 update by push
|
16
|
+
12f9cc4ad0b4f0af4f7bae379f281b2cebe7cc7f 9368f2c32f83054ab072b7c9686d8baa0bad7f12 iyue <ys1231@126.com> 1751101033 +0800 update by push
|
17
|
+
9368f2c32f83054ab072b7c9686d8baa0bad7f12 2de8ecbb5ab5de1a032bef3f4606ce5fa7c6c4e8 iyue <ys1231@126.com> 1751103218 +0800 update by push
|
18
|
+
2de8ecbb5ab5de1a032bef3f4606ce5fa7c6c4e8 b2a941b669991d7e0f9bdc35f1014897a933f4e2 iyue <ys1231@126.com> 1751105599 +0800 update by push
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,2 @@
|
|
1
|
+
x�RMo�@��_�J�BB�#B=�!�I7�����k�܂��CSZ�Rh U��*����L�N���:vQT�=X�7o�̾��F����;w�% N;P>u{m8hJ8eh|�F�w볟e�}��Ɓ~���xo����}�:r�����G|�Q �;=+����o�Fţ�V��>ކo{�6��7���84~<��FP�S��W�~�Uߚ@�>�fN�J�2T�|�L #"�!!9
|
2
|
+
����ǯ�\����5'H���IH�t����R����0E�nʐ��m��B9�.�c YU�rF�<�a�G����M,�Lլ��#�b�����誑�3�x�)�5Y�X6)�`�"4���U���c$����]1�X�_P5��z��1*Ş��5�j0�b�֘%[��+4/��6Z�={@)�sϯ��7�vߔ�>Ȋ��?)B�'��<�@4t|�QĚYj��H��h�,���oA2���T�E+�L�����M
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
x��MO�0�=�S4p��4��#=y7ff�`��ћ�K�R_��| $��_���_�����=5�����i���3s��H��w̡Pj�F
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,4 @@
|
|
1
|
+
x���n�@�Y�)�G�3�!�TU��6���d,,�Id��5"m�(�(mP�R���"�"RKC����o�oX���|�sY��=�ؼ'�UD4�5S�F���c�B4�,�s�4�K�R��
|
2
|
+
w�1�V������k9�k֦K��!�;�b�r���@�W5BL4���j�c[�#RV�2BJ��k ��%k��Y�
|
3
|
+
��z�U��0��F�O���r0I�fЍ�3����^��^2��ӡ�<P�s���r�_�To,o��a?[���dv$Ͼ��%v�{����^y2�����U=a۹O^��r�����h�Bg�^Ĺo����>�����"9�s:��Zq{����Z+n-�~�j��z�����˧Ys{}����:����WOe�Y��QO�r�
|
4
|
+
>�_�f/����`y������i���
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
x��Mj�0��u�Y��F�~lB�U��7��A��}���}��W�e�;9O��TNJ3��Y;B\J�Gr�r��h���q�7dH���p�]�z����%I�ٔ���F����ov�"��E��
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
.git/refs/heads/iyue
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
b2a941b669991d7e0f9bdc35f1014897a933f4e2
|
.git/refs/remotes/gitlab/iyue
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
b2a941b669991d7e0f9bdc35f1014897a933f4e2
|
.git/refs/remotes/origin/iyue
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
b2a941b669991d7e0f9bdc35f1014897a933f4e2
|
README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
🔧 **从JADX反编译的Java源码自动重构Protobuf .proto文件**
|
4
4
|
|
5
|
-
一个强大的逆向工程工具,能够从任何使用Google Protobuf Lite的Android应用中自动重构出完整的.proto
|
5
|
+
一个强大的逆向工程工具,能够从任何使用Google Protobuf Lite的Android应用中自动重构出完整的.proto文件结构。
|
6
6
|
|
7
7
|
## ✨ 特性
|
8
8
|
|
@@ -12,91 +12,101 @@
|
|
12
12
|
- 🌐 **通用性**: 适用于任何Android应用,无需硬编码映射
|
13
13
|
- 🧠 **智能推断**: 从Java源码直接读取类型信息,确保高准确性
|
14
14
|
- 📝 **标准输出**: 严格遵循Google Proto Style Guide
|
15
|
-
- 🚀 **高性能**: 文件缓存系统 + 智能路径构造,执行速度提升20%+
|
16
|
-
- 🛠️ **特殊类型支持**: MapFieldLite、Internal.ProtobufList、Google Well-Known Types
|
17
15
|
|
18
16
|
## 🛠️ 安装
|
19
17
|
|
18
|
+
### 方式一:拉取代码
|
20
19
|
```bash
|
21
20
|
# 克隆项目
|
22
|
-
git clone
|
21
|
+
git clone <repository_url>
|
23
22
|
cd reproto
|
24
23
|
|
25
24
|
# 安装依赖
|
26
25
|
pip install -r requirements.txt
|
27
26
|
```
|
28
27
|
|
29
|
-
|
28
|
+
### 方式二:pip安装
|
29
|
+
```bash
|
30
|
+
# 从本地构建安装
|
31
|
+
pip install .
|
32
|
+
|
33
|
+
# 在线安装
|
34
|
+
pip install reproto
|
35
|
+
```
|
30
36
|
|
31
|
-
|
37
|
+
## 📖 使用
|
38
|
+
|
39
|
+
### 命令行使用
|
32
40
|
```bash
|
33
|
-
python main.py
|
41
|
+
# 基本用法 python main.py or 命令 reproto
|
42
|
+
reproto <java_sources_dir> <root_class> <output_dir> [--verbose]
|
43
|
+
|
44
|
+
# 示例:重构普通类
|
45
|
+
reproto ./out_jadx/sources com.example.messaging.v1.models.MessageData ./protos_generated
|
46
|
+
|
47
|
+
# 示例:重构内部类(注意:包含$的类名需要用单引号包裹)
|
48
|
+
reproto ./out_jadx/sources 'com.example.account.v1.Models$Onboarded' ./output
|
49
|
+
|
50
|
+
# 详细输出
|
51
|
+
reproto ./out_jadx/sources com.example.Model ./output --verbose
|
52
|
+
```
|
53
|
+
|
54
|
+
### 代码使用
|
55
|
+
```python
|
56
|
+
# 作为包使用
|
57
|
+
from core import ProtoReconstructor
|
58
|
+
from utils.logger import setup_logger
|
59
|
+
from pathlib import Path
|
60
|
+
|
61
|
+
# 初始化
|
62
|
+
setup_logger("./logs")
|
63
|
+
sources_dir = Path("./out_jadx/sources")
|
64
|
+
output_dir = Path("./protos_generated")
|
65
|
+
|
66
|
+
# 创建重构器并执行
|
67
|
+
reconstructor = ProtoReconstructor(sources_dir, output_dir)
|
68
|
+
results = reconstructor.reconstruct_from_root("com.example.Model")
|
69
|
+
|
70
|
+
# 查看结果
|
71
|
+
for class_name, definition in results.items():
|
72
|
+
print(f"生成: {class_name} -> {definition.proto_filename}")
|
34
73
|
```
|
35
74
|
|
36
75
|
### 参数说明
|
37
76
|
- `java_sources_dir`: JADX反编译的Java源码目录路径
|
38
|
-
- `root_class`:
|
77
|
+
- `root_class`: 要重构的根类完整类名
|
39
78
|
- `output_dir`: 生成的proto文件输出目录路径
|
40
79
|
- `--verbose`: 显示详细处理信息
|
41
80
|
|
42
|
-
|
43
|
-
```bash
|
44
|
-
# 重构消息应用的数据模型
|
45
|
-
python main.py ./out_jadx/sources com.example.messaging.v1.models.MessageData ./protos_generated --verbose
|
81
|
+
## ⚠️ 注意事项
|
46
82
|
|
47
|
-
|
48
|
-
|
83
|
+
### 重要提醒
|
84
|
+
- **内部类命名**: 包含`$`符号的类名(如内部类)必须用**单引号包裹**
|
85
|
+
```bash
|
86
|
+
# ✅ 正确
|
87
|
+
reproto ./sources 'com.example.Outer$Inner' ./output
|
88
|
+
|
89
|
+
# ❌ 错误
|
90
|
+
reproto ./sources com.example.Outer$Inner ./output
|
91
|
+
```
|
49
92
|
|
50
|
-
|
51
|
-
|
52
|
-
```
|
93
|
+
### 使用建议
|
94
|
+
1. **JADX反编译**: 先使用JADX反编译APK文件
|
95
|
+
```bash
|
96
|
+
jadx -d out_jadx app.apk
|
97
|
+
```
|
53
98
|
|
54
|
-
|
99
|
+
2. **类名查找**: 在JADX GUI中找到目标Protobuf类的完整类名
|
55
100
|
|
56
|
-
|
57
|
-
1. **字节码解析**: 逆向工程Google Protobuf Lite的`newMessageInfo`调用
|
58
|
-
2. **依赖发现**: 递归分析Java文件中的类型引用
|
59
|
-
3. **智能推断**: 基于字段名和对象数组推断枚举和消息类型
|
60
|
-
4. **源码分析**: 直接从Java源码读取真实的字段类型声明
|
61
|
-
5. **🆕 性能优化**: 文件缓存系统 + 直接路径构造,避免全目录扫描
|
101
|
+
3. **输出目录**: 确保输出目录有写入权限
|
62
102
|
|
63
|
-
|
64
|
-
```
|
65
|
-
Java源码 → 字节码提取 → 类型解码 → 依赖发现 → 源码验证 → Proto生成
|
66
|
-
↓
|
67
|
-
🚀 性能优化: 文件缓存 + 智能路径构造 + 统一类型检测
|
68
|
-
```
|
69
|
-
|
70
|
-
## 📁 项目结构
|
71
|
-
|
72
|
-
```
|
73
|
-
reproto/
|
74
|
-
├── main.py # 主程序入口
|
75
|
-
├── core/ # 核心组件
|
76
|
-
│ ├── reconstructor.py # 主协调器 (已优化)
|
77
|
-
│ ├── info_decoder.py # 字节码解码器
|
78
|
-
│ └── bytecode_parser.py # 字节码解析工具
|
79
|
-
├── parsing/ # 解析模块
|
80
|
-
│ ├── java_parser.py # Java文件解析器
|
81
|
-
│ ├── enum_parser.py # 枚举解析器 (🆕)
|
82
|
-
│ └── java_source_analyzer.py # Java源码分析器 (已优化)
|
83
|
-
├── generation/ # 生成模块
|
84
|
-
│ └── proto_generator.py # Proto文件生成器
|
85
|
-
├── models/ # 数据模型
|
86
|
-
│ └── message_definition.py # 消息和枚举定义
|
87
|
-
├── utils/ # 工具函数 (大幅扩展)
|
88
|
-
│ ├── logger.py # 日志系统
|
89
|
-
│ ├── file_utils.py # 文件工具
|
90
|
-
│ ├── file_cache.py # 文件缓存系统 (🆕)
|
91
|
-
│ └── type_utils.py # 类型处理工具 (🆕)
|
92
|
-
└── logs/ # 日志文件目录
|
93
|
-
```
|
103
|
+
4. **日志查看**: 使用`--verbose`参数查看详细处理过程
|
94
104
|
|
95
105
|
## 📊 输出示例
|
96
106
|
|
97
107
|
### 输入:Java源码
|
98
108
|
```java
|
99
|
-
public final class
|
109
|
+
public final class SearchResult extends GeneratedMessageLite {
|
100
110
|
private MapFieldLite<String, Contact> contacts_;
|
101
111
|
private Internal.ProtobufList<String> phoneNumbers_;
|
102
112
|
|
@@ -109,90 +119,57 @@ public final class BulkSearchResult extends GeneratedMessageLite {
|
|
109
119
|
```protobuf
|
110
120
|
syntax = "proto3";
|
111
121
|
|
112
|
-
package com.
|
122
|
+
package com.example.search.v1.models;
|
113
123
|
|
114
|
-
option java_package = "com.
|
124
|
+
option java_package = "com.example.search.v1.models";
|
115
125
|
option java_multiple_files = true;
|
116
126
|
|
117
|
-
message
|
127
|
+
message SearchResult {
|
118
128
|
map<string, Contact> contacts = 1;
|
119
129
|
repeated string phone_numbers = 2;
|
120
130
|
}
|
121
131
|
```
|
122
132
|
|
123
|
-
##
|
124
|
-
|
125
|
-
### 🆕 重大性能提升
|
126
|
-
- **总执行时间**: 从~81秒优化到~65秒,提升 **19.8%**
|
127
|
-
- **基础类型检测**: 从2-3秒延迟优化为 **瞬间响应**,提升 **99%+**
|
128
|
-
- **索引系统**: 移除未使用的索引系统,节省 **100%** 构建开销
|
129
|
-
- **文件I/O**: 智能缓存系统,避免重复读取
|
130
|
-
|
131
|
-
### 🔧 技术优化
|
132
|
-
1. **文件缓存系统**: 线程安全的文件内容缓存,避免重复I/O
|
133
|
-
2. **直接路径构造**: 根据包名直接构造文件路径,避免全目录扫描
|
134
|
-
3. **统一类型检测**: 使用`TypeMapper`统一处理所有类型转换
|
135
|
-
4. **智能包名推断**: 基于包结构的智能类名解析
|
133
|
+
## 🛠️ 支持的特性
|
136
134
|
|
137
|
-
###
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
135
|
+
### Protobuf类型支持
|
136
|
+
- ✅ 基础类型:`string`, `int32`, `int64`, `bool`, `float`, `double`
|
137
|
+
- ✅ 消息类型:嵌套消息和引用消息
|
138
|
+
- ✅ 枚举类型:完整的枚举值解析
|
139
|
+
- ✅ 重复字段:`repeated` 类型
|
140
|
+
- ✅ 映射字段:`map<key, value>` 类型
|
141
|
+
- ✅ Oneof字段:互斥字段组
|
142
|
+
- ✅ Google Well-Known Types
|
145
143
|
|
146
|
-
|
144
|
+
### 特殊Java类型
|
145
|
+
- `MapFieldLite<K, V>` → `map<K, V>`
|
146
|
+
- `Internal.ProtobufList<T>` → `repeated T`
|
147
|
+
- `Internal.IntList` → `repeated enum` (枚举列表)
|
147
148
|
|
148
|
-
|
149
|
-
```java
|
150
|
-
// Java源码
|
151
|
-
private MapFieldLite<String, Contact> contacts_;
|
149
|
+
## 📁 项目结构
|
152
150
|
|
153
|
-
// 生成的Proto
|
154
|
-
map<string, Contact> contacts = 1;
|
155
151
|
```
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
152
|
+
reproto/
|
153
|
+
├── main.py # 主程序入口
|
154
|
+
├── core/ # 核心组件
|
155
|
+
│ ├── reconstructor.py # 主协调器
|
156
|
+
│ └── info_decoder.py # 字节码解码器
|
157
|
+
├── parsing/ # 解析模块
|
158
|
+
│ ├── java_parser.py # Java文件解析器
|
159
|
+
│ └── enum_parser.py # 枚举解析器
|
160
|
+
├── generation/ # 生成模块
|
161
|
+
│ └── proto_generator.py # Proto文件生成器
|
162
|
+
├── models/ # 数据模型
|
163
|
+
│ └── message_definition.py # 消息和枚举定义
|
164
|
+
├── utils/ # 工具函数
|
165
|
+
│ ├── logger.py # 日志系统
|
166
|
+
│ ├── file_cache.py # 文件缓存系统
|
167
|
+
│ ├── type_utils.py # 类型处理工具
|
168
|
+
│ └── report_utils.py # 结果统计工具
|
169
|
+
└── include/ # Google Protobuf标准文件
|
170
|
+
└── google/protobuf/ # Well-Known Types
|
164
171
|
```
|
165
172
|
|
166
|
-
### Google Well-Known Types
|
167
|
-
- `google.protobuf.Any`
|
168
|
-
- `google.protobuf.Timestamp`
|
169
|
-
- `google.protobuf.Duration`
|
170
|
-
- `google.protobuf.StringValue`
|
171
|
-
- 等等...
|
172
|
-
|
173
|
-
## 🚀 工作流程
|
174
|
-
|
175
|
-
1. 使用JADX反编译Android应用:`jadx -d out_jadx app.apk`
|
176
|
-
2. 运行ReProto指定根Protobuf类
|
177
|
-
3. 自动解析所有相关类和依赖
|
178
|
-
4. 🆕 智能缓存和路径优化,快速处理
|
179
|
-
5. 生成完整的.proto文件结构
|
180
|
-
|
181
|
-
## 📝 配置选项
|
182
|
-
|
183
|
-
### 日志配置
|
184
|
-
- 日志文件自动保存到 `./logs/` 目录
|
185
|
-
- 文件格式: `reproto-YYYY-MM-DD-HH-MM-SS.log`
|
186
|
-
- 使用 `--verbose` 参数查看详细处理过程
|
187
|
-
- 🆕 性能统计和缓存监控信息
|
188
|
-
|
189
|
-
### 输出格式
|
190
|
-
生成的proto文件遵循Google Protobuf Style Guide:
|
191
|
-
- 文件名:`snake_case.proto`
|
192
|
-
- 字段名:`snake_case`
|
193
|
-
- 消息名:`PascalCase`
|
194
|
-
- 枚举值:`UPPER_SNAKE_CASE`
|
195
|
-
|
196
173
|
## 🔧 开发
|
197
174
|
|
198
175
|
```bash
|
@@ -201,72 +178,9 @@ poetry install
|
|
201
178
|
poetry shell
|
202
179
|
|
203
180
|
# 运行测试
|
204
|
-
|
205
|
-
|
206
|
-
# 性能测试
|
207
|
-
time python main.py ../out_jadx/sources com.truecaller.search.v1.models.SearchResult ../test_output
|
181
|
+
reproto ../out_jadx/sources com.example.TestClass ../test_output --verbose
|
208
182
|
```
|
209
183
|
|
210
|
-
## 🐛 故障排除
|
211
|
-
|
212
|
-
### 常见问题
|
213
|
-
|
214
|
-
1. **文件找不到错误**
|
215
|
-
```bash
|
216
|
-
# 确保JADX输出目录正确
|
217
|
-
ls -la out_jadx/sources/com/example/
|
218
|
-
```
|
219
|
-
|
220
|
-
2. **内存不足**
|
221
|
-
```bash
|
222
|
-
# 对于大型应用,增加Java堆内存
|
223
|
-
export JAVA_OPTS="-Xmx4g"
|
224
|
-
```
|
225
|
-
|
226
|
-
3. **性能问题**
|
227
|
-
```bash
|
228
|
-
# 查看缓存统计,确认没有重复I/O
|
229
|
-
grep "缓存统计" logs/reproto-*.log
|
230
|
-
```
|
231
|
-
|
232
|
-
## 📊 支持的Protobuf特性
|
233
|
-
|
234
|
-
| 特性 | 支持状态 | 示例 |
|
235
|
-
|------|----------|------|
|
236
|
-
| 基础类型 | ✅ 完整支持 | `string`, `int32`, `bool` |
|
237
|
-
| 消息类型 | ✅ 完整支持 | `Contact`, `UserInfo` |
|
238
|
-
| 枚举类型 | ✅ 完整支持 | `enum Status { ACTIVE = 0; }` |
|
239
|
-
| repeated | ✅ 完整支持 | `repeated string tags` |
|
240
|
-
| map | ✅ 完整支持 | `map<string, Contact> contacts` |
|
241
|
-
| oneof | ✅ 完整支持 | `oneof data { ... }` |
|
242
|
-
| 嵌套消息 | ✅ 完整支持 | `message Outer.Inner` |
|
243
|
-
| Well-Known Types | ✅ 新增支持 | `google.protobuf.Timestamp` |
|
244
|
-
|
245
|
-
## 🎯 最新更新 (v2.0)
|
246
|
-
|
247
|
-
### 🚀 性能优化
|
248
|
-
- 移除未使用的索引系统,提升执行效率20%+
|
249
|
-
- 文件缓存系统,避免重复I/O操作
|
250
|
-
- 智能路径构造,避免全目录扫描
|
251
|
-
- 统一类型检测器,简化代码逻辑
|
252
|
-
|
253
|
-
### 🆕 新增功能
|
254
|
-
- MapFieldLite自动转换为标准map语法
|
255
|
-
- Internal.ProtobufList支持
|
256
|
-
- Google Protobuf Well-Known Types支持
|
257
|
-
- 增强的枚举解析器
|
258
|
-
- 详细的性能监控和统计
|
259
|
-
|
260
|
-
### 🔧 技术改进
|
261
|
-
- 代码复杂度显著降低
|
262
|
-
- 内存使用优化
|
263
|
-
- 错误处理增强
|
264
|
-
- 日志系统改进
|
265
|
-
|
266
|
-
## 📄 许可证
|
267
|
-
|
268
|
-
本项目为私有项目,仅供授权用户使用。
|
269
|
-
|
270
184
|
---
|
271
185
|
|
272
|
-
|
186
|
+
**🚀 立即开始重构你的Protobuf文件!**
|
core/__init__.py
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
"""
|
2
|
+
核心处理模块
|
3
|
+
|
4
|
+
包含Protobuf重构的核心逻辑:
|
5
|
+
- 信息解码器:解码Google Protobuf Lite的字节码
|
6
|
+
- 重构器:管理整个重构过程和依赖发现
|
7
|
+
"""
|
8
|
+
|
9
|
+
# 智能导入:同时支持相对导入(包环境)和绝对导入(开发环境)
|
10
|
+
try:
|
11
|
+
# 相对导入(包环境)
|
12
|
+
from .info_decoder import InfoDecoder
|
13
|
+
from .reconstructor import ProtoReconstructor, JavaSourceAnalyzer
|
14
|
+
except ImportError:
|
15
|
+
# 绝对导入(开发环境)
|
16
|
+
from core.info_decoder import InfoDecoder
|
17
|
+
from core.reconstructor import ProtoReconstructor, JavaSourceAnalyzer
|
18
|
+
|
19
|
+
__all__ = [
|
20
|
+
'InfoDecoder',
|
21
|
+
'ProtoReconstructor',
|
22
|
+
'JavaSourceAnalyzer'
|
23
|
+
]
|
1
24
|
|
2
25
|
|
3
26
|
|