wrasse 1.0.0b0__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.
- wrasse-1.0.0b0/AGENTS.md +34 -0
- wrasse-1.0.0b0/CHANGELOG.md +118 -0
- wrasse-1.0.0b0/CONTRIBUTING.md +48 -0
- wrasse-1.0.0b0/LICENSE +21 -0
- wrasse-1.0.0b0/MANIFEST.in +12 -0
- wrasse-1.0.0b0/PKG-INFO +187 -0
- wrasse-1.0.0b0/README.md +137 -0
- wrasse-1.0.0b0/README_zh.md +137 -0
- wrasse-1.0.0b0/SECURITY.md +44 -0
- wrasse-1.0.0b0/examples/showcase/.cursorrules +3 -0
- wrasse-1.0.0b0/examples/showcase/.env +1 -0
- wrasse-1.0.0b0/examples/showcase/AdminController.java +15 -0
- wrasse-1.0.0b0/examples/showcase/Crypto.java +13 -0
- wrasse-1.0.0b0/examples/showcase/admin.py +8 -0
- wrasse-1.0.0b0/examples/showcase/api.py +6 -0
- wrasse-1.0.0b0/examples/showcase/authz.py +10 -0
- wrasse-1.0.0b0/examples/showcase/config.py +12 -0
- wrasse-1.0.0b0/examples/showcase/config_flags.js +7 -0
- wrasse-1.0.0b0/examples/showcase/crypto_bad.py +12 -0
- wrasse-1.0.0b0/examples/showcase/csrf_config.py +6 -0
- wrasse-1.0.0b0/examples/showcase/deser.py +4 -0
- wrasse-1.0.0b0/examples/showcase/errors.py +4 -0
- wrasse-1.0.0b0/examples/showcase/failopen.py +5 -0
- wrasse-1.0.0b0/examples/showcase/frontend.ts +4 -0
- wrasse-1.0.0b0/examples/showcase/history_leak.py +1 -0
- wrasse-1.0.0b0/examples/showcase/legacy/requirements.txt +2 -0
- wrasse-1.0.0b0/examples/showcase/limits.py +3 -0
- wrasse-1.0.0b0/examples/showcase/logging_inj.py +9 -0
- wrasse-1.0.0b0/examples/showcase/login_cost.js +5 -0
- wrasse-1.0.0b0/examples/showcase/logs.py +5 -0
- wrasse-1.0.0b0/examples/showcase/misconfig.py +9 -0
- wrasse-1.0.0b0/examples/showcase/models.py +5 -0
- wrasse-1.0.0b0/examples/showcase/mongo.py +6 -0
- wrasse-1.0.0b0/examples/showcase/notes.md +2 -0
- wrasse-1.0.0b0/examples/showcase/owasp.py +17 -0
- wrasse-1.0.0b0/examples/showcase/page.html +1 -0
- wrasse-1.0.0b0/examples/showcase/pyproject.toml +4 -0
- wrasse-1.0.0b0/examples/showcase/requirements.txt +9 -0
- wrasse-1.0.0b0/examples/showcase/roles.py +10 -0
- wrasse-1.0.0b0/examples/showcase/secrets.py +5 -0
- wrasse-1.0.0b0/examples/showcase/serializers.py +6 -0
- wrasse-1.0.0b0/examples/showcase/service.py +2 -0
- wrasse-1.0.0b0/examples/showcase/sql.py +9 -0
- wrasse-1.0.0b0/examples/showcase/template.py +9 -0
- wrasse-1.0.0b0/examples/showcase/toolbox.py +4 -0
- wrasse-1.0.0b0/examples/showcase/tunnel.py +1 -0
- wrasse-1.0.0b0/examples/showcase/upload.py +6 -0
- wrasse-1.0.0b0/examples/showcase/web/app.js +2 -0
- wrasse-1.0.0b0/examples/showcase/web/package-lock.json +1 -0
- wrasse-1.0.0b0/examples/showcase/web/package.json +1 -0
- wrasse-1.0.0b0/pyproject.toml +45 -0
- wrasse-1.0.0b0/setup.cfg +4 -0
- wrasse-1.0.0b0/src/wrasse/__init__.py +3 -0
- wrasse-1.0.0b0/src/wrasse/__main__.py +3 -0
- wrasse-1.0.0b0/src/wrasse/cli.py +1051 -0
- wrasse-1.0.0b0/src/wrasse/core.py +542 -0
- wrasse-1.0.0b0/src/wrasse/deps.py +142 -0
- wrasse-1.0.0b0/src/wrasse/facts.py +874 -0
- wrasse-1.0.0b0/src/wrasse/history.py +82 -0
- wrasse-1.0.0b0/src/wrasse/java.py +86 -0
- wrasse-1.0.0b0/src/wrasse/py.typed +0 -0
- wrasse-1.0.0b0/src/wrasse/report.py +341 -0
- wrasse-1.0.0b0/src/wrasse/rules.py +568 -0
- wrasse-1.0.0b0/src/wrasse/rulesdoc.py +151 -0
- wrasse-1.0.0b0/src/wrasse/structure.py +767 -0
- wrasse-1.0.0b0/src/wrasse/term.py +225 -0
- wrasse-1.0.0b0/src/wrasse.egg-info/PKG-INFO +187 -0
- wrasse-1.0.0b0/src/wrasse.egg-info/SOURCES.txt +128 -0
- wrasse-1.0.0b0/src/wrasse.egg-info/dependency_links.txt +1 -0
- wrasse-1.0.0b0/src/wrasse.egg-info/entry_points.txt +2 -0
- wrasse-1.0.0b0/src/wrasse.egg-info/requires.txt +3 -0
- wrasse-1.0.0b0/src/wrasse.egg-info/top_level.txt +1 -0
- wrasse-1.0.0b0/tests/corpus/secure/.cursorrules +2 -0
- wrasse-1.0.0b0/tests/corpus/secure/.env +1 -0
- wrasse-1.0.0b0/tests/corpus/secure/.gitignore +1 -0
- wrasse-1.0.0b0/tests/corpus/secure/ok_authz.py +6 -0
- wrasse-1.0.0b0/tests/corpus/secure/ok_crypto.py +9 -0
- wrasse-1.0.0b0/tests/corpus/secure/ok_deser.py +8 -0
- wrasse-1.0.0b0/tests/corpus/secure/ok_docs.py +6 -0
- wrasse-1.0.0b0/tests/corpus/secure/ok_env.py +5 -0
- wrasse-1.0.0b0/tests/corpus/secure/ok_escape.py +8 -0
- wrasse-1.0.0b0/tests/corpus/secure/ok_helper.py +10 -0
- wrasse-1.0.0b0/tests/corpus/secure/ok_hosts.py +1 -0
- wrasse-1.0.0b0/tests/corpus/secure/ok_http.py +8 -0
- wrasse-1.0.0b0/tests/corpus/secure/ok_input.py +11 -0
- wrasse-1.0.0b0/tests/corpus/secure/ok_log.py +10 -0
- wrasse-1.0.0b0/tests/corpus/secure/ok_logs.py +5 -0
- wrasse-1.0.0b0/tests/corpus/secure/ok_page.html +1 -0
- wrasse-1.0.0b0/tests/corpus/secure/ok_sql.py +3 -0
- wrasse-1.0.0b0/tests/corpus/secure/ok_xml.py +5 -0
- wrasse-1.0.0b0/tests/corpus/secure/ok_yaml.py +5 -0
- wrasse-1.0.0b0/tests/corpus/secure/requirements.txt +5 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/.cursorrules +3 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/.env +1 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/Crypto.java +13 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/admin.py +8 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/api.py +6 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/authz.py +10 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/config.py +12 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/config_flags.js +7 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/crypto_bad.py +12 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/deser.py +4 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/errors.py +4 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/failopen.py +5 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/frontend.ts +4 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/legacy/requirements.txt +2 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/limits.py +3 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/logging_inj.py +9 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/logs.py +5 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/misconfig.py +9 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/models.py +5 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/mongo.py +6 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/notes.md +2 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/owasp.py +17 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/page.html +1 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/pyproject.toml +4 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/requirements.txt +7 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/roles.py +10 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/secrets.py +5 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/serializers.py +6 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/service.py +2 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/sql.py +9 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/template.py +9 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/toolbox.py +4 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/tunnel.py +1 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/upload.py +6 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/web/app.js +2 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/web/package-lock.json +1 -0
- wrasse-1.0.0b0/tests/corpus/vulnerable/web/package.json +1 -0
- wrasse-1.0.0b0/tests/test_wrasse.py +1270 -0
wrasse-1.0.0b0/AGENTS.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Notes for agents
|
|
2
|
+
|
|
3
|
+
wrasse is a local security scanner. It is deterministic: a rule fires or it does not, and the same input always produces the same finding id. Preserve that when you drive it.
|
|
4
|
+
|
|
5
|
+
## Calling it
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
wrasse preflight . # config only, executes nothing
|
|
9
|
+
wrasse audit . --format json # machine-readable, one object
|
|
10
|
+
wrasse audit . --fail-on high # exit 2 means the gate failed
|
|
11
|
+
wrasse explain 3 # evidence for one finding
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Read `--format json`. It has a stable shape: `summary`, then `findings[]` with `id`, `rule`, `severity`, `status`, `file`, `line`, `why`, `fix.minus`, `fix.plus`, `evidence`.
|
|
15
|
+
|
|
16
|
+
## Rules for relaying results
|
|
17
|
+
|
|
18
|
+
- **Quote findings; do not summarise them away.** A `critical` finding does not become "a small issue" because the rest looked fine.
|
|
19
|
+
- **Report the exit code as it is.** `4` means the scan did not finish. It is not a pass, and it is not "no problems found".
|
|
20
|
+
- **A `needs_review` finding is not a confirmed bug.** Say so, with the reason the tool gave.
|
|
21
|
+
- **Never edit code to satisfy a finding** unless the user asked for a fix. Emit the `fix.plus` line and let them decide.
|
|
22
|
+
- **Never run `--online`** without asking; it sends dependency names to PyPI or npm.
|
|
23
|
+
|
|
24
|
+
## Where things are
|
|
25
|
+
|
|
26
|
+
| Path | Holds |
|
|
27
|
+
|---|---|
|
|
28
|
+
| `src/wrasse/rules.py` | every rule: id, severity, bilingual title/why/fix, preset prompt |
|
|
29
|
+
| `src/wrasse/facts.py` | line-level detectors (L1) |
|
|
30
|
+
| `src/wrasse/structure.py` | AST detectors (L2): data flow, structural authorization |
|
|
31
|
+
| `src/wrasse/core.py` | project index, route extraction, masking, safe file reads |
|
|
32
|
+
| `tests/corpus/` | 22 vulnerabilities that must be found, 9 secure samples that must stay clean |
|
|
33
|
+
|
|
34
|
+
To add a rule, follow [CONTRIBUTING.md](CONTRIBUTING.md): a rule needs a detector, a corpus sample and an entry in `EXPECTED`. `test_precision_on_secure_corpus` is what will catch a rule that fires on the fixed version of the code.
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0-beta
|
|
4
|
+
|
|
5
|
+
First usable release. No dependencies, no model calls, offline by default.
|
|
6
|
+
|
|
7
|
+
### Detection
|
|
8
|
+
|
|
9
|
+
62 rules across two mainlines.
|
|
10
|
+
|
|
11
|
+
Privacy: hard-coded provider keys, entropy-scored assignments, private key
|
|
12
|
+
blocks, secrets in frontend variables, secrets in browser code, sensitive
|
|
13
|
+
values in logs, exception text returned to clients, secret fields in response
|
|
14
|
+
models, upload paths built from filenames, `.env` readable by an agent.
|
|
15
|
+
|
|
16
|
+
AI pitfalls: packages that do not exist, pinned versions that do not exist,
|
|
17
|
+
typosquatted names, routes with no authentication, queries with no ownership
|
|
18
|
+
constraint, request bodies without a schema, debug mode, wildcard CORS with
|
|
19
|
+
credentials, unsafe deserialization, SQL built from values, command injection,
|
|
20
|
+
SSRF, ownership checked only inside one role branch, credentials that were
|
|
21
|
+
deleted but still sit in git history, request data rendered into HTML without
|
|
22
|
+
escaping, endpoints on disposable tunnels, machine paths and private addresses
|
|
23
|
+
leaked into docs, undeclared imports, and a licence declaration that the LICENSE
|
|
24
|
+
file does not support.
|
|
25
|
+
|
|
26
|
+
Three groups were added later in the same release.
|
|
27
|
+
|
|
28
|
+
- Input models and passwords: mass assignment through a privileged field on an
|
|
29
|
+
input model, MD5/SHA-1 password hashing, outbound `requests` / `httpx` calls
|
|
30
|
+
with no timeout.
|
|
31
|
+
- From the 2026 reports: invisible characters (zero-width, bidi, tag) in agent
|
|
32
|
+
instruction files, reported without echoing the line; request text written
|
|
33
|
+
into a log line with no newline handling (CWE-117); broken ciphers (DES, RC4,
|
|
34
|
+
3DES, ECB, a literal key, Java `Cipher.getInstance`); a dependency whose first
|
|
35
|
+
release is under 90 days old, the one signal slopsquatting leaves before
|
|
36
|
+
install.
|
|
37
|
+
- OWASP API gaps: server-side template injection; a request body used directly
|
|
38
|
+
as a Mongo filter; an admin path that requires login but no role; a list
|
|
39
|
+
endpoint with no `limit`; API docs left open on an app that already looks
|
|
40
|
+
shipped; a dependency installed over plain HTTP; a `verify*` function whose
|
|
41
|
+
`except` returns `True`; strong PII (`id_card`, `ssn`, card numbers) on a
|
|
42
|
+
response model.
|
|
43
|
+
|
|
44
|
+
### Java and Spring
|
|
45
|
+
|
|
46
|
+
Two line-level Java rules need nothing installed: `Cipher.getInstance` and
|
|
47
|
+
`MessageDigest.getInstance`. Three Spring rules need a parser, not a JDK:
|
|
48
|
+
`pip install wrasse[java]` adds wildcard `@CrossOrigin`, `.csrf().disable()` and
|
|
49
|
+
`permitAll()`. Nothing is compiled or run.
|
|
50
|
+
|
|
51
|
+
### Precision
|
|
52
|
+
|
|
53
|
+
Measured on seven real repositories: 191 findings became 54. What changed:
|
|
54
|
+
|
|
55
|
+
- A logging call has to be a level method. `logger.setup_logging(...)` stopped
|
|
56
|
+
matching as a sink.
|
|
57
|
+
- A value counts as request data when it is request-derived, or when the file
|
|
58
|
+
imports a web framework. A CLI's `args` stopped counting.
|
|
59
|
+
- Lines inside multi-line strings are skipped, so prompt text and docstrings no
|
|
60
|
+
longer match code rules.
|
|
61
|
+
- An import inside `try/except ImportError` counts as an optional dependency.
|
|
62
|
+
- `fs/promises` resolves to the Node builtin, and `vscode` / `electron` are
|
|
63
|
+
host-provided.
|
|
64
|
+
- Machine paths produce one finding per file instead of one per line.
|
|
65
|
+
- `shell=True` fires only when request data reaches the command.
|
|
66
|
+
- A monorepo's own workspace packages count as declared.
|
|
67
|
+
- A Python import is checked against Python manifests only.
|
|
68
|
+
- Placeholder paths such as `/Users/x/` and `/Users/demo/` are ignored.
|
|
69
|
+
- A private address counts where it configures a host, and not in a pentest
|
|
70
|
+
example or a help string.
|
|
71
|
+
- Build caches (`.cache`, `.turbo`, `.nx`, `.esbuild`) are out of scope.
|
|
72
|
+
- A bucket ACL and the Django host-check setting match only when a value is
|
|
73
|
+
assigned, so another scanner's rule table no longer matches them.
|
|
74
|
+
- In JavaScript and TypeScript only `eval(` is a sink. `exec(` is an interface
|
|
75
|
+
method and `RegExp.prototype.exec`, so it no longer matches there.
|
|
76
|
+
|
|
77
|
+
### Session and configuration
|
|
78
|
+
|
|
79
|
+
`wrasse` opens a session with a banner, the last scan, and a numbered list.
|
|
80
|
+
Typing `/` opens a command menu (`Tab` completes, `↑↓` selects, `Esc` closes,
|
|
81
|
+
the list scrolls). `/config` opens an arrow-key panel over four settings:
|
|
82
|
+
`lang`, `fail_on`, `mode`, `focus`. Both fall back to plain input when there is
|
|
83
|
+
no TTY, so piped use is unchanged.
|
|
84
|
+
|
|
85
|
+
Settings live in `.wrasse/config.json`, written only by `wrasse config set` and
|
|
86
|
+
by `/config`; every command reads it. `--lang` overrides the language for one
|
|
87
|
+
run and writes nothing, so you can read someone else's repository in your own
|
|
88
|
+
language without leaving a file in it. `.wrasse/last.json` stays out of version
|
|
89
|
+
control; `config.json` and `baseline.json` can be committed.
|
|
90
|
+
|
|
91
|
+
### Reporting
|
|
92
|
+
|
|
93
|
+
`--diff REF`, `--baseline FILE`, `--sarif FILE`, and a `baseline` command
|
|
94
|
+
(`create` / `diff`). Output is text (red/green fix lines, line gutter, context),
|
|
95
|
+
JSON, SARIF 2.1.0, or a single-file HTML report, in English or Chinese.
|
|
96
|
+
|
|
97
|
+
The project model is a Python AST index with symbol and route extraction,
|
|
98
|
+
FastAPI `Depends` chains, `APIRouter(prefix=…)` and `include_router(prefix=…)`
|
|
99
|
+
resolution, dependency manifests, and agent config discovery.
|
|
100
|
+
|
|
101
|
+
Commands: `audit`, `preflight`, `review`, `open`, `explain`, `rules`, `config`,
|
|
102
|
+
`baseline`, `doctor`. Finding ids are stable across scans; `open 3` works on the
|
|
103
|
+
last scan's numbering.
|
|
104
|
+
|
|
105
|
+
### Privacy and honesty
|
|
106
|
+
|
|
107
|
+
Offline by default; `--online` is the only way package names leave the machine,
|
|
108
|
+
and the run says which ones it checked. Every finding is `confirmed` or
|
|
109
|
+
`needs_review`, severity is kept separate from confidence, exit code 4 means the
|
|
110
|
+
scan did not finish, and a credential is masked before any renderer sees it.
|
|
111
|
+
|
|
112
|
+
### Known limits
|
|
113
|
+
|
|
114
|
+
- Python and FastAPI in depth. Java gets two line rules plus the optional Spring
|
|
115
|
+
parser; other languages are not scanned.
|
|
116
|
+
- Authorization is structural. Semantic inference is planned for 1.1.
|
|
117
|
+
- No incremental scan.
|
|
118
|
+
- `pytest`-style fixtures are not modelled.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
## Run the tests
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
python -m unittest discover -s tests -v
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
No third-party test runner. 34 tests, about a second.
|
|
10
|
+
|
|
11
|
+
## Adding a rule
|
|
12
|
+
|
|
13
|
+
A rule is six pieces of content plus one detector. All six live in
|
|
14
|
+
`src/wrasse/rules.py`; the detector lives in `facts.py` (L1, line/regex level) or
|
|
15
|
+
`structure.py` (L2, AST level).
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
_r("category/name", mainline, severity, status,
|
|
19
|
+
"Title in English", "标题(中文)",
|
|
20
|
+
"Why it matters in English.", "为什么重要(中文)。",
|
|
21
|
+
"{line}", "<the suggested replacement>",
|
|
22
|
+
"Preset prompt in English, with {{file}} {{line}} {{snippet}}.",
|
|
23
|
+
"中文预设提示词。")
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Then:
|
|
27
|
+
|
|
28
|
+
1. Add a vulnerable sample under `tests/corpus/vulnerable/`.
|
|
29
|
+
2. Add the rule to `EXPECTED` in `tests/test_wrasse.py`.
|
|
30
|
+
3. Add a secure sample under `tests/corpus/secure/` that must stay clean — the
|
|
31
|
+
most common regression is a rule that fires on the *fixed* version of the code.
|
|
32
|
+
4. Run the tests. `test_precision_on_secure_corpus` is the one that will catch you.
|
|
33
|
+
|
|
34
|
+
## Rule standards
|
|
35
|
+
|
|
36
|
+
- **`fix` must be pasteable.** Not "add a check" — the actual line. If we cannot
|
|
37
|
+
give a correct generic fix, the fix line is `# manual review required — …`.
|
|
38
|
+
- **`needs_review` when we cannot see the whole picture.** Anything that depends
|
|
39
|
+
on code outside the scanned tree, on middleware, or on deployment config must
|
|
40
|
+
not be `confirmed`.
|
|
41
|
+
- **No rule may print a secret.** Route every `secret/*` finding through `_emit`,
|
|
42
|
+
which masks values.
|
|
43
|
+
- **Deterministic only.** No model calls, no network, no randomness. A rule that
|
|
44
|
+
needs judgement beyond the AST belongs in `needs_review`, not in a heuristic.
|
|
45
|
+
|
|
46
|
+
## Commit messages
|
|
47
|
+
|
|
48
|
+
One line, imperative, what changed and why: `tighten ssrf rule to ignore fixed hosts`.
|
wrasse-1.0.0b0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jiaming Shi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
include LICENSE
|
|
2
|
+
include README.md
|
|
3
|
+
include README_zh.md
|
|
4
|
+
include AGENTS.md
|
|
5
|
+
include SECURITY.md
|
|
6
|
+
include CONTRIBUTING.md
|
|
7
|
+
include CHANGELOG.md
|
|
8
|
+
graft tests
|
|
9
|
+
graft examples/showcase
|
|
10
|
+
prune tests/__pycache__
|
|
11
|
+
prune examples/showcase/__pycache__
|
|
12
|
+
global-exclude *.pyc
|
wrasse-1.0.0b0/PKG-INFO
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: wrasse
|
|
3
|
+
Version: 1.0.0b0
|
|
4
|
+
Summary: Security audit for AI-written code — deterministic, offline, no API key.
|
|
5
|
+
Author: Jiaming Shi
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Jiaming Shi
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/JiamingShi-JsPhys/wrasse
|
|
29
|
+
Project-URL: Source, https://github.com/JiamingShi-JsPhys/wrasse
|
|
30
|
+
Project-URL: Issues, https://github.com/JiamingShi-JsPhys/wrasse/issues
|
|
31
|
+
Project-URL: Changelog, https://github.com/JiamingShi-JsPhys/wrasse/blob/main/CHANGELOG.md
|
|
32
|
+
Keywords: security,sast,fastapi,ai-generated-code,privacy,secrets,cli
|
|
33
|
+
Classifier: Development Status :: 4 - Beta
|
|
34
|
+
Classifier: Environment :: Console
|
|
35
|
+
Classifier: Intended Audience :: Developers
|
|
36
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
37
|
+
Classifier: Operating System :: OS Independent
|
|
38
|
+
Classifier: Programming Language :: Python :: 3
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
42
|
+
Classifier: Topic :: Security
|
|
43
|
+
Classifier: Typing :: Typed
|
|
44
|
+
Requires-Python: >=3.11
|
|
45
|
+
Description-Content-Type: text/markdown
|
|
46
|
+
License-File: LICENSE
|
|
47
|
+
Provides-Extra: java
|
|
48
|
+
Requires-Dist: javalang>=0.13; extra == "java"
|
|
49
|
+
Dynamic: license-file
|
|
50
|
+
|
|
51
|
+
# wrasse
|
|
52
|
+
|
|
53
|
+
**Audit the code an AI wrote. Every finding comes with the exact line to replace.**
|
|
54
|
+
|
|
55
|
+
Deterministic rules, no model, no network by default, no API key.
|
|
56
|
+
|
|
57
|
+
**English** · [简体中文](README_zh.md)
|
|
58
|
+
|
|
59
|
+
**Version:** 1.0.0-beta · **License:** MIT · **Python:** 3.11+ · **Dependencies:** none
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## What it does
|
|
64
|
+
|
|
65
|
+
It answers two questions.
|
|
66
|
+
|
|
67
|
+
**Will this code leak something?** Hard-coded keys, secrets in `NEXT_PUBLIC_*` variables, tokens in logs, stack traces returned to clients, secret fields in response models, upload paths built from filenames, a `.env` an agent can read.
|
|
68
|
+
|
|
69
|
+
**What did the AI leave out?** Packages that do not exist, routes with no authentication, queries with no ownership check, a check that only runs inside one role branch, request bodies without a schema, an input model the caller can set `is_admin` on, debug mode, wildcard CORS, unsafe deserialization, SQL built from values, an outbound call with no timeout, request text written straight into a log line, a broken cipher, invisible characters planted in an agent instruction file, a template built from the request, an admin path that only checks login, a list endpoint with no ceiling, a verification that returns True when it throws.
|
|
70
|
+
|
|
71
|
+
Every finding carries the file, the line, the source text and the reason. The red line is what you have; the green line is what to put there. Where a correct generic replacement cannot be proven, the green line says so and does not invent one: a wrong patch makes the problem look fixed.
|
|
72
|
+
|
|
73
|
+
62 rules. 111 tests. Nothing calls a model.
|
|
74
|
+
|
|
75
|
+
## Install
|
|
76
|
+
|
|
77
|
+
Not on PyPI yet.
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
cd wrasse
|
|
81
|
+
python -m pip install -e . --no-deps
|
|
82
|
+
wrasse --version
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
`--no-deps` is there because there are none. Without installing, `PYTHONPATH=src python -m wrasse …` runs the same code.
|
|
86
|
+
|
|
87
|
+
Java: `Cipher.getInstance("DES…")` and `MessageDigest.getInstance("MD5")` are checked without installing anything extra. The three Spring rules need a parser rather than a JDK: `pip install wrasse[java]` adds wildcard `@CrossOrigin`, `.csrf().disable()` and `permitAll()`.
|
|
88
|
+
|
|
89
|
+
## Use
|
|
90
|
+
|
|
91
|
+
Day to day:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
wrasse # session: last scan, then a prompt
|
|
95
|
+
wrasse audit . # scan the current project
|
|
96
|
+
wrasse review # step through the findings
|
|
97
|
+
wrasse explain 3 # why the third one is a finding
|
|
98
|
+
wrasse open 3 # open it at its line
|
|
99
|
+
wrasse config set lang zh # report language, saved for this project
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Wiring it in:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
wrasse audit . --diff main # only lines changed since main
|
|
106
|
+
wrasse audit . --mode quick # L1 only, fits a pre-commit hook
|
|
107
|
+
wrasse audit . --format sarif --fail-on high # CI and code scanning
|
|
108
|
+
wrasse audit . --online --history # registry checks, deleted keys
|
|
109
|
+
wrasse baseline create # freeze what you already have
|
|
110
|
+
wrasse preflight . # before letting an agent open a repo
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Every command and flag: [docs/commands.md](docs/commands.md). Inside the session a full command works too (`audit . --focus privacy`), plus `/audit`, `o 3`, `?` and `q`. Typing `/` opens a command menu (`Tab` completes, `↑↓` moves); `/config` opens the settings panel.
|
|
114
|
+
|
|
115
|
+
## What a finding looks like
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
app/billing.ts ─────────────────────────────────────── 1
|
|
119
|
+
|
|
120
|
+
● CRITICAL secret/frontend-env .................. 7:1
|
|
121
|
+
5 export const publicConfig = {
|
|
122
|
+
6 publishable: process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE,
|
|
123
|
+
- NEXT_PUBLIC_STRIPE_SECRET: "sk_l••••00",
|
|
124
|
+
+ // server-side only — never expose this secret to the browser
|
|
125
|
+
8 };
|
|
126
|
+
│ why NEXT_PUBLIC_/VITE_/REACT_APP_ variables are inlined into the browser bundle.
|
|
127
|
+
└ → wrasse explain 1
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
A `?` before the rule id means `needs_review`: reported, but never counted by `--fail-on`.
|
|
131
|
+
|
|
132
|
+
## Two mainlines, two depths
|
|
133
|
+
|
|
134
|
+
`--focus privacy | ai | all` picks what to report. `--mode quick | standard` picks how deep to scan. They are independent: the same finding keeps the same id, severity and evidence under any combination.
|
|
135
|
+
|
|
136
|
+
`quick` is L1 only, fast enough for a pre-commit hook. `standard` adds data flow and the structural authorization checks.
|
|
137
|
+
|
|
138
|
+
## Exit codes
|
|
139
|
+
|
|
140
|
+
| Code | Meaning |
|
|
141
|
+
|---|---|
|
|
142
|
+
| `0` | nothing at or above `--fail-on` |
|
|
143
|
+
| `2` | a finding reached `--fail-on` (default `high`) |
|
|
144
|
+
| `3` | the path is not a project |
|
|
145
|
+
| `4` | **the scan did not finish**, which is not a pass |
|
|
146
|
+
|
|
147
|
+
## What it guarantees
|
|
148
|
+
|
|
149
|
+
Every item below has a test.
|
|
150
|
+
|
|
151
|
+
- It parses the project without importing or running it.
|
|
152
|
+
- It never calls a model, and `core`/`facts`/`structure` cannot import one.
|
|
153
|
+
- A credential is masked before any renderer sees it: terminal, JSON, SARIF, HTML, state file.
|
|
154
|
+
- It reads only regular files inside the project, and writes only `.wrasse/` inside it.
|
|
155
|
+
- Offline by default. `--online` is the only thing that leaves the machine, and it says so when it does.
|
|
156
|
+
|
|
157
|
+
## Limits
|
|
158
|
+
|
|
159
|
+
- Authorization is structural: "never written" and "written for one role" are caught; a rule spread across services is `needs_review`.
|
|
160
|
+
- A green line you cannot verify is a template rather than a patch; read it before pasting.
|
|
161
|
+
- Python and FastAPI in depth. Java: two line-level rules built in, three more with `wrasse[java]`. `include_router` prefixes are resolved when static.
|
|
162
|
+
- A scan stops at 20,000 files or 256 MB (exit `4`). No incremental scan yet.
|
|
163
|
+
- XSS is covered for templates (`|safe`), DOM sinks (`innerHTML`) and HTML responses; a custom renderer is not.
|
|
164
|
+
- Data flow crosses one function boundary; a second helper in between is not followed.
|
|
165
|
+
- MCP runtime poisoning is not covered.
|
|
166
|
+
|
|
167
|
+
## Docs
|
|
168
|
+
|
|
169
|
+
- **[examples/showcase-report.html](examples/showcase-report.html)**: every rule on one page, generated from `examples/showcase/`
|
|
170
|
+
- **[docs/commands.md](docs/commands.md)**: which command for which job, for daily use and for wiring it into CI
|
|
171
|
+
- **[docs/reading.html](docs/reading.html)**: how to read a report, every number and symbol
|
|
172
|
+
- **[docs/rules.html](docs/rules.html)**: every rule with its reason and replacement
|
|
173
|
+
- [docs/architecture.md](docs/architecture.md): layers, data model, command surface
|
|
174
|
+
- [CONTRIBUTING.md](CONTRIBUTING.md): how to add a rule, and what a fix must prove
|
|
175
|
+
- [SECURITY.md](SECURITY.md): how to report a problem in wrasse itself
|
|
176
|
+
|
|
177
|
+
## Tests
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
python -m unittest discover -s tests
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
111 tests, no network. `tests/corpus/vulnerable/` holds 53 planted rule/file pairs (62 findings) that must all be found; `tests/corpus/secure/` holds 17 samples that look wrong and are not.
|
|
184
|
+
|
|
185
|
+
## License
|
|
186
|
+
|
|
187
|
+
MIT. Author and maintainer: Jiaming Shi.
|
wrasse-1.0.0b0/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# wrasse
|
|
2
|
+
|
|
3
|
+
**Audit the code an AI wrote. Every finding comes with the exact line to replace.**
|
|
4
|
+
|
|
5
|
+
Deterministic rules, no model, no network by default, no API key.
|
|
6
|
+
|
|
7
|
+
**English** · [简体中文](README_zh.md)
|
|
8
|
+
|
|
9
|
+
**Version:** 1.0.0-beta · **License:** MIT · **Python:** 3.11+ · **Dependencies:** none
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## What it does
|
|
14
|
+
|
|
15
|
+
It answers two questions.
|
|
16
|
+
|
|
17
|
+
**Will this code leak something?** Hard-coded keys, secrets in `NEXT_PUBLIC_*` variables, tokens in logs, stack traces returned to clients, secret fields in response models, upload paths built from filenames, a `.env` an agent can read.
|
|
18
|
+
|
|
19
|
+
**What did the AI leave out?** Packages that do not exist, routes with no authentication, queries with no ownership check, a check that only runs inside one role branch, request bodies without a schema, an input model the caller can set `is_admin` on, debug mode, wildcard CORS, unsafe deserialization, SQL built from values, an outbound call with no timeout, request text written straight into a log line, a broken cipher, invisible characters planted in an agent instruction file, a template built from the request, an admin path that only checks login, a list endpoint with no ceiling, a verification that returns True when it throws.
|
|
20
|
+
|
|
21
|
+
Every finding carries the file, the line, the source text and the reason. The red line is what you have; the green line is what to put there. Where a correct generic replacement cannot be proven, the green line says so and does not invent one: a wrong patch makes the problem look fixed.
|
|
22
|
+
|
|
23
|
+
62 rules. 111 tests. Nothing calls a model.
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
Not on PyPI yet.
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
cd wrasse
|
|
31
|
+
python -m pip install -e . --no-deps
|
|
32
|
+
wrasse --version
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`--no-deps` is there because there are none. Without installing, `PYTHONPATH=src python -m wrasse …` runs the same code.
|
|
36
|
+
|
|
37
|
+
Java: `Cipher.getInstance("DES…")` and `MessageDigest.getInstance("MD5")` are checked without installing anything extra. The three Spring rules need a parser rather than a JDK: `pip install wrasse[java]` adds wildcard `@CrossOrigin`, `.csrf().disable()` and `permitAll()`.
|
|
38
|
+
|
|
39
|
+
## Use
|
|
40
|
+
|
|
41
|
+
Day to day:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
wrasse # session: last scan, then a prompt
|
|
45
|
+
wrasse audit . # scan the current project
|
|
46
|
+
wrasse review # step through the findings
|
|
47
|
+
wrasse explain 3 # why the third one is a finding
|
|
48
|
+
wrasse open 3 # open it at its line
|
|
49
|
+
wrasse config set lang zh # report language, saved for this project
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Wiring it in:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
wrasse audit . --diff main # only lines changed since main
|
|
56
|
+
wrasse audit . --mode quick # L1 only, fits a pre-commit hook
|
|
57
|
+
wrasse audit . --format sarif --fail-on high # CI and code scanning
|
|
58
|
+
wrasse audit . --online --history # registry checks, deleted keys
|
|
59
|
+
wrasse baseline create # freeze what you already have
|
|
60
|
+
wrasse preflight . # before letting an agent open a repo
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Every command and flag: [docs/commands.md](docs/commands.md). Inside the session a full command works too (`audit . --focus privacy`), plus `/audit`, `o 3`, `?` and `q`. Typing `/` opens a command menu (`Tab` completes, `↑↓` moves); `/config` opens the settings panel.
|
|
64
|
+
|
|
65
|
+
## What a finding looks like
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
app/billing.ts ─────────────────────────────────────── 1
|
|
69
|
+
|
|
70
|
+
● CRITICAL secret/frontend-env .................. 7:1
|
|
71
|
+
5 export const publicConfig = {
|
|
72
|
+
6 publishable: process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE,
|
|
73
|
+
- NEXT_PUBLIC_STRIPE_SECRET: "sk_l••••00",
|
|
74
|
+
+ // server-side only — never expose this secret to the browser
|
|
75
|
+
8 };
|
|
76
|
+
│ why NEXT_PUBLIC_/VITE_/REACT_APP_ variables are inlined into the browser bundle.
|
|
77
|
+
└ → wrasse explain 1
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
A `?` before the rule id means `needs_review`: reported, but never counted by `--fail-on`.
|
|
81
|
+
|
|
82
|
+
## Two mainlines, two depths
|
|
83
|
+
|
|
84
|
+
`--focus privacy | ai | all` picks what to report. `--mode quick | standard` picks how deep to scan. They are independent: the same finding keeps the same id, severity and evidence under any combination.
|
|
85
|
+
|
|
86
|
+
`quick` is L1 only, fast enough for a pre-commit hook. `standard` adds data flow and the structural authorization checks.
|
|
87
|
+
|
|
88
|
+
## Exit codes
|
|
89
|
+
|
|
90
|
+
| Code | Meaning |
|
|
91
|
+
|---|---|
|
|
92
|
+
| `0` | nothing at or above `--fail-on` |
|
|
93
|
+
| `2` | a finding reached `--fail-on` (default `high`) |
|
|
94
|
+
| `3` | the path is not a project |
|
|
95
|
+
| `4` | **the scan did not finish**, which is not a pass |
|
|
96
|
+
|
|
97
|
+
## What it guarantees
|
|
98
|
+
|
|
99
|
+
Every item below has a test.
|
|
100
|
+
|
|
101
|
+
- It parses the project without importing or running it.
|
|
102
|
+
- It never calls a model, and `core`/`facts`/`structure` cannot import one.
|
|
103
|
+
- A credential is masked before any renderer sees it: terminal, JSON, SARIF, HTML, state file.
|
|
104
|
+
- It reads only regular files inside the project, and writes only `.wrasse/` inside it.
|
|
105
|
+
- Offline by default. `--online` is the only thing that leaves the machine, and it says so when it does.
|
|
106
|
+
|
|
107
|
+
## Limits
|
|
108
|
+
|
|
109
|
+
- Authorization is structural: "never written" and "written for one role" are caught; a rule spread across services is `needs_review`.
|
|
110
|
+
- A green line you cannot verify is a template rather than a patch; read it before pasting.
|
|
111
|
+
- Python and FastAPI in depth. Java: two line-level rules built in, three more with `wrasse[java]`. `include_router` prefixes are resolved when static.
|
|
112
|
+
- A scan stops at 20,000 files or 256 MB (exit `4`). No incremental scan yet.
|
|
113
|
+
- XSS is covered for templates (`|safe`), DOM sinks (`innerHTML`) and HTML responses; a custom renderer is not.
|
|
114
|
+
- Data flow crosses one function boundary; a second helper in between is not followed.
|
|
115
|
+
- MCP runtime poisoning is not covered.
|
|
116
|
+
|
|
117
|
+
## Docs
|
|
118
|
+
|
|
119
|
+
- **[examples/showcase-report.html](examples/showcase-report.html)**: every rule on one page, generated from `examples/showcase/`
|
|
120
|
+
- **[docs/commands.md](docs/commands.md)**: which command for which job, for daily use and for wiring it into CI
|
|
121
|
+
- **[docs/reading.html](docs/reading.html)**: how to read a report, every number and symbol
|
|
122
|
+
- **[docs/rules.html](docs/rules.html)**: every rule with its reason and replacement
|
|
123
|
+
- [docs/architecture.md](docs/architecture.md): layers, data model, command surface
|
|
124
|
+
- [CONTRIBUTING.md](CONTRIBUTING.md): how to add a rule, and what a fix must prove
|
|
125
|
+
- [SECURITY.md](SECURITY.md): how to report a problem in wrasse itself
|
|
126
|
+
|
|
127
|
+
## Tests
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
python -m unittest discover -s tests
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
111 tests, no network. `tests/corpus/vulnerable/` holds 53 planted rule/file pairs (62 findings) that must all be found; `tests/corpus/secure/` holds 17 samples that look wrong and are not.
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
MIT. Author and maintainer: Jiaming Shi.
|