scrypto-audit-kit 0.5.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 (30) hide show
  1. scrypto_audit_kit-0.5.0/LICENSE +201 -0
  2. scrypto_audit_kit-0.5.0/PKG-INFO +307 -0
  3. scrypto_audit_kit-0.5.0/README.md +277 -0
  4. scrypto_audit_kit-0.5.0/VERSION +1 -0
  5. scrypto_audit_kit-0.5.0/bin/__init__.py +56 -0
  6. scrypto_audit_kit-0.5.0/bin/attest.py +128 -0
  7. scrypto_audit_kit-0.5.0/bin/ci-gate.py +14 -0
  8. scrypto_audit_kit-0.5.0/bin/ci_gate.py +54 -0
  9. scrypto_audit_kit-0.5.0/bin/extract-report.py +229 -0
  10. scrypto_audit_kit-0.5.0/bin/gen_tests.py +157 -0
  11. scrypto_audit_kit-0.5.0/bin/mcp_server.py +284 -0
  12. scrypto_audit_kit-0.5.0/bin/sak_lib.py +268 -0
  13. scrypto_audit_kit-0.5.0/bin/static_analysis.py +414 -0
  14. scrypto_audit_kit-0.5.0/pyproject.toml +65 -0
  15. scrypto_audit_kit-0.5.0/scrypto_audit_kit.egg-info/PKG-INFO +307 -0
  16. scrypto_audit_kit-0.5.0/scrypto_audit_kit.egg-info/SOURCES.txt +28 -0
  17. scrypto_audit_kit-0.5.0/scrypto_audit_kit.egg-info/dependency_links.txt +1 -0
  18. scrypto_audit_kit-0.5.0/scrypto_audit_kit.egg-info/entry_points.txt +6 -0
  19. scrypto_audit_kit-0.5.0/scrypto_audit_kit.egg-info/requires.txt +10 -0
  20. scrypto_audit_kit-0.5.0/scrypto_audit_kit.egg-info/top_level.txt +1 -0
  21. scrypto_audit_kit-0.5.0/setup.cfg +4 -0
  22. scrypto_audit_kit-0.5.0/tests/test_attest.py +79 -0
  23. scrypto_audit_kit-0.5.0/tests/test_examples.py +55 -0
  24. scrypto_audit_kit-0.5.0/tests/test_gen_tests.py +63 -0
  25. scrypto_audit_kit-0.5.0/tests/test_mcp_tools.py +105 -0
  26. scrypto_audit_kit-0.5.0/tests/test_packaging.py +107 -0
  27. scrypto_audit_kit-0.5.0/tests/test_sak_lib.py +133 -0
  28. scrypto_audit_kit-0.5.0/tests/test_security.py +189 -0
  29. scrypto_audit_kit-0.5.0/tests/test_static_analysis.py +205 -0
  30. scrypto_audit_kit-0.5.0/tests/test_tool_contracts.py +120 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing the Work or
166
+ Derivative Works thereof, You may choose to offer, and charge a
167
+ fee for, acceptance of support, warranty, indemnity, or other
168
+ liability obligations and/or rights consistent with this License.
169
+ However, in accepting such obligations, You may act only on Your
170
+ own behalf and on Your sole responsibility, not on behalf of any
171
+ other Contributor, and only if You agree to indemnify, defend,
172
+ and hold each Contributor harmless for any liability incurred by,
173
+ or claims asserted against, such Contributor by reason of your
174
+ accepting any such warranty or support.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 scrypto-audit-kit contributors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,307 @@
1
+ Metadata-Version: 2.4
2
+ Name: scrypto-audit-kit
3
+ Version: 0.5.0
4
+ Summary: Pre-audit toolkit for Scrypto blueprints on Radix: deterministic static analysis, an LLM checklist pass, machine-readable reports, an MCP server, and on-chain attestation.
5
+ Author: bigdev
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/bigdevxrd/scrypto-audit-kit
8
+ Project-URL: Repository, https://github.com/bigdevxrd/scrypto-audit-kit
9
+ Project-URL: Issues, https://github.com/bigdevxrd/scrypto-audit-kit/issues
10
+ Project-URL: Documentation, https://github.com/bigdevxrd/scrypto-audit-kit/tree/main/docs
11
+ Keywords: scrypto,radix,smart-contracts,security,audit,static-analysis,mcp,defi,web3
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Topic :: Security
18
+ Classifier: Topic :: Software Development :: Quality Assurance
19
+ Requires-Python: >=3.8
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Provides-Extra: mcp
23
+ Requires-Dist: mcp[cli]>=1.0; extra == "mcp"
24
+ Provides-Extra: schema
25
+ Requires-Dist: jsonschema>=4.0; extra == "schema"
26
+ Provides-Extra: dev
27
+ Requires-Dist: jsonschema>=4.0; extra == "dev"
28
+ Requires-Dist: mcp[cli]>=1.0; extra == "dev"
29
+ Dynamic: license-file
30
+
31
+ # scrypto-audit-kit
32
+
33
+ [![lint](https://github.com/bigdevxrd/scrypto-audit-kit/actions/workflows/lint.yml/badge.svg)](https://github.com/bigdevxrd/scrypto-audit-kit/actions/workflows/lint.yml)
34
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
35
+ [![Scrypto · Radix](https://img.shields.io/badge/Scrypto-Radix-052CC0)](https://docs.radixdlt.com/docs/scrypto-1)
36
+ [![status: alpha](https://img.shields.io/badge/status-alpha-orange.svg)](#limitations--read-this-before-relying-on-the-output)
37
+ [![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md)
38
+
39
+ Pre-audit harness for [Scrypto](https://docs.radixdlt.com/docs/scrypto-1) blueprints on the Radix network. Runs a **hybrid analysis** — deterministic static rules plus an LLM pass over a curated checklist + reference patterns — and produces a findings report (markdown + JSON) you can hand to a human auditor (or use to fix issues yourself). The static pass alone is free and needs no API key.
40
+
41
+ This is a **pre-audit** tool, not an audit. It catches the kinds of issues a careful reviewer would catch on a first read so that paid auditors can spend their time on the harder, second-read findings. **It does not replace a human audit before mainnet deployment.**
42
+
43
+ > **Where this fits** — the kit is the entry rung of a *trust ladder* that climbs from `cargo check` up to a full human audit (Hacken, Certik, …). The bigger plan — agentic audit→fix→verify loops, reproducible attested runs, and on-chain attestation — lives in **[VISION.md](VISION.md)**.
44
+
45
+ ## What it does
46
+
47
+ For each scrypto package you point it at, the kit:
48
+
49
+ 1. Runs a **deterministic static pass** (free, no API) — a curated set of high-precision Scrypto rules (unbounded drains, no-owner globalize, self-rotating roles, floats, hardcoded addresses, …).
50
+ 2. Loads the package's source (Cargo.toml + everything under `src/` and `tests/`) into an [aider](https://aider.chat) session.
51
+ 3. Loads a vulnerability **checklist** (11 classes — auth, reentrancy, decimal, resource handling, time, state machine, external calls, upgrade, oracle, slippage, allowances) and a catalogue of **reference patterns** (Ignition, CaviarNine HyperStake, subintents, a strategy-vault threat model, general scrypto knowledge) as read-only context.
52
+ 4. Asks Claude Sonnet 4.6 to produce a structured findings report — summary, findings (Critical → Info), checklist coverage walk, pattern conformance check, test-coverage gaps, open questions for the human auditor.
53
+ 5. Merges both passes and writes a markdown report to `audit-reports/<repo>-<package>-<date>.md` **and** a machine-readable `report.json` ([schema](schema/audit-report.schema.json)) that agents and the CI gate consume.
54
+
55
+ The kit is **read-only by design**. It produces reports; it does not edit your blueprint. Edits to audit-grade code must go through a separate, human-supervised session.
56
+
57
+ ## Quickstart
58
+
59
+ ```bash
60
+ pip install scrypto-audit-kit # the deterministic toolkit + MCP server, no API key needed
61
+ # ...or clone for the full LLM audit harness (audit.sh):
62
+ git clone https://github.com/bigdevxrd/scrypto-audit-kit
63
+ ```
64
+
65
+ The pip package gives you the free static analysis, test-scaffold generation, the attestation
66
+ bridge, and the MCP server — importable and as `sak-*` commands. The full `./audit.sh` (the LLM
67
+ checklist pass) lives in the clone. **[docs/quickstart.md](docs/quickstart.md)** walks all three
68
+ tiers end to end.
69
+
70
+ ### Requirements (for the full `./audit.sh` audit)
71
+
72
+ - [aider](https://aider.chat) (`pip install aider-chat` — version 0.86 or newer)
73
+ - An Anthropic API key (the kit defaults to Claude Sonnet 4.6 — get one at <https://console.anthropic.com>)
74
+ - bash, awk, find (standard on macOS / Linux)
75
+ - `python3` — optional; only needed for the machine-readable `report.json` (the markdown report works without it)
76
+
77
+ The key can be provided in any of three ways:
78
+
79
+ ```bash
80
+ # 1. Export in your shell (preferred for CI)
81
+ export ANTHROPIC_API_KEY=sk-ant-...
82
+
83
+ # 2. Point AIDER_ENV_FILE at an existing env file
84
+ AIDER_ENV_FILE=~/some/.env ./audit.sh /path/to/package
85
+
86
+ # 3. Drop a .env file (gitignored) in the kit directory
87
+ echo "ANTHROPIC_API_KEY=sk-ant-..." > .env
88
+ ```
89
+
90
+ Verify with:
91
+
92
+ ```bash
93
+ make check-deps
94
+ ```
95
+
96
+ ### Run an audit
97
+
98
+ ```bash
99
+ git clone https://github.com/bigdevxrd/scrypto-audit-kit
100
+ cd scrypto-audit-kit
101
+ chmod +x audit.sh
102
+
103
+ ./audit.sh /path/to/your/scrypto/package
104
+ # or:
105
+ make audit TARGET=/path/to/your/scrypto/package
106
+ ```
107
+
108
+ The target must be a scrypto package directory (has a `Cargo.toml` and a `src/lib.rs`). The kit will read everything under `src/` and `tests/`.
109
+
110
+ The report lands in `audit-reports/<repo>-<package>-<YYYY-MM-DD>.md`. Reports are gitignored — share them by other means, don't commit them.
111
+
112
+ ### Example
113
+
114
+ ```bash
115
+ ./audit.sh ~/scrypto/my-vault
116
+ [pre-flight] compile check OFF (default; compiling runs the target's build scripts).
117
+ opt in with --compile-check for code you trust.
118
+
119
+ ==> scrypto-audit-kit
120
+ target: scrypto / my-vault
121
+ path: /home/me/scrypto/my-vault
122
+ model: claude
123
+ sources: 3 files
124
+ refs: 6 files (read-only)
125
+ report -> audit-reports/scrypto-my-vault-2026-05-11.md
126
+
127
+ [aider runs ...]
128
+
129
+ ==> done. report: audit-reports/scrypto-my-vault-2026-05-11.md
130
+ ```
131
+
132
+ > Note: an opt-in `--compile-check` pre-flight runs `cargo check --release --target
133
+ > wasm32-unknown-unknown` first and bails if the package doesn't compile. It is **off by
134
+ > default**: compiling executes the target's build scripts and proc-macros on your machine,
135
+ > so enable it only for code you trust enough to run
136
+ > (`rustup target add wasm32-unknown-unknown` sets up the target).
137
+
138
+ ### Choosing a model
139
+
140
+ The default is Claude Sonnet 4.6. A `--model` flag selects the analysis model:
141
+
142
+ ```bash
143
+ ./audit.sh --model claude <path> # default — Sonnet 4.6, best pattern depth
144
+ ./audit.sh --model deepseek <path> # cheaper broad scan (needs DEEPSEEK_API_KEY)
145
+ ./audit.sh --model both <path> # DeepSeek broad pass, then Claude deep pass,
146
+ # with a cross-model confidence summary
147
+ ```
148
+
149
+ `both` runs DeepSeek first for a wide net, feeds its findings to Claude as
150
+ context, and tags findings both models agree on as HIGH confidence. Use it when
151
+ you want a second opinion on a high-stakes blueprint.
152
+
153
+ ### Free tier: deterministic static analysis
154
+
155
+ A static pass runs on every audit, and you can run it *alone* with **no API key, no aider, and no toolchain**:
156
+
157
+ ```bash
158
+ ./audit.sh --static-only <path> # free, instant, deterministic
159
+ ```
160
+
161
+ It applies a curated set of high-precision Scrypto rules — comment/string-aware, so code rules don't match inside comments or string literals — and writes the same `report.json`. Suppress a finding with a `// sak:allow <rule-id>` comment; add `--no-static` to a full run to skip the pass. See [docs/static-analysis.md](docs/static-analysis.md) for the rule list and how to add one.
162
+
163
+ ### Try it on the bundled example
164
+
165
+ The repo ships a deliberately-vulnerable blueprint so you can see real output without writing any code — the static tier needs no API key:
166
+
167
+ ```bash
168
+ ./audit.sh --static-only examples/vulnerable-vault # free; drop --static-only for the full hybrid run
169
+ ```
170
+
171
+ The expected result is committed beside it — [`examples/vulnerable-vault.pre-audit.md`](examples/vulnerable-vault.pre-audit.md) (human) and [`.json`](examples/vulnerable-vault.pre-audit.json) (machine-readable). Every `file:line` in it is exact, because the bugs are planted.
172
+
173
+ ### Machine-readable output
174
+
175
+ Alongside the markdown, the kit writes `report.json` conforming to [`schema/audit-report.schema.json`](schema/audit-report.schema.json) — stable ids (`F-###` from the LLM, `S-###` from the static pass, each tagged with its `source`), severities, full checklist coverage, and a provenance block (kit version, model, checklist version, and a sha256 of the analyzed source). This is what agents, the CI gate, and (later) on-chain attestation consume; the markdown is a render of it.
176
+
177
+ ### Continuous integration & a badge
178
+
179
+ Run the pre-audit on every PR and show a status badge — full setup in [docs/ci.md](docs/ci.md). In short, call the reusable workflow:
180
+
181
+ ```yaml
182
+ jobs:
183
+ scrypto-pre-audit:
184
+ uses: bigdevxrd/scrypto-audit-kit/.github/workflows/pre-audit.yml@main
185
+ with:
186
+ package: packages/my-blueprint
187
+ fail-on: high
188
+ secrets:
189
+ ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
190
+ ```
191
+
192
+ It compiles, audits, uploads the report, and fails on High/Critical findings — an honest "pre-audit passing" signal, not a safety guarantee.
193
+
194
+ ### Use it from an agent (MCP + Claude Code)
195
+
196
+ The kit ships an **MCP server** so an agent can run the pre-audit as tools and walk you through **audit → fix → re-verify**:
197
+
198
+ ```bash
199
+ pip install "mcp[cli]"
200
+ claude mcp add --transport stdio scrypto-audit-kit -- python3 "$PWD/bin/mcp_server.py"
201
+ ```
202
+
203
+ Tools: `static_scan` (free), `audit_package`, `propose_tests`, `attestation_payload`, `get_findings`, `show_finding_source`, `reaudit_diff`, `gate`, `get_checklist`. There's also a Claude Code skill (`/scrypto-pre-audit`) and an [AGENTS.md](AGENTS.md) playbook for any agent. Full setup — including the audit→fix→verify loop — in [docs/agents.md](docs/agents.md); the nine tools and their formal contracts are in [docs/mcp-tools.md](docs/mcp-tools.md).
204
+
205
+ ### Build on it — the Python SDK
206
+
207
+ `pip install scrypto-audit-kit` makes the deterministic core importable, with zero required
208
+ dependencies:
209
+
210
+ ```python
211
+ from scrypto_audit_kit import static_analysis, sak_lib
212
+ findings = static_analysis.analyze_package("path/to/package") # free, no API key
213
+ verdict = sak_lib.gate_verdict(sak_lib.build_report(findings), "high")
214
+ ```
215
+
216
+ The full API, the nine tools in-process, and the `sak-*` console scripts are in
217
+ [docs/sdk.md](docs/sdk.md). Three runnable example agents — a free-tier CI gate, the
218
+ audit→fix→verify loop, and an MCP client — are in [examples/agents/](examples/agents/).
219
+
220
+ ### Generate tests, attest on-chain
221
+
222
+ - **Property tests.** `propose_tests` (or `python3 bin/gen_tests.py <pkg>`) emits compilable `#[ignore]`d `scrypto-test` scaffolds for the coverage gaps — auth negative-paths, happy paths, a value invariant — so closing them is fill-in-the-blank.
223
+ - **On-chain attestation (L3).** `attestation_payload` (or `python3 bin/attest.py <report.json>`) turns a report into a Radix transaction manifest that records an attestation on-ledger via the [attestation/](attestation/) registry blueprint — bound to your exact source hash (the deterministic anchor). A coverage record, not a safety guarantee, and for the LLM tier not byte-reproducible (see [attestation/README.md](attestation/README.md)).
224
+
225
+ ## What's in the kit
226
+
227
+ ```
228
+ scrypto-audit-kit/
229
+ ├── audit.sh The harness — wraps aider with the right flags + context.
230
+ ├── Makefile Convenience targets (audit, lint, test, check-deps).
231
+ ├── pyproject.toml Pip packaging — importable SDK + sak-* console scripts.
232
+ ├── VERSION Kit version, stamped into every report.
233
+ ├── VISION.md / ROADMAP.md The trust-ladder strategy + the live phase checklist.
234
+ ├── AGENTS.md How an agent should drive the kit (audit → fix → verify).
235
+ ├── .mcp.json MCP server config (auto-wires the tools in Claude Code).
236
+ ├── .aider.conf.yml Tuned config: model=Sonnet 4.6, no editor/commits, cache on.
237
+ ├── prompts/
238
+ │ ├── audit.md Auditor-role prompt + report structure (incl. the JSON appendix).
239
+ │ └── checklist.md Eleven vulnerability classes with concrete questions per class.
240
+ ├── references/ Read-only context — production patterns + threat models (5 files).
241
+ ├── schema/ JSON Schemas — the report + the MCP tool contracts.
242
+ ├── bin/ engine + tools: static_analysis.py, gen_tests.py, attest.py, mcp_server.py, …
243
+ ├── tests/ Stdlib unit tests for the tooling (`make test`).
244
+ ├── docs/ The docs suite (quickstart · sdk · mcp-tools · architecture · …).
245
+ ├── attestation/ On-chain attestation registry blueprint (Scrypto, L3).
246
+ ├── .claude/skills/ The scrypto-pre-audit Claude Code skill.
247
+ ├── audit-reports/ Output dir, gitignored.
248
+ └── examples/
249
+ ├── vulnerable-vault/ Deliberately-vulnerable fixture + its committed report.
250
+ ├── agents/ Runnable example agents (CI gate, audit→fix→verify, MCP client).
251
+ └── ci/ Drop-in pre-audit workflow for your repo.
252
+ ```
253
+
254
+ ## Documentation
255
+
256
+ Everything is in **[docs/](docs/README.md)**; the short list:
257
+
258
+ - [quickstart.md](docs/quickstart.md) — install + run, all three tiers
259
+ - [static-analysis.md](docs/static-analysis.md) — the deterministic rules (and adding one)
260
+ - [agents.md](docs/agents.md) · [mcp-tools.md](docs/mcp-tools.md) — drive it from an agent / over MCP
261
+ - [sdk.md](docs/sdk.md) — the Python API + console scripts
262
+ - [ci.md](docs/ci.md) — CI gate + badge
263
+ - [architecture.md](docs/architecture.md) — how the pieces fit together
264
+ - [VISION.md](VISION.md) · [ROADMAP.md](ROADMAP.md) · [CHANGELOG.md](CHANGELOG.md) — strategy, status, history
265
+
266
+ ## Limitations — read this before relying on the output
267
+
268
+ The kit is honest about what it is. Things it explicitly does **not** do:
269
+
270
+ - **It is not a formal verifier.** No theorem proving, no symbolic execution, no fuzzing. Findings are derived from pattern matching against a checklist by an LLM.
271
+ - **It does not run `cargo build` or `cargo test`.** Compilation issues, dependency vulnerabilities, and test failures are not in scope. Run those separately.
272
+ - **It does not catch novel attack classes.** It will surface known footguns reliably and propose novel concerns as low-confidence open questions. Novel-attack discovery is the human auditor's job.
273
+ - **The LLM can hallucinate file:line citations.** Every finding cites a location; you must verify those citations before acting on them. The audit prompt explicitly instructs the model to cite, but verification is on the reader.
274
+ - **It is not a deployment gate.** Do not block deploys on a clean report. The kit is an aid, not approval.
275
+
276
+ If any of these limitations matter for your use case, do not use this kit as a substitute for a paid audit.
277
+
278
+ ## Cost
279
+
280
+ With the default config (Sonnet 4.6, prompt caching on, references cached across runs):
281
+
282
+ - First audit of a session: ~50k input tokens (references) + 5–20k input tokens (target source) + ~5–15k output tokens → roughly $0.20–$0.40 per run.
283
+ - Subsequent audits in the same prompt-cache window: cached references reduce cost ~70% → roughly $0.10 per run.
284
+
285
+ These figures are estimates as of 2026. Check current [Anthropic pricing](https://www.anthropic.com/pricing) for accurate numbers. The kit deliberately does *not* use the architect/editor split (which would add a second model call) because we want analysis, not code edits.
286
+
287
+ ## Contributing
288
+
289
+ This kit is community-maintained and gets stronger with more eyes on it. The most valuable contributions:
290
+
291
+ - **New vulnerability classes for the checklist.** Real-world Scrypto exploits or footguns we haven't catalogued yet.
292
+ - **New reference patterns.** Open-source Radix blueprints with patterns worth catalogue-ing — adapter scaffolds, role hierarchies, panic modes, etc.
293
+ - **Trial reports.** Run the kit against a public blueprint and share what it found (or missed). Negative results are valuable.
294
+ - **Harness fixes.** False-positive patterns, brittle parsing, missing edge cases in `audit.sh`.
295
+
296
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for the workflow.
297
+
298
+ ## License
299
+
300
+ [Apache 2.0](LICENSE) — the same license most of the upstream Radix ecosystem uses. Forks, derivatives, and commercial use all welcome; attribution preserved per the license.
301
+
302
+ ## Related
303
+
304
+ - [Radix Scrypto docs](https://docs.radixdlt.com/docs/scrypto-1)
305
+ - [radixdlt/Ignition](https://github.com/radixdlt/Ignition) — the canonical Radix-team-maintained reference codebase (most of our `references/ignition-patterns.md` extracts from here)
306
+ - [caviarnine/caviarnine-scrypto](https://github.com/caviarnine/caviarnine-scrypto) — Apache-licensed CaviarNine production blueprints
307
+ - [aider](https://aider.chat) — the LLM coding agent this kit wraps