trace-sec 0.0.0-stage → 2.1.0

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 (249) hide show
  1. package/README.md +210 -2
  2. package/bin/trace.js +112 -0
  3. package/package.json +44 -4
  4. package/pyproject.toml +39 -0
  5. package/src/trace_engine/__init__.py +8 -0
  6. package/src/trace_engine/__pycache__/__init__.cpython-311.pyc +0 -0
  7. package/src/trace_engine/__pycache__/cli.cpython-311.pyc +0 -0
  8. package/src/trace_engine/__pycache__/doctor.cpython-311.pyc +0 -0
  9. package/src/trace_engine/__pycache__/interactive.cpython-311.pyc +0 -0
  10. package/src/trace_engine/__pycache__/verify.cpython-311.pyc +0 -0
  11. package/src/trace_engine/ai/__init__.py +7 -0
  12. package/src/trace_engine/ai/__pycache__/__init__.cpython-311.pyc +0 -0
  13. package/src/trace_engine/ai/__pycache__/base.cpython-311.pyc +0 -0
  14. package/src/trace_engine/ai/__pycache__/ollama.cpython-311.pyc +0 -0
  15. package/src/trace_engine/ai/__pycache__/planner.cpython-311.pyc +0 -0
  16. package/src/trace_engine/ai/base.py +23 -0
  17. package/src/trace_engine/ai/ollama.py +50 -0
  18. package/src/trace_engine/ai/planner.py +40 -0
  19. package/src/trace_engine/apm/__init__.py +18 -0
  20. package/src/trace_engine/apm/__pycache__/__init__.cpython-311.pyc +0 -0
  21. package/src/trace_engine/apm/__pycache__/builder.cpython-311.pyc +0 -0
  22. package/src/trace_engine/apm/__pycache__/edges.cpython-311.pyc +0 -0
  23. package/src/trace_engine/apm/__pycache__/model.cpython-311.pyc +0 -0
  24. package/src/trace_engine/apm/__pycache__/nodes.cpython-311.pyc +0 -0
  25. package/src/trace_engine/apm/__pycache__/serialization.cpython-311.pyc +0 -0
  26. package/src/trace_engine/apm/builder.py +208 -0
  27. package/src/trace_engine/apm/edges.py +25 -0
  28. package/src/trace_engine/apm/model.py +107 -0
  29. package/src/trace_engine/apm/nodes.py +27 -0
  30. package/src/trace_engine/apm/serialization.py +105 -0
  31. package/src/trace_engine/benchmark/__init__.py +5 -0
  32. package/src/trace_engine/benchmark/__pycache__/__init__.cpython-311.pyc +0 -0
  33. package/src/trace_engine/benchmark/__pycache__/owasp.cpython-311.pyc +0 -0
  34. package/src/trace_engine/benchmark/owasp.py +183 -0
  35. package/src/trace_engine/cli.py +1184 -0
  36. package/src/trace_engine/config/__init__.py +35 -0
  37. package/src/trace_engine/config/__pycache__/__init__.cpython-311.pyc +0 -0
  38. package/src/trace_engine/config/__pycache__/defaults.cpython-311.pyc +0 -0
  39. package/src/trace_engine/config/__pycache__/loader.cpython-311.pyc +0 -0
  40. package/src/trace_engine/config/__pycache__/settings.cpython-311.pyc +0 -0
  41. package/src/trace_engine/config/defaults.py +48 -0
  42. package/src/trace_engine/config/loader.py +64 -0
  43. package/src/trace_engine/config/settings.py +72 -0
  44. package/src/trace_engine/doctor.py +250 -0
  45. package/src/trace_engine/findings/__init__.py +15 -0
  46. package/src/trace_engine/findings/__pycache__/__init__.cpython-311.pyc +0 -0
  47. package/src/trace_engine/findings/__pycache__/correlate.cpython-311.pyc +0 -0
  48. package/src/trace_engine/findings/__pycache__/model.cpython-311.pyc +0 -0
  49. package/src/trace_engine/findings/__pycache__/recommendations.cpython-311.pyc +0 -0
  50. package/src/trace_engine/findings/__pycache__/store.cpython-311.pyc +0 -0
  51. package/src/trace_engine/findings/correlate.py +103 -0
  52. package/src/trace_engine/findings/model.py +40 -0
  53. package/src/trace_engine/findings/recommendations.py +35 -0
  54. package/src/trace_engine/findings/store.py +39 -0
  55. package/src/trace_engine/framework/__init__.py +58 -0
  56. package/src/trace_engine/framework/__pycache__/__init__.cpython-311.pyc +0 -0
  57. package/src/trace_engine/framework/__pycache__/base.cpython-311.pyc +0 -0
  58. package/src/trace_engine/framework/__pycache__/csharp.cpython-311.pyc +0 -0
  59. package/src/trace_engine/framework/__pycache__/dart.cpython-311.pyc +0 -0
  60. package/src/trace_engine/framework/__pycache__/django.cpython-311.pyc +0 -0
  61. package/src/trace_engine/framework/__pycache__/express.cpython-311.pyc +0 -0
  62. package/src/trace_engine/framework/__pycache__/fastapi.cpython-311.pyc +0 -0
  63. package/src/trace_engine/framework/__pycache__/flask.cpython-311.pyc +0 -0
  64. package/src/trace_engine/framework/__pycache__/go.cpython-311.pyc +0 -0
  65. package/src/trace_engine/framework/__pycache__/nextjs.cpython-311.pyc +0 -0
  66. package/src/trace_engine/framework/__pycache__/php.cpython-311.pyc +0 -0
  67. package/src/trace_engine/framework/__pycache__/react_router.cpython-311.pyc +0 -0
  68. package/src/trace_engine/framework/__pycache__/ruby.cpython-311.pyc +0 -0
  69. package/src/trace_engine/framework/__pycache__/rust.cpython-311.pyc +0 -0
  70. package/src/trace_engine/framework/__pycache__/springboot.cpython-311.pyc +0 -0
  71. package/src/trace_engine/framework/base.py +49 -0
  72. package/src/trace_engine/framework/csharp.py +111 -0
  73. package/src/trace_engine/framework/dart.py +152 -0
  74. package/src/trace_engine/framework/django.py +188 -0
  75. package/src/trace_engine/framework/express.py +82 -0
  76. package/src/trace_engine/framework/fastapi.py +135 -0
  77. package/src/trace_engine/framework/flask.py +108 -0
  78. package/src/trace_engine/framework/go.py +94 -0
  79. package/src/trace_engine/framework/nextjs.py +200 -0
  80. package/src/trace_engine/framework/php.py +98 -0
  81. package/src/trace_engine/framework/react_router.py +331 -0
  82. package/src/trace_engine/framework/ruby.py +69 -0
  83. package/src/trace_engine/framework/rust.py +101 -0
  84. package/src/trace_engine/framework/springboot.py +145 -0
  85. package/src/trace_engine/harness/__init__.py +19 -0
  86. package/src/trace_engine/harness/__pycache__/__init__.cpython-311.pyc +0 -0
  87. package/src/trace_engine/harness/__pycache__/benchmark.cpython-311.pyc +0 -0
  88. package/src/trace_engine/harness/__pycache__/context.cpython-311.pyc +0 -0
  89. package/src/trace_engine/harness/__pycache__/engine.cpython-311.pyc +0 -0
  90. package/src/trace_engine/harness/__pycache__/patcher.cpython-311.pyc +0 -0
  91. package/src/trace_engine/harness/__pycache__/remediators.cpython-311.pyc +0 -0
  92. package/src/trace_engine/harness/benchmark.py +55 -0
  93. package/src/trace_engine/harness/context.py +49 -0
  94. package/src/trace_engine/harness/engine.py +187 -0
  95. package/src/trace_engine/harness/patcher.py +143 -0
  96. package/src/trace_engine/harness/remediators.py +307 -0
  97. package/src/trace_engine/ingest/__init__.py +15 -0
  98. package/src/trace_engine/ingest/__pycache__/__init__.cpython-311.pyc +0 -0
  99. package/src/trace_engine/ingest/__pycache__/files.cpython-311.pyc +0 -0
  100. package/src/trace_engine/ingest/__pycache__/hashing.cpython-311.pyc +0 -0
  101. package/src/trace_engine/ingest/__pycache__/ignore.cpython-311.pyc +0 -0
  102. package/src/trace_engine/ingest/__pycache__/repository.cpython-311.pyc +0 -0
  103. package/src/trace_engine/ingest/files.py +60 -0
  104. package/src/trace_engine/ingest/hashing.py +21 -0
  105. package/src/trace_engine/ingest/ignore.py +108 -0
  106. package/src/trace_engine/ingest/repository.py +50 -0
  107. package/src/trace_engine/intelligence/__init__.py +15 -0
  108. package/src/trace_engine/intelligence/__pycache__/__init__.cpython-311.pyc +0 -0
  109. package/src/trace_engine/intelligence/__pycache__/evaluation.cpython-311.pyc +0 -0
  110. package/src/trace_engine/intelligence/__pycache__/orchestrator.cpython-311.pyc +0 -0
  111. package/src/trace_engine/intelligence/__pycache__/tracebench.cpython-311.pyc +0 -0
  112. package/src/trace_engine/intelligence/evaluation.py +828 -0
  113. package/src/trace_engine/intelligence/laya/__init__.py +19 -0
  114. package/src/trace_engine/intelligence/laya/__pycache__/__init__.cpython-311.pyc +0 -0
  115. package/src/trace_engine/intelligence/laya/__pycache__/prompts.cpython-311.pyc +0 -0
  116. package/src/trace_engine/intelligence/laya/__pycache__/router.cpython-311.pyc +0 -0
  117. package/src/trace_engine/intelligence/laya/__pycache__/schemas.cpython-311.pyc +0 -0
  118. package/src/trace_engine/intelligence/laya/__pycache__/telemetry.cpython-311.pyc +0 -0
  119. package/src/trace_engine/intelligence/laya/__pycache__/thresholds.cpython-311.pyc +0 -0
  120. package/src/trace_engine/intelligence/laya/prompts.py +67 -0
  121. package/src/trace_engine/intelligence/laya/router.py +352 -0
  122. package/src/trace_engine/intelligence/laya/schemas.py +56 -0
  123. package/src/trace_engine/intelligence/laya/telemetry.py +48 -0
  124. package/src/trace_engine/intelligence/laya/thresholds.py +12 -0
  125. package/src/trace_engine/intelligence/orchestrator.py +130 -0
  126. package/src/trace_engine/intelligence/securebert/__init__.py +6 -0
  127. package/src/trace_engine/intelligence/securebert/__pycache__/__init__.cpython-311.pyc +0 -0
  128. package/src/trace_engine/intelligence/securebert/__pycache__/cache.cpython-311.pyc +0 -0
  129. package/src/trace_engine/intelligence/securebert/__pycache__/classifier.cpython-311.pyc +0 -0
  130. package/src/trace_engine/intelligence/securebert/cache.py +37 -0
  131. package/src/trace_engine/intelligence/securebert/classifier.py +240 -0
  132. package/src/trace_engine/intelligence/tracebench.py +61 -0
  133. package/src/trace_engine/intelligence/training/__init__.py +21 -0
  134. package/src/trace_engine/intelligence/training/__pycache__/__init__.cpython-311.pyc +0 -0
  135. package/src/trace_engine/intelligence/training/__pycache__/dataset.cpython-311.pyc +0 -0
  136. package/src/trace_engine/intelligence/training/__pycache__/dataset_importers.cpython-311.pyc +0 -0
  137. package/src/trace_engine/intelligence/training/__pycache__/laya_trainer.cpython-311.pyc +0 -0
  138. package/src/trace_engine/intelligence/training/__pycache__/lora_system2.cpython-311.pyc +0 -0
  139. package/src/trace_engine/intelligence/training/__pycache__/morefixes_pipeline.cpython-311.pyc +0 -0
  140. package/src/trace_engine/intelligence/training/__pycache__/slicer.cpython-311.pyc +0 -0
  141. package/src/trace_engine/intelligence/training/__pycache__/train_all.cpython-311.pyc +0 -0
  142. package/src/trace_engine/intelligence/training/__pycache__/trainer.cpython-311.pyc +0 -0
  143. package/src/trace_engine/intelligence/training/dataset.py +320 -0
  144. package/src/trace_engine/intelligence/training/dataset_importers.py +349 -0
  145. package/src/trace_engine/intelligence/training/laya_trainer.py +678 -0
  146. package/src/trace_engine/intelligence/training/lora_system2.py +162 -0
  147. package/src/trace_engine/intelligence/training/morefixes_pipeline.py +463 -0
  148. package/src/trace_engine/intelligence/training/slicer.py +129 -0
  149. package/src/trace_engine/intelligence/training/train_all.py +1009 -0
  150. package/src/trace_engine/intelligence/training/trainer.py +321 -0
  151. package/src/trace_engine/interactive.py +623 -0
  152. package/src/trace_engine/mcp/__init__.py +6 -0
  153. package/src/trace_engine/mcp/__pycache__/__init__.cpython-311.pyc +0 -0
  154. package/src/trace_engine/mcp/__pycache__/config.cpython-311.pyc +0 -0
  155. package/src/trace_engine/mcp/__pycache__/server.cpython-311.pyc +0 -0
  156. package/src/trace_engine/mcp/config.py +42 -0
  157. package/src/trace_engine/mcp/server.py +398 -0
  158. package/src/trace_engine/output/__init__.py +28 -0
  159. package/src/trace_engine/output/__pycache__/__init__.cpython-311.pyc +0 -0
  160. package/src/trace_engine/output/__pycache__/html.cpython-311.pyc +0 -0
  161. package/src/trace_engine/output/__pycache__/markdown.cpython-311.pyc +0 -0
  162. package/src/trace_engine/output/__pycache__/sarif.cpython-311.pyc +0 -0
  163. package/src/trace_engine/output/__pycache__/terminal.cpython-311.pyc +0 -0
  164. package/src/trace_engine/output/html.py +142 -0
  165. package/src/trace_engine/output/markdown.py +65 -0
  166. package/src/trace_engine/output/sarif.py +180 -0
  167. package/src/trace_engine/output/terminal.py +537 -0
  168. package/src/trace_engine/parsing/__init__.py +26 -0
  169. package/src/trace_engine/parsing/__pycache__/__init__.cpython-311.pyc +0 -0
  170. package/src/trace_engine/parsing/__pycache__/calls.cpython-311.pyc +0 -0
  171. package/src/trace_engine/parsing/__pycache__/language.cpython-311.pyc +0 -0
  172. package/src/trace_engine/parsing/__pycache__/locations.cpython-311.pyc +0 -0
  173. package/src/trace_engine/parsing/__pycache__/parser.cpython-311.pyc +0 -0
  174. package/src/trace_engine/parsing/__pycache__/symbols.cpython-311.pyc +0 -0
  175. package/src/trace_engine/parsing/calls.py +14 -0
  176. package/src/trace_engine/parsing/language.py +24 -0
  177. package/src/trace_engine/parsing/locations.py +17 -0
  178. package/src/trace_engine/parsing/parser.py +465 -0
  179. package/src/trace_engine/parsing/symbols.py +45 -0
  180. package/src/trace_engine/plugin/__init__.py +157 -0
  181. package/src/trace_engine/plugin/__pycache__/__init__.cpython-311.pyc +0 -0
  182. package/src/trace_engine/plugin/__pycache__/evaluator.cpython-311.pyc +0 -0
  183. package/src/trace_engine/plugin/__pycache__/swebench_adapter.cpython-311.pyc +0 -0
  184. package/src/trace_engine/plugin/__pycache__/task.cpython-311.pyc +0 -0
  185. package/src/trace_engine/plugin/bundle/hooks.json +24 -0
  186. package/src/trace_engine/plugin/bundle/mcp_config.json +11 -0
  187. package/src/trace_engine/plugin/bundle/plugin.json +20 -0
  188. package/src/trace_engine/plugin/bundle/rules/security_remediation.md +40 -0
  189. package/src/trace_engine/plugin/bundle/skills/trace-security-harness/SKILL.md +118 -0
  190. package/src/trace_engine/plugin/evaluator.py +105 -0
  191. package/src/trace_engine/plugin/swebench_adapter.py +96 -0
  192. package/src/trace_engine/plugin/task.py +48 -0
  193. package/src/trace_engine/policy/__init__.py +5 -0
  194. package/src/trace_engine/policy/__pycache__/__init__.cpython-311.pyc +0 -0
  195. package/src/trace_engine/policy/__pycache__/scope.cpython-311.pyc +0 -0
  196. package/src/trace_engine/policy/scope.py +80 -0
  197. package/src/trace_engine/runtime/__init__.py +7 -0
  198. package/src/trace_engine/runtime/__pycache__/__init__.cpython-311.pyc +0 -0
  199. package/src/trace_engine/runtime/__pycache__/client.cpython-311.pyc +0 -0
  200. package/src/trace_engine/runtime/__pycache__/observations.cpython-311.pyc +0 -0
  201. package/src/trace_engine/runtime/__pycache__/target.cpython-311.pyc +0 -0
  202. package/src/trace_engine/runtime/client.py +81 -0
  203. package/src/trace_engine/runtime/observations.py +18 -0
  204. package/src/trace_engine/runtime/target.py +23 -0
  205. package/src/trace_engine/security/__init__.py +16 -0
  206. package/src/trace_engine/security/__pycache__/__init__.cpython-311.pyc +0 -0
  207. package/src/trace_engine/security/__pycache__/fusion.cpython-311.pyc +0 -0
  208. package/src/trace_engine/security/__pycache__/hypotheses.cpython-311.pyc +0 -0
  209. package/src/trace_engine/security/__pycache__/signals.cpython-311.pyc +0 -0
  210. package/src/trace_engine/security/__pycache__/timing.cpython-311.pyc +0 -0
  211. package/src/trace_engine/security/fusion.py +126 -0
  212. package/src/trace_engine/security/hypotheses.py +251 -0
  213. package/src/trace_engine/security/signals.py +28 -0
  214. package/src/trace_engine/security/timing.py +132 -0
  215. package/src/trace_engine/testpacks/__init__.py +18 -0
  216. package/src/trace_engine/testpacks/__pycache__/__init__.cpython-311.pyc +0 -0
  217. package/src/trace_engine/testpacks/__pycache__/authentication.cpython-311.pyc +0 -0
  218. package/src/trace_engine/testpacks/__pycache__/base.cpython-311.pyc +0 -0
  219. package/src/trace_engine/testpacks/__pycache__/bfla.cpython-311.pyc +0 -0
  220. package/src/trace_engine/testpacks/__pycache__/bola.cpython-311.pyc +0 -0
  221. package/src/trace_engine/testpacks/__pycache__/cors.cpython-311.pyc +0 -0
  222. package/src/trace_engine/testpacks/__pycache__/deserialization.cpython-311.pyc +0 -0
  223. package/src/trace_engine/testpacks/__pycache__/injection.cpython-311.pyc +0 -0
  224. package/src/trace_engine/testpacks/__pycache__/mass_assignment.cpython-311.pyc +0 -0
  225. package/src/trace_engine/testpacks/__pycache__/path_traversal.cpython-311.pyc +0 -0
  226. package/src/trace_engine/testpacks/__pycache__/registry.cpython-311.pyc +0 -0
  227. package/src/trace_engine/testpacks/__pycache__/ssrf.cpython-311.pyc +0 -0
  228. package/src/trace_engine/testpacks/__pycache__/ssti.cpython-311.pyc +0 -0
  229. package/src/trace_engine/testpacks/authentication.py +60 -0
  230. package/src/trace_engine/testpacks/base.py +63 -0
  231. package/src/trace_engine/testpacks/bfla.py +70 -0
  232. package/src/trace_engine/testpacks/bola.py +94 -0
  233. package/src/trace_engine/testpacks/cors.py +85 -0
  234. package/src/trace_engine/testpacks/deserialization.py +86 -0
  235. package/src/trace_engine/testpacks/injection.py +179 -0
  236. package/src/trace_engine/testpacks/mass_assignment.py +70 -0
  237. package/src/trace_engine/testpacks/path_traversal.py +117 -0
  238. package/src/trace_engine/testpacks/registry.py +44 -0
  239. package/src/trace_engine/testpacks/ssrf.py +85 -0
  240. package/src/trace_engine/testpacks/ssti.py +96 -0
  241. package/src/trace_engine/tools/__init__.py +6 -0
  242. package/src/trace_engine/tools/__pycache__/__init__.cpython-311.pyc +0 -0
  243. package/src/trace_engine/tools/__pycache__/adapters.cpython-311.pyc +0 -0
  244. package/src/trace_engine/tools/__pycache__/base.cpython-311.pyc +0 -0
  245. package/src/trace_engine/tools/__pycache__/registry.cpython-311.pyc +0 -0
  246. package/src/trace_engine/tools/adapters.py +111 -0
  247. package/src/trace_engine/tools/base.py +68 -0
  248. package/src/trace_engine/tools/registry.py +36 -0
  249. package/src/trace_engine/verify.py +156 -0
package/README.md CHANGED
@@ -1,3 +1,211 @@
1
- # Temporary Holding Version
1
+ # TRACE — Threat Reconnaissance & Attack-path Correlation Engine (v2.1)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![Security Gate](https://github.com/VK-Amogh/TRACE/actions/workflows/trace-gate.yml/badge.svg)](https://github.com/VK-Amogh/TRACE/actions/workflows/trace-gate.yml)
4
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
5
+ [![Python](https://img.shields.io/badge/Python-3.11+-green.svg)](https://www.python.org/)
6
+ [![Node.js](https://img.shields.io/badge/NPX-Zero--Install-mint.svg)](https://nodejs.org/)
7
+ [![AI Models](https://img.shields.io/badge/AI_Models-SecureBERT_2.0_%2B_Laya_System_1-emerald.svg)](https://huggingface.co/ehsanaghaei/SecureBERT)
8
+
9
+ > **Threat Reconnaissance & Attack-path Correlation Engine** — A local-first, zero-telemetry neuro-symbolic security intelligence engine, autonomous agent harness, and deterministic verification layer for AI coding agents (Claude Code, Antigravity, Cursor, Codex, OpenHands).
10
+
11
+ ---
12
+
13
+ ## 🚀 Instant Zero-Install Quickstart (NPX)
14
+
15
+ Run TRACE immediately on any machine with Node.js installed without cloning or manual configuration:
16
+
17
+ ```bash
18
+ # Launch interactive step-by-step security wizard (via NPM)
19
+ npx @vk.amogh/trace
20
+
21
+ # Or run directly from GitHub
22
+ npx github:VK-Amogh/TRACE
23
+
24
+ # Run comprehensive vulnerability audit across all source files and AI models
25
+ npx @vk.amogh/trace audit .
26
+
27
+ # Interactive Architecture & "How It Works" Guide
28
+ npx @vk.amogh/trace how-it-works
29
+ ```
30
+
31
+ Or install globally via npm:
32
+ ```bash
33
+ npm install -g @vk.amogh/trace
34
+ trace welcome
35
+ ```
36
+
37
+ ---
38
+
39
+ ## 🤖 AI Coding Agent Integration (Claude Code, Antigravity, Cursor)
40
+
41
+ TRACE was purpose-built to act as the **ground-truth verification oracle** for autonomous AI coding agents.
42
+
43
+ ### 1-Click Skill & MCP Installation
44
+ Run this single command inside any repository you want your coding agent to audit and repair:
45
+
46
+ ```bash
47
+ npx @vk.amogh/trace install-skill
48
+ ```
49
+
50
+ This immediately registers:
51
+ - **Claude Code Integration:** Configures `.mcp.json` and installs `.claude/skills/trace-security/`
52
+ - **Antigravity / Agentic IDEs:** Installs `.agents/plugins/trace-security/` with rules and skill runbooks
53
+ - **Cursor IDE Integration:** Generates `.cursor/mcp.json`
54
+
55
+ ### Connect Directly to Claude Code CLI
56
+ ```bash
57
+ claude mcp add trace -- npx -y @vk.amogh/trace mcp
58
+ ```
59
+
60
+ ### Registered Agent MCP Tools:
61
+ | Tool Name | Description |
62
+ |---|---|
63
+ | `trace_scan` | Full static AST + Attack-Path Model (APM) + live exploit correlation |
64
+ | `trace_findings` | Query correlated findings with AST code evidence and reproduction steps |
65
+ | `trace_explain` | Deep-dive root-cause analysis with zero-dummy-bypass remediation guidance |
66
+ | `trace_verify` | Live deterministic verification oracle proving whether an agent's patch fixed the flaw |
67
+ | `trace_harness_task` | Generate standardized benchmark tasks for the current unmitigated vulnerability |
68
+ | `trace_eval_patch` | Score patches produced by external agents with rollback protection |
69
+
70
+ ---
71
+
72
+ ## 🧠 Bundled Neural Intelligence Stack (SecureBERT 2.0 & Laya System 1)
73
+
74
+ TRACE does **not** rely solely on static heuristics. It incorporates a fine-tuned dual-engine neural stack bundled directly with the repository via **Git LFS**:
75
+
76
+ 1. **SecureBERT 2.0 Semantic Vulnerability Classifier (`ehsanaghaei/SecureBERT` fine-tuned):**
77
+ - 125M parameter transformer specialized in cybersecurity AST token semantics.
78
+ - Accurately classifies vulnerability classes: **BOLA/IDOR, BFLA, SSRF, Injection (SQLi/Command), Broken Authentication, Mass Assignment, Path Traversal, CORS**.
79
+ - Offline cached token representations for instant classification.
80
+
81
+ 2. **Laya System 1 Decision Engine (`convaiinnovations/laya` fine-tuned):**
82
+ - Dual-head priority router with ONNX Runtime sub-millisecond execution (<0.5ms per endpoint).
83
+ - Dynamically triages high-risk routes into `P0 (Critical Exploit Path)` down to `P3 (Informational)`.
84
+
85
+ ### Zero-Setup Model Verification
86
+ When cloned or installed, TRACE automatically loads the bundled fine-tuned checkpoints from `.trace/models/`:
87
+ ```bash
88
+ trace intelligence
89
+ ```
90
+ Output:
91
+ ```text
92
+ TRACE Intelligence Stack Status
93
+ • Laya System 1 Decision Engine: ONLINE (convaiinnovations/laya loaded on CPU)
94
+ • SecureBERT 2.0 Semantic Classifier: ONLINE (.trace/models/securebert-finetuned)
95
+ • Model Hierarchy: Deterministic -> SecureBERT -> Laya System 1 -> Local LLM
96
+ ```
97
+
98
+ ---
99
+
100
+ ## 🛡️ Core Architecture & Operational Guarantees
101
+
102
+ TRACE operates on three strict architectural invariants:
103
+
104
+ ```
105
+ ┌─────────────────────────┐
106
+ │ Multi-Language AST Code │ (Python, TypeScript, JavaScript, Go, Java, Kotlin, PHP)
107
+ └────────────┬────────────┘
108
+ ▼
109
+ ┌─────────────────────────┐
110
+ │ Attack-Path Model (APM) │ Directed graph: Endpoints ➔ Handlers ➔ Auth Gates ➔ Sinks
111
+ └────────────┬────────────┘
112
+ ▼
113
+ ┌─────────────────────────┐
114
+ │ Neural Intelligence │ SecureBERT 2.0 + Laya System 1 Dual-Engine Scoring
115
+ └────────────┬────────────┘
116
+ ▼
117
+ ┌─────────────────────────┐
118
+ │ ScopeGuard Runtime DAST │ RFC-1918 / Localhost Sandboxed Active Probing
119
+ └────────────┬────────────┘
120
+ ▼
121
+ ┌─────────────────────────┐
122
+ │ Ground-Truth Findings │ 100% Correlated Evidence (Zero False Positives)
123
+ └────────────┬────────────┘
124
+ ▼
125
+ ┌─────────────────────────┐
126
+ │ Agent Remediation Loop │ Auto-patching + Verification Oracle + SWE-bench Export
127
+ └─────────────────────────┘
128
+ ```
129
+
130
+ 1. **100% Local-First & Offline:**
131
+ - Operates completely on your local workstation. Zero external cloud telemetry or proprietary API dependencies.
132
+ 2. **ScopeGuard Boundary Enforcement:**
133
+ - Dynamic probing is hard-isolated to localhost and authorized development containers. Cloud destinations and third-party APIs are rejected at the socket layer.
134
+ 3. **Zero-False-Positive Guarantee:**
135
+ - Flaws are only promoted to `CONFIRMED` when both static AST attack paths and live runtime oracles prove exploitability.
136
+
137
+ ---
138
+
139
+ ## 💻 CLI Command Reference
140
+
141
+ ### Comprehensive Audits & Testing
142
+ ```bash
143
+ # Interactive guided terminal audit wizard
144
+ trace
145
+
146
+ # Full repository audit across all languages, test packs, and AI models
147
+ trace audit [PATH]
148
+
149
+ # End-to-end scan with target URL and SARIF report export
150
+ trace scan [PATH] --target http://127.0.0.1:18080 --format sarif -o results.sarif
151
+
152
+ # Explain a specific finding with reproduction curl commands
153
+ trace explain TR-BOLA-001
154
+
155
+ # Replay exact HTTP reproduction steps
156
+ trace replay TR-BOLA-001
157
+ ```
158
+
159
+ ### Autonomous Remediation & Benchmarking
160
+ ```bash
161
+ # Run self-healing remediation loop (synthesize fix, apply patch, verify oracle)
162
+ trace heal [PATH]
163
+
164
+ # Verify if a developer or coding agent's code change resolved a finding
165
+ trace verify TR-BOLA-001
166
+
167
+ # Benchmark coding agent performance against TRACE-Bench v1.0 scorecard
168
+ trace bench [PATH] --model "Claude-3.7-Sonnet"
169
+
170
+ # Export benchmark instances to SWE-bench JSONL format
171
+ trace plugin export -o swebench_tasks.jsonl
172
+ ```
173
+
174
+ ### System Inspection & Labs
175
+ ```bash
176
+ # Environment diagnostic check (Tree-sitter, SQLite, PyTorch, Tool Adapters)
177
+ trace doctor
178
+
179
+ # Start reference vulnerable Vending API lab
180
+ trace lab start --port 18080
181
+ ```
182
+
183
+ ---
184
+
185
+ ## 🛠️ Python Local Installation (Alternative)
186
+
187
+ If developing directly inside Python:
188
+
189
+ ```bash
190
+ git clone https://github.com/VK-Amogh/TRACE.git
191
+ cd TRACE
192
+
193
+ # Ensure Git LFS pulls the model checkpoints
194
+ git lfs pull
195
+
196
+ # Create virtual environment
197
+ python -m venv .venv
198
+ source .venv/bin/activate # Or on Windows: .venv\Scripts\activate
199
+
200
+ # Install editable package
201
+ pip install -e .
202
+
203
+ # Run test suite (63 unit tests)
204
+ pytest
205
+ ```
206
+
207
+ ---
208
+
209
+ ## 📄 License
210
+
211
+ Apache License 2.0. See [LICENSE](LICENSE) for details.
package/bin/trace.js ADDED
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * TRACE — Threat Reconnaissance & Attack-path Correlation Engine
5
+ * Node.js & NPX launcher for TRACE Python engine.
6
+ */
7
+
8
+ import { spawn } from 'child_process';
9
+ import { existsSync, mkdirSync, cpSync, writeFileSync } from 'fs';
10
+ import { resolve, join, dirname } from 'path';
11
+ import { fileURLToPath } from 'url';
12
+
13
+ const __filename = fileURLToPath(import.meta.url);
14
+ const __dirname = dirname(__filename);
15
+ const projectRoot = resolve(__dirname, '..');
16
+ const args = process.argv.slice(2);
17
+
18
+ // Handle install-skill directly in Node.js for instant zero-dependency agent skill setup
19
+ if (args[0] === 'install-skill' || args[0] === 'setup-agent' || args[0] === 'install-agent') {
20
+ const targetDir = process.cwd();
21
+ const bundleDir = join(projectRoot, 'src', 'trace_engine', 'plugin', 'bundle');
22
+
23
+ console.log('\n\x1b[32m\x1b[1mInstalling TRACE Autonomous Security Agent Skill & MCP Tools...\x1b[0m');
24
+
25
+ if (existsSync(bundleDir)) {
26
+ // 1. Antigravity plugin (.agents/plugins/trace-security)
27
+ const agentPluginDir = join(targetDir, '.agents', 'plugins', 'trace-security');
28
+ mkdirSync(agentPluginDir, { recursive: true });
29
+ cpSync(bundleDir, agentPluginDir, { recursive: true });
30
+ console.log(` \x1b[32m✓\x1b[0m Antigravity Plugin : ${agentPluginDir}`);
31
+
32
+ // 2. Direct agent skill (.agents/skills/trace-security-harness)
33
+ const skillSrc = join(bundleDir, 'skills', 'trace-security-harness');
34
+ if (existsSync(skillSrc)) {
35
+ const agentSkillDir = join(targetDir, '.agents', 'skills', 'trace-security-harness');
36
+ mkdirSync(agentSkillDir, { recursive: true });
37
+ cpSync(skillSrc, agentSkillDir, { recursive: true });
38
+ console.log(` \x1b[32m✓\x1b[0m Agent Skill : ${agentSkillDir}`);
39
+
40
+ // 3. Claude Code skill (.claude/skills/trace-security)
41
+ const claudeSkillDir = join(targetDir, '.claude', 'skills', 'trace-security');
42
+ mkdirSync(claudeSkillDir, { recursive: true });
43
+ cpSync(skillSrc, claudeSkillDir, { recursive: true });
44
+ console.log(` \x1b[32m✓\x1b[0m Claude Code Skill : ${claudeSkillDir}`);
45
+ }
46
+
47
+ // 4. MCP Configuration (.mcp.json and .cursor/mcp.json)
48
+ const isWin = process.platform === 'win32';
49
+ const mcpConfig = {
50
+ mcpServers: {
51
+ trace: {
52
+ command: isWin ? 'cmd.exe' : 'npx',
53
+ args: isWin
54
+ ? ['/c', 'npx', '-y', 'github:VK-Amogh/TRACE', 'mcp']
55
+ : ['-y', 'github:VK-Amogh/TRACE', 'mcp'],
56
+ env: {
57
+ PYTHONUNBUFFERED: '1',
58
+ },
59
+ },
60
+ },
61
+ };
62
+ const mcpJsonPath = join(targetDir, '.mcp.json');
63
+ writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, 2), 'utf-8');
64
+ console.log(` \x1b[32m✓\x1b[0m Claude Code MCP : ${mcpJsonPath}`);
65
+
66
+ const cursorMcpDir = join(targetDir, '.cursor');
67
+ mkdirSync(cursorMcpDir, { recursive: true });
68
+ writeFileSync(join(cursorMcpDir, 'mcp.json'), JSON.stringify(mcpConfig, null, 2), 'utf-8');
69
+ console.log(` \x1b[32m✓\x1b[0m Cursor IDE MCP : ${join(cursorMcpDir, 'mcp.json')}`);
70
+
71
+ console.log('\n\x1b[1mCapabilities Enabled for AI Coding Agents:\x1b[0m');
72
+ console.log(' • \x1b[32mClaude Code Integration:\x1b[0m Skills + MCP server ready');
73
+ console.log(' • \x1b[32mAntigravity & Agentic IDEs:\x1b[0m .agents/plugins/trace-security active');
74
+ console.log(' • \x1b[32mVerification Tools:\x1b[0m trace_scan, trace_findings, trace_verify, trace_harness_task');
75
+ console.log('\n\x1b[90mTo register in Claude Code CLI directly:\x1b[0m');
76
+ console.log(' \x1b[37mclaude mcp add trace -- npx github:VK-Amogh/TRACE mcp\x1b[0m\n');
77
+ process.exit(0);
78
+ } else {
79
+ console.error(`[TRACE] Bundle directory not found at ${bundleDir}`);
80
+ process.exit(1);
81
+ }
82
+ }
83
+
84
+ // Find virtual environment python or system python
85
+ const isWin = process.platform === 'win32';
86
+ const venvPython = isWin
87
+ ? join(projectRoot, '.venv', 'Scripts', 'python.exe')
88
+ : join(projectRoot, '.venv', 'bin', 'python');
89
+
90
+ const pythonBin = existsSync(venvPython) ? venvPython : (isWin ? 'python' : 'python3');
91
+
92
+ const cliArgs = ['-m', 'trace_engine.cli', ...args];
93
+
94
+ const proc = spawn(pythonBin, cliArgs, {
95
+ cwd: process.cwd(),
96
+ stdio: 'inherit',
97
+ env: {
98
+ ...process.env,
99
+ PYTHONPATH: join(projectRoot, 'src') + (process.env.PYTHONPATH ? (isWin ? ';' : ':') + process.env.PYTHONPATH : ''),
100
+ PYTHONIOENCODING: 'utf-8',
101
+ },
102
+ });
103
+
104
+ proc.on('exit', (code) => {
105
+ process.exit(code || 0);
106
+ });
107
+
108
+ proc.on('error', (err) => {
109
+ console.error(`[TRACE] Failed to spawn Python process (${pythonBin}):`, err.message);
110
+ console.error(`Please ensure Python 3.10+ is installed and on your PATH, or run: pip install -e .`);
111
+ process.exit(1);
112
+ });
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "trace-sec",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.1.0",
4
+ "description": "Threat Reconnaissance & Attack-path Correlation Engine — Security Verification Layer for Coding Agents with Fine-Tuned SecureBERT 2.0 & Laya AI",
5
+ "type": "module",
6
+ "main": "bin/trace.js",
7
+ "bin": {
8
+ "trace": "./bin/trace.js",
9
+ "trace-sec": "./bin/trace.js",
10
+ "trace-security": "./bin/trace.js"
11
+ },
12
+ "files": [
13
+ "bin",
14
+ "src",
15
+ "README.md",
16
+ "pyproject.toml"
17
+ ],
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/VK-Amogh/TRACE.git"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/VK-Amogh/TRACE/issues"
24
+ },
25
+ "homepage": "https://github.com/VK-Amogh/TRACE#readme",
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "keywords": [
30
+ "security",
31
+ "dast",
32
+ "sast",
33
+ "attack-path",
34
+ "mcp",
35
+ "claude-code",
36
+ "cursor",
37
+ "codex",
38
+ "antigravity",
39
+ "vulnerability",
40
+ "securebert",
41
+ "laya",
42
+ "agent-harness"
43
+ ],
44
+ "author": "Amogh (VK-Amogh)",
45
+ "license": "Apache-2.0"
46
+ }
package/pyproject.toml ADDED
@@ -0,0 +1,39 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "trace-sec"
7
+ version = "1.0.0"
8
+ description = "Threat Reconnaissance & Attack-path Correlation Engine"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ authors = [
12
+ { name = "TRACE Core Team" }
13
+ ]
14
+ dependencies = [
15
+ "typer>=0.12.0",
16
+ "rich>=13.7.0",
17
+ "pydantic>=2.7.0",
18
+ "pydantic-settings>=2.2.0",
19
+ "networkx>=3.2.0",
20
+ "httpx>=0.27.0",
21
+ "orjson>=3.9.0",
22
+ "tomli-w>=1.0.0",
23
+ "tree-sitter>=0.21.0",
24
+ "tree-sitter-language-pack>=0.2.0",
25
+ ]
26
+
27
+ [project.scripts]
28
+ trace = "trace_engine.cli:app"
29
+ Trace = "trace_engine.cli:app"
30
+
31
+ [tool.hatch.build.targets.wheel]
32
+ packages = ["src/trace_engine"]
33
+
34
+ [tool.pytest.ini_options]
35
+ testpaths = ["tests"]
36
+ python_files = ["test_*.py"]
37
+ filterwarnings = [
38
+ "ignore::RuntimeWarning:laya.*",
39
+ ]
@@ -0,0 +1,8 @@
1
+ """TRACE — Threat Reconnaissance & Attack-path Correlation Engine.
2
+
3
+ Local-first application security analysis and runtime validation engine.
4
+ """
5
+
6
+ __version__ = "1.0.0"
7
+ __app_name__ = "TRACE"
8
+ __description__ = "Threat Reconnaissance & Attack-path Correlation Engine"
@@ -0,0 +1,7 @@
1
+ """Local AI orchestration module."""
2
+
3
+ from trace_engine.ai.base import AIProvider
4
+ from trace_engine.ai.ollama import OllamaProvider
5
+ from trace_engine.ai.planner import TestPlanner
6
+
7
+ __all__ = ["AIProvider", "OllamaProvider", "TestPlanner"]
@@ -0,0 +1,23 @@
1
+ """Base interfaces for local AI providers."""
2
+
3
+ from abc import ABC, abstractmethod
4
+ from typing import Optional, Dict, Any
5
+
6
+
7
+ class AIProvider(ABC):
8
+ """Abstract interface for local LLM engines."""
9
+
10
+ @property
11
+ @abstractmethod
12
+ def name(self) -> str:
13
+ pass
14
+
15
+ @abstractmethod
16
+ def is_available(self) -> bool:
17
+ """Check if local inference engine is reachable."""
18
+ pass
19
+
20
+ @abstractmethod
21
+ def generate(self, prompt: str, system_prompt: Optional[str] = None) -> Optional[str]:
22
+ """Generate a response using the local model."""
23
+ pass
@@ -0,0 +1,50 @@
1
+ """Ollama local AI provider."""
2
+
3
+ import httpx
4
+ from typing import Optional
5
+ from trace_engine.ai.base import AIProvider
6
+
7
+
8
+ class OllamaProvider(AIProvider):
9
+ """Integrates with local Ollama runtime for offline model execution."""
10
+
11
+ def __init__(
12
+ self,
13
+ endpoint: str = "http://127.0.0.1:11434",
14
+ model: str = "qwen2.5-coder:latest",
15
+ temperature: float = 0.1,
16
+ ):
17
+ self.endpoint = endpoint.rstrip("/")
18
+ self.model = model
19
+ self.temperature = temperature
20
+
21
+ @property
22
+ def name(self) -> str:
23
+ return f"Ollama ({self.model})"
24
+
25
+ def is_available(self) -> bool:
26
+ try:
27
+ with httpx.Client(timeout=2.0) as client:
28
+ res = client.get(f"{self.endpoint}/api/tags")
29
+ return res.status_code == 200
30
+ except Exception:
31
+ return False
32
+
33
+ def generate(self, prompt: str, system_prompt: Optional[str] = None) -> Optional[str]:
34
+ try:
35
+ payload = {
36
+ "model": self.model,
37
+ "prompt": prompt,
38
+ "stream": False,
39
+ "options": {"temperature": self.temperature},
40
+ }
41
+ if system_prompt:
42
+ payload["system"] = system_prompt
43
+
44
+ with httpx.Client(timeout=30.0) as client:
45
+ res = client.post(f"{self.endpoint}/api/generate", json=payload)
46
+ if res.status_code == 200:
47
+ return res.json().get("response")
48
+ except Exception:
49
+ pass
50
+ return None
@@ -0,0 +1,40 @@
1
+ """AI and deterministic test planner for orchestrating security validation."""
2
+
3
+ from typing import List, Optional
4
+ from trace_engine.security.hypotheses import SecurityHypothesis
5
+ from trace_engine.ai.base import AIProvider
6
+ from trace_engine.ai.ollama import OllamaProvider
7
+
8
+
9
+ class TestPlanner:
10
+ """Orchestrates test selection using deterministic signals and optional local AI reasoning."""
11
+
12
+ def __init__(self, ai_provider: Optional[AIProvider] = None):
13
+ self.ai_provider = ai_provider or OllamaProvider()
14
+
15
+ def prioritize_hypotheses(
16
+ self, hypotheses: List[SecurityHypothesis]
17
+ ) -> List[SecurityHypothesis]:
18
+ """Orders hypotheses by severity prior and attack surface criticality."""
19
+ return sorted(hypotheses, key=lambda h: h.confidence_prior, reverse=True)
20
+
21
+ def explain_finding_with_ai(
22
+ self, title: str, category: str, attack_path: List[str], evidence: List[str]
23
+ ) -> str:
24
+ """Uses local AI if available to explain root cause and exploitability in plain language."""
25
+ if self.ai_provider and self.ai_provider.is_available():
26
+ prompt = (
27
+ f"Explain the security vulnerability '{title}' in category {category}.\n"
28
+ f"Attack path hops: {' -> '.join(attack_path)}\n"
29
+ f"Evidence: {'; '.join(evidence)}\n"
30
+ f"Provide a concise, 2-3 sentence technical explanation of the exploit risk and fix."
31
+ )
32
+ response = self.ai_provider.generate(prompt)
33
+ if response:
34
+ return response.strip()
35
+
36
+ # Fallback explanation
37
+ return (
38
+ f"The attack path violates security invariant {category}. "
39
+ f"Static code flow reaches sensitive sink without boundary enforcement."
40
+ )
@@ -0,0 +1,18 @@
1
+ """Attack-Path Model (APM) module."""
2
+
3
+ from trace_engine.apm.nodes import APMNode, NodeType
4
+ from trace_engine.apm.edges import APMEdge, EdgeType
5
+ from trace_engine.apm.model import AttackPathModel
6
+ from trace_engine.apm.builder import APMBuilder
7
+ from trace_engine.apm.serialization import save_apm_sqlite, export_apm_json
8
+
9
+ __all__ = [
10
+ "APMNode",
11
+ "NodeType",
12
+ "APMEdge",
13
+ "EdgeType",
14
+ "AttackPathModel",
15
+ "APMBuilder",
16
+ "save_apm_sqlite",
17
+ "export_apm_json",
18
+ ]