extrospect 0.1.0__tar.gz

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.
Files changed (141) hide show
  1. extrospect-0.1.0/.gitignore +60 -0
  2. extrospect-0.1.0/CHANGELOG.md +39 -0
  3. extrospect-0.1.0/LICENSE +202 -0
  4. extrospect-0.1.0/NOTICE +4 -0
  5. extrospect-0.1.0/PKG-INFO +244 -0
  6. extrospect-0.1.0/README.md +187 -0
  7. extrospect-0.1.0/README.zh-CN.md +165 -0
  8. extrospect-0.1.0/SECURITY.md +30 -0
  9. extrospect-0.1.0/docs/architecture.md +88 -0
  10. extrospect-0.1.0/docs/eval_real_world.md +100 -0
  11. extrospect-0.1.0/docs/eval_results.md +16 -0
  12. extrospect-0.1.0/docs/i18n.md +30 -0
  13. extrospect-0.1.0/docs/mcp.md +113 -0
  14. extrospect-0.1.0/docs/scoring.md +85 -0
  15. extrospect-0.1.0/docs/zh-CN/architecture.md +80 -0
  16. extrospect-0.1.0/docs/zh-CN/eval_real_world.md +79 -0
  17. extrospect-0.1.0/docs/zh-CN/i18n.md +25 -0
  18. extrospect-0.1.0/docs/zh-CN/mcp.md +102 -0
  19. extrospect-0.1.0/docs/zh-CN/scoring.md +72 -0
  20. extrospect-0.1.0/eval/ablations.yaml +39 -0
  21. extrospect-0.1.0/eval/datasets/fixtures.jsonl +8 -0
  22. extrospect-0.1.0/eval/datasets/seed.jsonl +211 -0
  23. extrospect-0.1.0/eval/fetch_samples.py +123 -0
  24. extrospect-0.1.0/eval/make_injection_variants.py +118 -0
  25. extrospect-0.1.0/eval/retrieval.py +126 -0
  26. extrospect-0.1.0/eval/run_eval.py +182 -0
  27. extrospect-0.1.0/eval/run_host_eval.py +373 -0
  28. extrospect-0.1.0/eval/train_gbm.py +74 -0
  29. extrospect-0.1.0/pyproject.toml +128 -0
  30. extrospect-0.1.0/src/extrospect/__init__.py +3 -0
  31. extrospect-0.1.0/src/extrospect/__main__.py +3 -0
  32. extrospect-0.1.0/src/extrospect/acquire/__init__.py +1 -0
  33. extrospect-0.1.0/src/extrospect/acquire/crx_download.py +88 -0
  34. extrospect-0.1.0/src/extrospect/acquire/local_profile.py +285 -0
  35. extrospect-0.1.0/src/extrospect/acquire/unpack.py +199 -0
  36. extrospect-0.1.0/src/extrospect/baseline/__init__.py +1 -0
  37. extrospect-0.1.0/src/extrospect/baseline/gbm.py +138 -0
  38. extrospect-0.1.0/src/extrospect/baseline/rules.py +103 -0
  39. extrospect-0.1.0/src/extrospect/cache.py +216 -0
  40. extrospect-0.1.0/src/extrospect/cli.py +873 -0
  41. extrospect-0.1.0/src/extrospect/config.py +387 -0
  42. extrospect-0.1.0/src/extrospect/data/__init__.py +1 -0
  43. extrospect-0.1.0/src/extrospect/data/advisories_builtin.json +287 -0
  44. extrospect-0.1.0/src/extrospect/data/intel_builtin.jsonl +25 -0
  45. extrospect-0.1.0/src/extrospect/data/lib_hashes.json +3 -0
  46. extrospect-0.1.0/src/extrospect/evaluation.py +386 -0
  47. extrospect-0.1.0/src/extrospect/fuse.py +140 -0
  48. extrospect-0.1.0/src/extrospect/http.py +98 -0
  49. extrospect-0.1.0/src/extrospect/i18n/__init__.py +266 -0
  50. extrospect-0.1.0/src/extrospect/i18n/locales/en.json +374 -0
  51. extrospect-0.1.0/src/extrospect/i18n/locales/zh-CN.json +374 -0
  52. extrospect-0.1.0/src/extrospect/knowledge/__init__.py +1 -0
  53. extrospect-0.1.0/src/extrospect/knowledge/advisory.py +149 -0
  54. extrospect-0.1.0/src/extrospect/knowledge/domains.py +110 -0
  55. extrospect-0.1.0/src/extrospect/knowledge/embeddings.py +128 -0
  56. extrospect-0.1.0/src/extrospect/knowledge/intel.py +156 -0
  57. extrospect-0.1.0/src/extrospect/knowledge/listing.py +264 -0
  58. extrospect-0.1.0/src/extrospect/knowledge/store.py +282 -0
  59. extrospect-0.1.0/src/extrospect/llm/__init__.py +2 -0
  60. extrospect-0.1.0/src/extrospect/llm/client.py +437 -0
  61. extrospect-0.1.0/src/extrospect/llm/engine.py +233 -0
  62. extrospect-0.1.0/src/extrospect/llm/fake.py +261 -0
  63. extrospect-0.1.0/src/extrospect/llm/investigator.py +231 -0
  64. extrospect-0.1.0/src/extrospect/llm/prompts/__init__.py +44 -0
  65. extrospect-0.1.0/src/extrospect/llm/prompts/host_audit_v1.md +16 -0
  66. extrospect-0.1.0/src/extrospect/llm/prompts/investigator_v1.md +24 -0
  67. extrospect-0.1.0/src/extrospect/llm/prompts/listing_extract_v1.md +8 -0
  68. extrospect-0.1.0/src/extrospect/llm/prompts/triage_v1.md +24 -0
  69. extrospect-0.1.0/src/extrospect/llm/prompts/verifier_v1.md +7 -0
  70. extrospect-0.1.0/src/extrospect/llm/router.py +170 -0
  71. extrospect-0.1.0/src/extrospect/llm/sanitize.py +322 -0
  72. extrospect-0.1.0/src/extrospect/llm/tools.py +646 -0
  73. extrospect-0.1.0/src/extrospect/llm/triage.py +326 -0
  74. extrospect-0.1.0/src/extrospect/llm/verifier.py +228 -0
  75. extrospect-0.1.0/src/extrospect/models.py +497 -0
  76. extrospect-0.1.0/src/extrospect/pipeline.py +375 -0
  77. extrospect-0.1.0/src/extrospect/report.py +736 -0
  78. extrospect-0.1.0/src/extrospect/static/__init__.py +1 -0
  79. extrospect-0.1.0/src/extrospect/static/analyzer.py +221 -0
  80. extrospect-0.1.0/src/extrospect/static/csp.py +114 -0
  81. extrospect-0.1.0/src/extrospect/static/deobfuscate.py +177 -0
  82. extrospect-0.1.0/src/extrospect/static/features.py +239 -0
  83. extrospect-0.1.0/src/extrospect/static/jsparse.py +471 -0
  84. extrospect-0.1.0/src/extrospect/static/libstrip.py +132 -0
  85. extrospect-0.1.0/src/extrospect/static/manifest.py +457 -0
  86. extrospect-0.1.0/src/extrospect/static/nodetools.py +61 -0
  87. extrospect-0.1.0/src/extrospect/static/permissions.py +402 -0
  88. extrospect-0.1.0/src/extrospect/static/sinks.py +1081 -0
  89. extrospect-0.1.0/src/extrospect/static/slicer.py +303 -0
  90. extrospect-0.1.0/src/extrospect/static/surface.py +398 -0
  91. extrospect-0.1.0/src/extrospect/static/vulns.py +416 -0
  92. extrospect-0.1.0/src/extrospect/trace.py +190 -0
  93. extrospect-0.1.0/src/extrospect/util.py +224 -0
  94. extrospect-0.1.0/src/extrospect/workspace.py +342 -0
  95. extrospect-0.1.0/src/extrospect_mcp/__init__.py +1 -0
  96. extrospect-0.1.0/src/extrospect_mcp/server.py +550 -0
  97. extrospect-0.1.0/tests/conftest.py +92 -0
  98. extrospect-0.1.0/tests/fixtures/extensions/benign_legacy_jquery/js/jquery-1.8.1.min.js +2 -0
  99. extrospect-0.1.0/tests/fixtures/extensions/benign_legacy_jquery/js/popup.js +7 -0
  100. extrospect-0.1.0/tests/fixtures/extensions/benign_legacy_jquery/manifest.json +8 -0
  101. extrospect-0.1.0/tests/fixtures/extensions/benign_legacy_jquery/popup.html +2 -0
  102. extrospect-0.1.0/tests/fixtures/extensions/benign_translator/bubble.css +1 -0
  103. extrospect-0.1.0/tests/fixtures/extensions/benign_translator/content.js +24 -0
  104. extrospect-0.1.0/tests/fixtures/extensions/benign_translator/logo.svg +1 -0
  105. extrospect-0.1.0/tests/fixtures/extensions/benign_translator/manifest.json +16 -0
  106. extrospect-0.1.0/tests/fixtures/extensions/benign_translator/service_worker.js +28 -0
  107. extrospect-0.1.0/tests/fixtures/extensions/benign_word_counter/_locales/en/messages.json +4 -0
  108. extrospect-0.1.0/tests/fixtures/extensions/benign_word_counter/_locales/zh_CN/messages.json +4 -0
  109. extrospect-0.1.0/tests/fixtures/extensions/benign_word_counter/background.js +3 -0
  110. extrospect-0.1.0/tests/fixtures/extensions/benign_word_counter/icon128.png +2 -0
  111. extrospect-0.1.0/tests/fixtures/extensions/benign_word_counter/manifest.json +11 -0
  112. extrospect-0.1.0/tests/fixtures/extensions/benign_word_counter/popup.css +1 -0
  113. extrospect-0.1.0/tests/fixtures/extensions/benign_word_counter/popup.html +9 -0
  114. extrospect-0.1.0/tests/fixtures/extensions/benign_word_counter/popup.js +20 -0
  115. extrospect-0.1.0/tests/fixtures/extensions/inj_prompt_injection/helper.js +24 -0
  116. extrospect-0.1.0/tests/fixtures/extensions/inj_prompt_injection/manifest.json +8 -0
  117. extrospect-0.1.0/tests/fixtures/extensions/mal_cookie_exfil/background.js +19 -0
  118. extrospect-0.1.0/tests/fixtures/extensions/mal_cookie_exfil/darkmode.css +1 -0
  119. extrospect-0.1.0/tests/fixtures/extensions/mal_cookie_exfil/darkmode.js +6 -0
  120. extrospect-0.1.0/tests/fixtures/extensions/mal_cookie_exfil/manifest.json +12 -0
  121. extrospect-0.1.0/tests/fixtures/extensions/mal_remote_config/bg.js +39 -0
  122. extrospect-0.1.0/tests/fixtures/extensions/mal_remote_config/manifest.json +11 -0
  123. extrospect-0.1.0/tests/fixtures/extensions/mal_remote_config/popup.html +1 -0
  124. extrospect-0.1.0/tests/fixtures/extensions/mal_remote_config/popup.js +3 -0
  125. extrospect-0.1.0/tests/fixtures/extensions/mal_search_hijack/links.js +13 -0
  126. extrospect-0.1.0/tests/fixtures/extensions/mal_search_hijack/manifest.json +24 -0
  127. extrospect-0.1.0/tests/fixtures/extensions/mal_search_hijack/newtab.html +2 -0
  128. extrospect-0.1.0/tests/fixtures/extensions/mal_search_hijack/newtab.js +1 -0
  129. extrospect-0.1.0/tests/fixtures/extensions/mal_search_hijack/rules/redirect.json +20 -0
  130. extrospect-0.1.0/tests/fixtures/extensions/mal_search_hijack/sw.js +18 -0
  131. extrospect-0.1.0/tests/fixtures/retire/jsrepository-mini.json +52 -0
  132. extrospect-0.1.0/tests/test_acquire.py +267 -0
  133. extrospect-0.1.0/tests/test_capability.py +126 -0
  134. extrospect-0.1.0/tests/test_evaluation.py +222 -0
  135. extrospect-0.1.0/tests/test_i18n.py +156 -0
  136. extrospect-0.1.0/tests/test_knowledge_mcp.py +510 -0
  137. extrospect-0.1.0/tests/test_llm_pipeline.py +568 -0
  138. extrospect-0.1.0/tests/test_manifest.py +97 -0
  139. extrospect-0.1.0/tests/test_pipeline_static.py +284 -0
  140. extrospect-0.1.0/tests/test_sinks_slices.py +260 -0
  141. extrospect-0.1.0/tests/test_vulns_fuse.py +195 -0
@@ -0,0 +1,60 @@
1
+ # ---------------------------------------------------------------------------
2
+ # Internal development docs — NEVER commit.
3
+ # Roadmaps, planning notes, progress logs and manual test checklists live in
4
+ # /internal/ and stay on the developer's machine only.
5
+ # ---------------------------------------------------------------------------
6
+ /internal/
7
+ *.internal.md
8
+ CLAUDE.md
9
+ CLAUDE.local.md
10
+ .claude/
11
+
12
+ # Python
13
+ __pycache__/
14
+ *.py[cod]
15
+ *.egg-info/
16
+ .eggs/
17
+ build/
18
+ dist/
19
+ .venv/
20
+ venv/
21
+ .python-eggs/
22
+ .mypy_cache/
23
+ .ruff_cache/
24
+ .pytest_cache/
25
+ .coverage
26
+ .coverage.*
27
+ htmlcov/
28
+ coverage.xml
29
+
30
+ # Node helpers (optional tooling installed per-project)
31
+ node_modules/
32
+ .tools/
33
+
34
+ # Evaluation artifacts: only dataset manifests are committed, never samples
35
+ eval/samples/
36
+ eval/runs/
37
+ # generated by eval/make_injection_variants.py (contains local paths)
38
+ eval/datasets/injection.jsonl
39
+ eval/.cache/
40
+ *.crx
41
+ !tests/fixtures/**/*.crx
42
+
43
+ # Local runtime data
44
+ .extrospect/
45
+ traces/
46
+ *.sqlite
47
+ *.sqlite3
48
+ *.db
49
+ *.lance/
50
+
51
+ # Editors / OS
52
+ .idea/
53
+ .vscode/
54
+ *.swp
55
+ .DS_Store
56
+ Thumbs.db
57
+
58
+ # Secrets
59
+ .env
60
+ .env.*
@@ -0,0 +1,39 @@
1
+ # Changelog / 更新日志
2
+
3
+ ## 0.1.0 - 2026-10-23 (alpha)
4
+
5
+ First public release. / 首次公开发布。
6
+
7
+ **English**
8
+
9
+ - Local risk analysis of Chromium-based browser extensions (Chrome, Edge, Brave, Chromium,
10
+ Vivaldi), or of a `.crx` / `.zip` / directory / Chrome Web Store id: CLI `extrospect`
11
+ and MCP server `extrospect-mcp`.
12
+ - Static pipeline (zero tokens): permission tiers and combinations, CSP, attack surface,
13
+ known-vulnerable libraries (retire.js + EPSS), bundle unpacking and deobfuscation,
14
+ tree-sitter sink detection, data-flow patterns, code slicing, prompt-injection detection.
15
+ - Host mode: the MCP client's model investigates with 13 tools, an `audit_my_extensions`
16
+ prompt and report resources; evidence quotes are verified and the score is computed
17
+ server-side.
18
+ - Engine mode (experimental, BYOK): layered LLM pipeline through litellm - triage,
19
+ investigator agent, verifier.
20
+ - Knowledge bases: store listings, malware-technique intel, security advisories.
21
+ - Results are labelled by what produced them: static-only scores are shown as attack
22
+ surface, verdicts that cannot be verified as "needs review".
23
+ - English and Simplified Chinese interface, reports and documentation.
24
+ - Evaluation harness, including Host-mode evaluation through Claude Code, and a first
25
+ real-world evaluation (`docs/eval_real_world.md`).
26
+
27
+ **中文**
28
+
29
+ - 在本机分析 Chromium 系浏览器(Chrome、Edge、Brave、Chromium、Vivaldi)里安装的扩展,也可以分析
30
+ `.crx` / `.zip` / 目录 / Chrome 商店 ID:命令行 `extrospect` 和 MCP server `extrospect-mcp`。
31
+ - 静态管线(零 token):权限分级与组合、CSP、攻击面、已知漏洞库(retire.js + EPSS)、拆包和解混淆、
32
+ 基于 tree-sitter 的 sink 检测、数据流模式、代码切片、提示注入检测。
33
+ - Host 模式:MCP 客户端的模型用 13 个工具、`audit_my_extensions` prompt 和报告资源做调查;证据引用的核对和
34
+ 分数计算都在服务器端完成。
35
+ - Engine 模式(实验性,BYOK):通过 litellm 的分层 LLM 管线——分诊、调查员 agent、核对器。
36
+ - 知识库:商店页面、恶意手法情报、安全公告。
37
+ - 结果按来源标注:只有静态分析时显示为攻击面,无法核实的结论显示为"需人工复核"。
38
+ - 英文和简体中文的界面、报告和文档。
39
+ - 评测框架,包括通过 Claude Code 做的 Host 模式评测,以及首轮真实环境评测(`docs/zh-CN/eval_real_world.md`)。
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,4 @@
1
+ Extrospect
2
+ Copyright 2026 johnnyzn
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
@@ -0,0 +1,244 @@
1
+ Metadata-Version: 2.5
2
+ Name: extrospect
3
+ Version: 0.1.0
4
+ Summary: Local browser-extension risk analysis engine with code evidence, exposed as a CLI and an MCP server.
5
+ Project-URL: Homepage, https://github.com/johnnyzn/Extrospect
6
+ Project-URL: Documentation, https://github.com/johnnyzn/Extrospect/tree/main/docs
7
+ Project-URL: Changelog, https://github.com/johnnyzn/Extrospect/blob/main/CHANGELOG.md
8
+ Project-URL: Issues, https://github.com/johnnyzn/Extrospect/issues
9
+ Author: johnnyzn
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ License-File: NOTICE
13
+ Keywords: browser-extension,chrome,llm,malware,mcp,security,static-analysis
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Environment :: Console
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Intended Audience :: Information Technology
18
+ Classifier: Natural Language :: Chinese (Simplified)
19
+ Classifier: Natural Language :: English
20
+ Classifier: Operating System :: OS Independent
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Topic :: Security
26
+ Requires-Python: >=3.11
27
+ Requires-Dist: httpx>=0.27
28
+ Requires-Dist: jsbeautifier>=1.15
29
+ Requires-Dist: mcp>=2.0
30
+ Requires-Dist: platformdirs>=4.2
31
+ Requires-Dist: pydantic>=2.7
32
+ Requires-Dist: regex>=2024.5.15
33
+ Requires-Dist: rich>=13.7
34
+ Requires-Dist: tldextract>=5.1
35
+ Requires-Dist: tree-sitter-javascript>=0.25
36
+ Requires-Dist: tree-sitter<0.26,>=0.25
37
+ Requires-Dist: typer>=0.12
38
+ Provides-Extra: all
39
+ Requires-Dist: lancedb>=0.13; extra == 'all'
40
+ Requires-Dist: lightgbm>=4.3; extra == 'all'
41
+ Requires-Dist: litellm>=1.60; extra == 'all'
42
+ Requires-Dist: numpy>=1.26; extra == 'all'
43
+ Requires-Dist: pyyaml>=6.0; extra == 'all'
44
+ Requires-Dist: scikit-learn>=1.4; extra == 'all'
45
+ Provides-Extra: eval
46
+ Requires-Dist: pyyaml>=6.0; extra == 'eval'
47
+ Provides-Extra: llm
48
+ Requires-Dist: litellm>=1.60; extra == 'llm'
49
+ Provides-Extra: ml
50
+ Requires-Dist: lightgbm>=4.3; extra == 'ml'
51
+ Requires-Dist: numpy>=1.26; extra == 'ml'
52
+ Requires-Dist: scikit-learn>=1.4; extra == 'ml'
53
+ Provides-Extra: rag
54
+ Requires-Dist: lancedb>=0.13; extra == 'rag'
55
+ Requires-Dist: numpy>=1.26; extra == 'rag'
56
+ Description-Content-Type: text/markdown
57
+
58
+ # Extrospect
59
+
60
+ **Local risk analysis for browser extensions, with code evidence.**
61
+ Ask your AI assistant *"are my browser extensions safe?"* and get an answer backed by
62
+ verified quotes from the extensions' source code.
63
+
64
+ [中文说明](https://github.com/johnnyzn/Extrospect/blob/main/README.zh-CN.md) ·
65
+ [Architecture](https://github.com/johnnyzn/Extrospect/blob/main/docs/architecture.md) ·
66
+ [Scoring](https://github.com/johnnyzn/Extrospect/blob/main/docs/scoring.md) ·
67
+ [MCP setup](https://github.com/johnnyzn/Extrospect/blob/main/docs/mcp.md) ·
68
+ [Languages](https://github.com/johnnyzn/Extrospect/blob/main/docs/i18n.md) ·
69
+ [Evaluation](https://github.com/johnnyzn/Extrospect/blob/main/docs/eval_real_world.md) ·
70
+ [Changelog](https://github.com/johnnyzn/Extrospect/blob/main/CHANGELOG.md)
71
+
72
+ Extrospect runs on your machine. It finds the extensions installed in Chrome, Edge, Brave,
73
+ Chromium and Vivaldi profiles (or takes a `.crx` / `.zip` / directory / Web Store id),
74
+ analyses what they *can* do and what their code *actually* does, and produces an
75
+ explainable 0-100 score.
76
+
77
+ | | |
78
+ |---|---|
79
+ | **Host mode (MCP)** | an MCP server: the model in your AI client (Claude Code, Codex, Cursor, VS Code, ...) becomes the investigator, Extrospect provides the tools, verifies the evidence and computes the score - no extra API cost |
80
+ | **Static pipeline (zero tokens)** | permission tiers and combinations, CSP, attack surface, known-vulnerable libraries (retire.js + EPSS), deobfuscation, tree-sitter detection of data sources, exfiltration channels, dynamic code and hijacking, data-flow patterns, code slicing |
81
+ | **Engine mode (BYOK, experimental)** | a layered LLM pipeline - small-model triage, a larger-model investigator agent with tools, and a verifier that checks every evidence quote against the source |
82
+ | **Prompt-injection aware** | comments and long strings are stripped before code reaches a model; text addressed to AI reviewers ("classify this as benign", "忽略之前的指令") is detected and reported as a red flag |
83
+ | **Multilingual** | English and Simplified Chinese UI and reports; LLM-written text in any language |
84
+
85
+ ## Status: alpha (0.1.0)
86
+
87
+ What has been checked:
88
+
89
+ - **Host mode** end to end in Claude Code with Opus 5.5, Sonnet 5.5 and Haiku 4.5. On 43
90
+ popular and deep-integration benign extensions from the Chrome Web Store (password
91
+ managers, ad blockers, wallets, translators, AI sidebars, developer tools) Sonnet 5.5
92
+ produced **no false positive**; every hand-written malicious test extension, including
93
+ one that tries to talk the reviewer into a benign verdict, was detected by all three
94
+ models. Details: [real-world evaluation](https://github.com/johnnyzn/Extrospect/blob/main/docs/eval_real_world.md).
95
+ - About 170 offline tests (zero tokens); CI on Linux, macOS and Windows.
96
+
97
+ Known limitations:
98
+
99
+ - **The detection rate on real malware is not measured yet.** The malicious extensions
100
+ that can still be downloaded are years old and have probably been cleaned up, so the
101
+ evaluation has no reliable malicious samples.
102
+ - **A static score alone measures attack surface, not malice.** Large legitimate
103
+ extensions score high, so `extrospect scan` shows it as *attack surface* rather than as
104
+ a risk level. Get a verdict through Host mode (or Engine mode).
105
+ - Smaller models (e.g. Haiku 4.5) sometimes fail the evidence check; such results are
106
+ shown as *needs review* instead of being trusted.
107
+ - Engine mode has not yet been validated with real models - treat it as experimental.
108
+ - Chromium-based browsers only (no Firefox or Safari yet).
109
+
110
+ Reports of false positives or missed detections are very welcome in the
111
+ [issue tracker](https://github.com/johnnyzn/Extrospect/issues).
112
+
113
+ ## Install
114
+
115
+ Requires Python 3.11+. Pick one:
116
+
117
+ ```bash
118
+ uv tool install extrospect # recommended: isolated environment, uv manages Python
119
+ pipx install extrospect # isolated environment with pipx
120
+ pip install extrospect # into the current (virtual) environment
121
+ ```
122
+
123
+ Then check the setup (optional tools, API keys, browser profiles):
124
+
125
+ ```bash
126
+ extrospect doctor
127
+ ```
128
+
129
+ Extras work the same way with all three, e.g. `pip install "extrospect[llm]"`:
130
+ `llm` (Engine mode), `rag` (LanceDB vector store), `all`. Optional Node.js helpers are
131
+ used automatically when present:
132
+ `npm i -g webcrack prettier retire` (bundle unpacking/deobfuscation, formatting, the
133
+ official retire.js scanner); without them Extrospect falls back to built-in equivalents.
134
+
135
+ From source:
136
+
137
+ ```bash
138
+ git clone https://github.com/johnnyzn/Extrospect && cd Extrospect
139
+ uv sync --all-extras
140
+ uv run extrospect doctor # prefix the commands below with `uv run`
141
+ ```
142
+
143
+ ## Use it from your AI assistant (MCP)
144
+
145
+ ```bash
146
+ claude mcp add extrospect -- uvx --from extrospect extrospect-mcp
147
+ ```
148
+
149
+ Installed with `pip` or `pipx` instead of uv? Use the installed command:
150
+ `claude mcp add extrospect -- extrospect-mcp` (inside a virtual environment, give its
151
+ full path, e.g. `.venv/bin/extrospect-mcp`).
152
+
153
+ Then ask *"Check my browser extensions"* or run the `/mcp__extrospect__audit_my_extensions`
154
+ prompt. It works with any MCP client that can start local servers - Claude Code, Claude
155
+ Desktop, Codex (CLI, IDE, the Codex tab of the ChatGPT desktop app), Cursor, VS Code,
156
+ Windsurf, Gemini CLI - but not with ChatGPT's chat, which only connects to remote servers.
157
+ Setup for each client, tools and the security model:
158
+ [docs/mcp.md](https://github.com/johnnyzn/Extrospect/blob/main/docs/mcp.md).
159
+ So far it has been evaluated with Claude models; a capable model (Sonnet or Opus class)
160
+ is recommended.
161
+
162
+ ## Command line
163
+
164
+ ```bash
165
+ # Every installed extension, ranked by static score (attack surface; no LLM, no cost)
166
+ extrospect scan --local
167
+
168
+ # One extension: a directory, a .crx/.zip, or a Web Store id (downloads the current version)
169
+ extrospect scan path/to/extension
170
+ extrospect scan --id aapbdbdomjkkjkaonfhkkikfgjllcleb -f html -o report.html
171
+
172
+ # Engine mode (experimental): full LLM analysis with your own API key
173
+ export ANTHROPIC_API_KEY=...
174
+ extrospect analyze <id-or-path> --max-cost 0.30
175
+ extrospect trace show <trace-id> # replay the agent's trajectory
176
+
177
+ # Reports in Chinese
178
+ extrospect --lang zh-CN scan --local
179
+ ```
180
+
181
+ Other commands: `list`, `report`, `history`, `download`, `config init|show|path`,
182
+ `cache stats|clear`, `knowledge build-intel|build-advisories|listing|stats`, `languages`,
183
+ `version`.
184
+
185
+ ## How a score is computed
186
+
187
+ ```
188
+ A capability what permissions + manifest allow (tiers, combinations, CSP)
189
+ Ev vulnerability max over CVEs of EPSS percentile x reachability weight
190
+ Em malicious evidence verified LLM verdict / GBM / rule baseline
191
+ E = 1 - (1 - Ev)(1 - Em)
192
+ Risk = 100 x A^0.5 x E^0.7 (+ hard rules) -> benign / low / medium / high / critical
193
+ ```
194
+
195
+ The LLM never sets the score: it produces a verdict and evidence, the Verifier drops
196
+ evidence whose quote is not in the file, and the formula does the rest. Every report
197
+ shows the breakdown. Without a model verdict the score is shown as **attack surface**,
198
+ not as a risk level, and a verdict that cannot be verified is shown as **needs review**.
199
+ Details: [docs/scoring.md](https://github.com/johnnyzn/Extrospect/blob/main/docs/scoring.md).
200
+
201
+ ## Privacy
202
+
203
+ Extrospect never uploads your extension list or extension code. Network access is
204
+ limited to: downloading a CRX when you pass a Web Store id, the retire.js vulnerability
205
+ repository, EPSS scores (CVE ids only), GitHub advisories (CVE ids), store listing pages
206
+ (only for the extension being investigated) and RDAP domain lookups. `--offline` disables
207
+ all of it. In Host mode the code your AI client reads goes to that client's model
208
+ provider; in Engine mode the analysed code slices go to the LLM provider you configured.
209
+
210
+ ## Configuration
211
+
212
+ `extrospect config init` writes a commented `config.toml` with every default: models per
213
+ role (any [litellm](https://docs.litellm.ai/) model id, including local `ollama/...`),
214
+ budgets, router thresholds, score weights, tool paths and language. Environment
215
+ variables: `EXTROSPECT_LANG`, `EXTROSPECT_OFFLINE`, `EXTROSPECT_*_MODEL`,
216
+ `EXTROSPECT_DATA_DIR`, `EXTROSPECT_CACHE_DIR`, `EXTROSPECT_BROWSER_ROOTS`.
217
+
218
+ ## Evaluation
219
+
220
+ `eval/` contains the dataset manifests (ids and labels only, never samples), the ablation
221
+ configurations and the evaluation scripts:
222
+
223
+ ```bash
224
+ uv run python eval/fetch_samples.py --dataset eval/datasets/seed.jsonl
225
+ uv run python eval/run_eval.py --dataset eval/datasets/seed.jsonl --configs rules
226
+ uv run python eval/run_eval.py --dataset eval/datasets/seed.jsonl --configs all --yes # spends API credits
227
+ uv run python eval/run_host_eval.py --model claude-sonnet-5-5 --yes # Host mode via Claude Code
228
+ ```
229
+
230
+ Results: [real-world evaluation](https://github.com/johnnyzn/Extrospect/blob/main/docs/eval_real_world.md)
231
+ and the generated [eval_results.md](https://github.com/johnnyzn/Extrospect/blob/main/docs/eval_results.md).
232
+
233
+ ## Development
234
+
235
+ ```bash
236
+ uv run pytest # ~170 tests, offline, zero tokens (LLM calls use fake backends)
237
+ uv run ruff check src tests eval && uv run mypy
238
+ ```
239
+
240
+ Security issues: see [SECURITY.md](https://github.com/johnnyzn/Extrospect/blob/main/SECURITY.md).
241
+
242
+ ## License
243
+
244
+ [Apache License 2.0](https://github.com/johnnyzn/Extrospect/blob/main/LICENSE).