pywrit 0.2.9__tar.gz → 0.2.10__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.
- {pywrit-0.2.9/src/pywrit.egg-info → pywrit-0.2.10}/PKG-INFO +20 -5
- {pywrit-0.2.9 → pywrit-0.2.10}/README.md +19 -4
- {pywrit-0.2.9 → pywrit-0.2.10}/pyproject.toml +1 -1
- {pywrit-0.2.9 → pywrit-0.2.10}/src/pywrit/__init__.py +1 -1
- {pywrit-0.2.9 → pywrit-0.2.10}/src/pywrit/cli.py +105 -7
- {pywrit-0.2.9 → pywrit-0.2.10/src/pywrit.egg-info}/PKG-INFO +20 -5
- {pywrit-0.2.9 → pywrit-0.2.10}/tests/test_scan_tsjs.py +43 -0
- {pywrit-0.2.9 → pywrit-0.2.10}/LICENSE +0 -0
- {pywrit-0.2.9 → pywrit-0.2.10}/setup.cfg +0 -0
- {pywrit-0.2.9 → pywrit-0.2.10}/src/pywrit/client.py +0 -0
- {pywrit-0.2.9 → pywrit-0.2.10}/src/pywrit/errors.py +0 -0
- {pywrit-0.2.9 → pywrit-0.2.10}/src/pywrit.egg-info/SOURCES.txt +0 -0
- {pywrit-0.2.9 → pywrit-0.2.10}/src/pywrit.egg-info/dependency_links.txt +0 -0
- {pywrit-0.2.9 → pywrit-0.2.10}/src/pywrit.egg-info/entry_points.txt +0 -0
- {pywrit-0.2.9 → pywrit-0.2.10}/src/pywrit.egg-info/requires.txt +0 -0
- {pywrit-0.2.9 → pywrit-0.2.10}/src/pywrit.egg-info/top_level.txt +0 -0
- {pywrit-0.2.9 → pywrit-0.2.10}/tests/test_client.py +0 -0
- {pywrit-0.2.9 → pywrit-0.2.10}/tests/test_scan_json.py +0 -0
- {pywrit-0.2.9 → pywrit-0.2.10}/tests/test_scan_python.py +0 -0
- {pywrit-0.2.9 → pywrit-0.2.10}/tests/test_wrap.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pywrit
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.10
|
|
4
4
|
Summary: Python client + CLI for Writ — the gate before the write
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Project-URL: Homepage, https://github.com/withwrit/pywrit
|
|
@@ -151,6 +151,12 @@ optional extra (tree-sitter based):
|
|
|
151
151
|
Without the extra, the scanner prints a one-line hint and keeps going —
|
|
152
152
|
Python scanning never needs it.
|
|
153
153
|
|
|
154
|
+
Findings from non-product paths (docs/, scripts/, sandbox/, examples/,
|
|
155
|
+
benchmark/, demo/, and build-tooling files such as gulpfile.js or
|
|
156
|
+
webpack.config.*) are suppressed by default: the report counts them per
|
|
157
|
+
class and names every suppressed path instead of listing them as findings.
|
|
158
|
+
Pass `--include-non-product` to report them like any other finding.
|
|
159
|
+
|
|
154
160
|
TS/JS is **scan-only**: findings are listed with verbs for your policy file,
|
|
155
161
|
but `writ scan --apply` never rewrites TS/JS files — gate those by hand.
|
|
156
162
|
Covered patterns: `fetch`/`axios` writes, `fs` writes, SQL through knex-style
|
|
@@ -183,16 +189,17 @@ example workflow: [examples/github-action/writ-scan.yml](examples/github-action/
|
|
|
183
189
|
|
|
184
190
|
## GitHub App
|
|
185
191
|
|
|
186
|
-
Install the [Writ GitHub App](https://
|
|
192
|
+
Install the [Writ GitHub App](https://github.com/apps/writ-scanner) on selected
|
|
187
193
|
repositories: every push and pull request is scanned for ungated write-sites,
|
|
188
194
|
with results as a check run on the PR and in the
|
|
189
195
|
[portal](https://app.withwrit.com), where you manage policy, keys, and the audit log.
|
|
196
|
+
Setup and data handling: [GitHub App docs](https://docs.withwrit.com/git-hub-app).
|
|
190
197
|
|
|
191
198
|
## MCP server (`writ-mcp`)
|
|
192
199
|
|
|
193
200
|
Give any MCP-compatible agent point-of-action policy checks. `writ-mcp` is a
|
|
194
201
|
[Model Context Protocol](https://modelcontextprotocol.io) server (stdio transport,
|
|
195
|
-
built on the MCP Python SDK) that exposes the Writ gate as **
|
|
202
|
+
built on the MCP Python SDK) that exposes the Writ gate as **17 MCP tools**:
|
|
196
203
|
the agent calls `writ_check` before a consequential write and gets back `ALLOW`,
|
|
197
204
|
`DENY`, or `STEP_UP` — with a tamper-evident, hash-chained audit receipt for
|
|
198
205
|
every decision.
|
|
@@ -212,13 +219,21 @@ pip install writ-mcp # then run `writ-mcp`
|
|
|
212
219
|
| `writ_receipts` | Read the tenant's audit log |
|
|
213
220
|
| `writ_policy` | Manage the verb policy |
|
|
214
221
|
| `writ_sandbox` | Keyless 90-second demo grant — no API key needed |
|
|
222
|
+
| `writ_github_installations` | List connected GitHub App installations |
|
|
223
|
+
| `writ_github_set_threshold` | Set the check-run fail threshold per install |
|
|
224
|
+
| `writ_github_toggle_pr_comments` | Enable/disable the PR-comment bot |
|
|
225
|
+
| `writ_manifests` | List repos with risk profiles or fetch one manifest |
|
|
226
|
+
| `writ_explain_receipt` | Explain a receipt in plain language |
|
|
227
|
+
| `writ_tenant_notify` | Get or update step-up notification settings |
|
|
228
|
+
| `writ_principals` | List the tenant's principals |
|
|
229
|
+
| `writ_verbs` | List the tenant's verb vocabulary |
|
|
230
|
+
| `writ_keys` | List API key metadata |
|
|
215
231
|
|
|
216
232
|
The gate tools need a free Writ API key (`WRIT_API_KEY`): 10,000 receipts/month
|
|
217
233
|
free, no credit card. `writ_sandbox` works with no key at all.
|
|
218
234
|
|
|
219
235
|
The server implementation lives in [`mcp/`](mcp/) (MIT). Also published on the
|
|
220
|
-
official MCP Registry as `io.github.withwrit/writ
|
|
221
|
-
[Smithery](https://smithery.ai/server/withwrit/writ-mcp), and listed on
|
|
236
|
+
official MCP Registry as `io.github.withwrit/writ` and listed on
|
|
222
237
|
[Glama](https://glama.ai/mcp/servers/withwrit/pywrit).
|
|
223
238
|
|
|
224
239
|
## Python client
|
|
@@ -129,6 +129,12 @@ optional extra (tree-sitter based):
|
|
|
129
129
|
Without the extra, the scanner prints a one-line hint and keeps going —
|
|
130
130
|
Python scanning never needs it.
|
|
131
131
|
|
|
132
|
+
Findings from non-product paths (docs/, scripts/, sandbox/, examples/,
|
|
133
|
+
benchmark/, demo/, and build-tooling files such as gulpfile.js or
|
|
134
|
+
webpack.config.*) are suppressed by default: the report counts them per
|
|
135
|
+
class and names every suppressed path instead of listing them as findings.
|
|
136
|
+
Pass `--include-non-product` to report them like any other finding.
|
|
137
|
+
|
|
132
138
|
TS/JS is **scan-only**: findings are listed with verbs for your policy file,
|
|
133
139
|
but `writ scan --apply` never rewrites TS/JS files — gate those by hand.
|
|
134
140
|
Covered patterns: `fetch`/`axios` writes, `fs` writes, SQL through knex-style
|
|
@@ -161,16 +167,17 @@ example workflow: [examples/github-action/writ-scan.yml](examples/github-action/
|
|
|
161
167
|
|
|
162
168
|
## GitHub App
|
|
163
169
|
|
|
164
|
-
Install the [Writ GitHub App](https://
|
|
170
|
+
Install the [Writ GitHub App](https://github.com/apps/writ-scanner) on selected
|
|
165
171
|
repositories: every push and pull request is scanned for ungated write-sites,
|
|
166
172
|
with results as a check run on the PR and in the
|
|
167
173
|
[portal](https://app.withwrit.com), where you manage policy, keys, and the audit log.
|
|
174
|
+
Setup and data handling: [GitHub App docs](https://docs.withwrit.com/git-hub-app).
|
|
168
175
|
|
|
169
176
|
## MCP server (`writ-mcp`)
|
|
170
177
|
|
|
171
178
|
Give any MCP-compatible agent point-of-action policy checks. `writ-mcp` is a
|
|
172
179
|
[Model Context Protocol](https://modelcontextprotocol.io) server (stdio transport,
|
|
173
|
-
built on the MCP Python SDK) that exposes the Writ gate as **
|
|
180
|
+
built on the MCP Python SDK) that exposes the Writ gate as **17 MCP tools**:
|
|
174
181
|
the agent calls `writ_check` before a consequential write and gets back `ALLOW`,
|
|
175
182
|
`DENY`, or `STEP_UP` — with a tamper-evident, hash-chained audit receipt for
|
|
176
183
|
every decision.
|
|
@@ -190,13 +197,21 @@ pip install writ-mcp # then run `writ-mcp`
|
|
|
190
197
|
| `writ_receipts` | Read the tenant's audit log |
|
|
191
198
|
| `writ_policy` | Manage the verb policy |
|
|
192
199
|
| `writ_sandbox` | Keyless 90-second demo grant — no API key needed |
|
|
200
|
+
| `writ_github_installations` | List connected GitHub App installations |
|
|
201
|
+
| `writ_github_set_threshold` | Set the check-run fail threshold per install |
|
|
202
|
+
| `writ_github_toggle_pr_comments` | Enable/disable the PR-comment bot |
|
|
203
|
+
| `writ_manifests` | List repos with risk profiles or fetch one manifest |
|
|
204
|
+
| `writ_explain_receipt` | Explain a receipt in plain language |
|
|
205
|
+
| `writ_tenant_notify` | Get or update step-up notification settings |
|
|
206
|
+
| `writ_principals` | List the tenant's principals |
|
|
207
|
+
| `writ_verbs` | List the tenant's verb vocabulary |
|
|
208
|
+
| `writ_keys` | List API key metadata |
|
|
193
209
|
|
|
194
210
|
The gate tools need a free Writ API key (`WRIT_API_KEY`): 10,000 receipts/month
|
|
195
211
|
free, no credit card. `writ_sandbox` works with no key at all.
|
|
196
212
|
|
|
197
213
|
The server implementation lives in [`mcp/`](mcp/) (MIT). Also published on the
|
|
198
|
-
official MCP Registry as `io.github.withwrit/writ
|
|
199
|
-
[Smithery](https://smithery.ai/server/withwrit/writ-mcp), and listed on
|
|
214
|
+
official MCP Registry as `io.github.withwrit/writ` and listed on
|
|
200
215
|
[Glama](https://glama.ai/mcp/servers/withwrit/pywrit).
|
|
201
216
|
|
|
202
217
|
## Python client
|
|
@@ -826,6 +826,54 @@ _TSJS_EXTS = {".ts": "typescript", ".tsx": "tsx", ".js": "javascript",
|
|
|
826
826
|
_TSJS_SKIP_DIR_NAMES = _SKIP_DIR_NAMES | {".next", "vendor", "venv", ".venv"}
|
|
827
827
|
_TSJS_TEST_DIRS = {"tests", "testing", "__tests__"}
|
|
828
828
|
_TSJS_MAX_BYTES = 1000000 # larger files are almost always bundles
|
|
829
|
+
|
|
830
|
+
# Non-product path classes. Write findings from these paths parse as real
|
|
831
|
+
# writes but are almost never product behavior — docs tooling, build/test
|
|
832
|
+
# scripts, demos, benchmarks (the axios-class scan noise: gulpfile.js,
|
|
833
|
+
# docs/scripts/*, sandbox/*, scripts/benchmark-*). They are suppressed from
|
|
834
|
+
# the report by default — counted per class under "suppressed" — and
|
|
835
|
+
# restored with --include-non-product. Matching is by whole directory
|
|
836
|
+
# segment or exact build-file basename, never filename substring, so
|
|
837
|
+
# product code next to an excluded directory (and files like
|
|
838
|
+
# lib/benchmark-utils.ts) stays reported. This is the single, central
|
|
839
|
+
# exclusion list for TS/JS; don't scatter string matches elsewhere.
|
|
840
|
+
_TSJS_NON_PRODUCT_DIRS = {
|
|
841
|
+
"docs": {"docs", "doc"},
|
|
842
|
+
"scripts": {"scripts"},
|
|
843
|
+
"examples": {"examples", "example"},
|
|
844
|
+
"sandbox": {"sandbox"},
|
|
845
|
+
"benchmark": {"benchmark", "benchmarks"},
|
|
846
|
+
"demo": {"demo", "demos"},
|
|
847
|
+
}
|
|
848
|
+
_TSJS_BUILD_TOOL_FILE = _re.compile(
|
|
849
|
+
r"^(gulpfile|gruntfile)(\.babel)?\.(js|mjs|cjs|ts)$"
|
|
850
|
+
r"|^(webpack|rollup|vite|esbuild|tsup|snowpack|babel)\.config\.(js|mjs|cjs|ts)$"
|
|
851
|
+
r"|^karma\.conf\.(js|mjs|cjs|ts)$", _re.I)
|
|
852
|
+
|
|
853
|
+
|
|
854
|
+
def _tsjs_non_product_class(path, root):
|
|
855
|
+
"""Return the non-product path class for a TS/JS file, or None.
|
|
856
|
+
|
|
857
|
+
Directory classes match on whole path segments (docs/, scripts/,
|
|
858
|
+
sandbox/, examples/, benchmark/, demo/ at any depth), so a product
|
|
859
|
+
file beside an excluded directory is unaffected. Build-tooling files
|
|
860
|
+
(gulpfile.js, Gruntfile.js, webpack.config.*, rollup.config.*,
|
|
861
|
+
vite.config.*, and equivalents) match by exact basename anywhere in
|
|
862
|
+
the tree so monorepo package configs are covered too.
|
|
863
|
+
"""
|
|
864
|
+
rel = path.relative_to(root)
|
|
865
|
+
segs = set(rel.parts[:-1])
|
|
866
|
+
for cls, names in _TSJS_NON_PRODUCT_DIRS.items():
|
|
867
|
+
if segs & names:
|
|
868
|
+
return cls
|
|
869
|
+
if _TSJS_BUILD_TOOL_FILE.match(path.name):
|
|
870
|
+
return "build-tooling"
|
|
871
|
+
return None
|
|
872
|
+
|
|
873
|
+
|
|
874
|
+
def _tsjs_suppressed_total(suppressed):
|
|
875
|
+
"""Total suppressed sites across all non-product classes."""
|
|
876
|
+
return sum(b["sites"] for b in (suppressed or {}).values())
|
|
829
877
|
_TSJS_HINT = ("hint: %d TS/JS file(s) not scanned; install the extra: "
|
|
830
878
|
"pip install 'pywrit[polyglot]'")
|
|
831
879
|
_TSJS_WRITE_METHODS = {"post", "put", "patch", "delete"}
|
|
@@ -1289,12 +1337,17 @@ def _tsjs_verb(rel, func_name, cls_name, kind):
|
|
|
1289
1337
|
return infer_verb(base, snake, cls_name, kind)
|
|
1290
1338
|
|
|
1291
1339
|
|
|
1292
|
-
def _tsjs_scan(root, excludes):
|
|
1293
|
-
"""Return dict with files, skipped, sites, gated, or hint
|
|
1294
|
-
extra is missing. Never raises on a bad file.
|
|
1340
|
+
def _tsjs_scan(root, excludes, include_non_product=False):
|
|
1341
|
+
"""Return dict with files, skipped, sites, gated, suppressed, or hint
|
|
1342
|
+
when the extra is missing. Never raises on a bad file.
|
|
1343
|
+
|
|
1344
|
+
Findings from non-product paths (_tsjs_non_product_class) are not
|
|
1345
|
+
dropped — they are counted per path class in res["suppressed"] so the
|
|
1346
|
+
report can say exactly what was held back. include_non_product restores
|
|
1347
|
+
the old behavior of reporting every site."""
|
|
1295
1348
|
files = _tsjs_collect_files(root, excludes)
|
|
1296
1349
|
res = {"files": files, "skipped": [], "sites": [], "gated": set(),
|
|
1297
|
-
"missing_extra": False}
|
|
1350
|
+
"suppressed": {}, "missing_extra": False}
|
|
1298
1351
|
if not files:
|
|
1299
1352
|
return res
|
|
1300
1353
|
parsers = _tsjs_parsers()
|
|
@@ -1312,6 +1365,14 @@ def _tsjs_scan(root, excludes):
|
|
|
1312
1365
|
except Exception:
|
|
1313
1366
|
res["skipped"].append(str(path))
|
|
1314
1367
|
continue
|
|
1368
|
+
cls = None if include_non_product \
|
|
1369
|
+
else _tsjs_non_product_class(path, root)
|
|
1370
|
+
if cls is not None and sites:
|
|
1371
|
+
bucket = res["suppressed"].setdefault(
|
|
1372
|
+
cls, {"sites": 0, "files": {}})
|
|
1373
|
+
bucket["sites"] += len(sites)
|
|
1374
|
+
bucket["files"][str(path)] = len(sites)
|
|
1375
|
+
continue
|
|
1315
1376
|
res["sites"].extend(sites)
|
|
1316
1377
|
res["gated"].update((str(path),) + g for g in gated)
|
|
1317
1378
|
return res
|
|
@@ -1375,10 +1436,24 @@ def print_scan_json(root, files, skipped, sites, gated_funcs, tsjs, ts_sites):
|
|
|
1375
1436
|
"findings": _scan_findings_json(root, sites, gated_funcs, tsjs,
|
|
1376
1437
|
ts_sites),
|
|
1377
1438
|
}
|
|
1439
|
+
ts_suppressed = tsjs.get("suppressed") or {}
|
|
1440
|
+
ts_sup_total = _tsjs_suppressed_total(ts_suppressed)
|
|
1441
|
+
if ts_sup_total:
|
|
1442
|
+
# Non-product findings held back by default: never dropped
|
|
1443
|
+
# silently — the report names every suppressed path.
|
|
1444
|
+
doc["tsjs_suppressed_non_product"] = {
|
|
1445
|
+
"sites": ts_sup_total,
|
|
1446
|
+
"by_class": {c: ts_suppressed[c]["sites"]
|
|
1447
|
+
for c in sorted(ts_suppressed)},
|
|
1448
|
+
"files": sorted(
|
|
1449
|
+
str(_pathlib.Path(f).relative_to(root))
|
|
1450
|
+
for c in ts_suppressed.values()
|
|
1451
|
+
for f in c["files"]),
|
|
1452
|
+
}
|
|
1378
1453
|
print(json.dumps(doc, indent=2))
|
|
1379
1454
|
|
|
1380
1455
|
|
|
1381
|
-
def _scan_repo(root, excludes):
|
|
1456
|
+
def _scan_repo(root, excludes, include_non_product=False):
|
|
1382
1457
|
"""Collect Python and TS/JS files and find write sites.
|
|
1383
1458
|
|
|
1384
1459
|
Returns (files, skipped, sites, gated, tsjs). This is the read-only
|
|
@@ -1402,7 +1477,8 @@ def _scan_repo(root, excludes):
|
|
|
1402
1477
|
sites.extend(v.sites)
|
|
1403
1478
|
gated.update((str(path), n, ln) for (n, ln) in v.gated)
|
|
1404
1479
|
|
|
1405
|
-
tsjs = _tsjs_scan(root, excludes or []
|
|
1480
|
+
tsjs = _tsjs_scan(root, excludes or [],
|
|
1481
|
+
include_non_product=include_non_product)
|
|
1406
1482
|
return files, skipped, sites, gated, tsjs
|
|
1407
1483
|
|
|
1408
1484
|
|
|
@@ -1516,7 +1592,9 @@ def scan_cmd(args):
|
|
|
1516
1592
|
print("error: not a directory: %s" % args.path, file=sys.stderr)
|
|
1517
1593
|
return 2
|
|
1518
1594
|
|
|
1519
|
-
files, skipped, sites, gated, tsjs = _scan_repo(
|
|
1595
|
+
files, skipped, sites, gated, tsjs = _scan_repo(
|
|
1596
|
+
root, args.exclude or [],
|
|
1597
|
+
include_non_product=getattr(args, "include_non_product", False))
|
|
1520
1598
|
analysis = _analyze_scan(root, files, skipped, sites, gated, tsjs)
|
|
1521
1599
|
by_func = analysis["by_func"]
|
|
1522
1600
|
ts_by_func = analysis["ts_by_func"]
|
|
@@ -1560,6 +1638,19 @@ def scan_cmd(args):
|
|
|
1560
1638
|
print(" %s:%d [%s] %s %s(): %s" % (
|
|
1561
1639
|
_pathlib.Path(s.file).relative_to(root), s.lineno, s.kind,
|
|
1562
1640
|
rid, s.func or "<module>", s.snippet))
|
|
1641
|
+
suppressed = tsjs.get("suppressed") or {}
|
|
1642
|
+
sup_total = _tsjs_suppressed_total(suppressed)
|
|
1643
|
+
if sup_total:
|
|
1644
|
+
by_class = ", ".join("%s: %d" % (c, suppressed[c]["sites"])
|
|
1645
|
+
for c in sorted(suppressed))
|
|
1646
|
+
print(" ts/js non-product: %d site(s) suppressed (%s); "
|
|
1647
|
+
"re-run with --include-non-product to show them"
|
|
1648
|
+
% (sup_total, by_class))
|
|
1649
|
+
for cls in sorted(suppressed):
|
|
1650
|
+
for f in sorted(suppressed[cls]["files"]):
|
|
1651
|
+
print(" suppressed %s: %d site(s) [%s]" % (
|
|
1652
|
+
_pathlib.Path(f).relative_to(root),
|
|
1653
|
+
suppressed[cls]["files"][f], cls))
|
|
1563
1654
|
if verbs:
|
|
1564
1655
|
print(" verbs discovered: %d" % len(verbs))
|
|
1565
1656
|
for vname in sorted(verbs):
|
|
@@ -2138,6 +2229,13 @@ def main():
|
|
|
2138
2229
|
help="Output format: human-readable text (default) or "
|
|
2139
2230
|
"machine-readable JSON risk report (read-only; no "
|
|
2140
2231
|
"policy file, no diffs)")
|
|
2232
|
+
scan.add_argument("--include-non-product", action="store_true",
|
|
2233
|
+
help="Include TS/JS findings from non-product paths that the "
|
|
2234
|
+
"scan suppresses by default: docs/, scripts/, sandbox/, "
|
|
2235
|
+
"examples/, benchmark/, demo/ directories and "
|
|
2236
|
+
"build-tooling files (gulpfile.js, webpack.config.*, "
|
|
2237
|
+
"rollup.config.*, vite.config.*, ...). Suppressed sites "
|
|
2238
|
+
"are always reported as a per-class count.")
|
|
2141
2239
|
scan.add_argument("--push-policy", action="store_true",
|
|
2142
2240
|
help="PUT the discovered policy to the gate (needs --key)")
|
|
2143
2241
|
scan.add_argument("--key", default="",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pywrit
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.10
|
|
4
4
|
Summary: Python client + CLI for Writ — the gate before the write
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Project-URL: Homepage, https://github.com/withwrit/pywrit
|
|
@@ -151,6 +151,12 @@ optional extra (tree-sitter based):
|
|
|
151
151
|
Without the extra, the scanner prints a one-line hint and keeps going —
|
|
152
152
|
Python scanning never needs it.
|
|
153
153
|
|
|
154
|
+
Findings from non-product paths (docs/, scripts/, sandbox/, examples/,
|
|
155
|
+
benchmark/, demo/, and build-tooling files such as gulpfile.js or
|
|
156
|
+
webpack.config.*) are suppressed by default: the report counts them per
|
|
157
|
+
class and names every suppressed path instead of listing them as findings.
|
|
158
|
+
Pass `--include-non-product` to report them like any other finding.
|
|
159
|
+
|
|
154
160
|
TS/JS is **scan-only**: findings are listed with verbs for your policy file,
|
|
155
161
|
but `writ scan --apply` never rewrites TS/JS files — gate those by hand.
|
|
156
162
|
Covered patterns: `fetch`/`axios` writes, `fs` writes, SQL through knex-style
|
|
@@ -183,16 +189,17 @@ example workflow: [examples/github-action/writ-scan.yml](examples/github-action/
|
|
|
183
189
|
|
|
184
190
|
## GitHub App
|
|
185
191
|
|
|
186
|
-
Install the [Writ GitHub App](https://
|
|
192
|
+
Install the [Writ GitHub App](https://github.com/apps/writ-scanner) on selected
|
|
187
193
|
repositories: every push and pull request is scanned for ungated write-sites,
|
|
188
194
|
with results as a check run on the PR and in the
|
|
189
195
|
[portal](https://app.withwrit.com), where you manage policy, keys, and the audit log.
|
|
196
|
+
Setup and data handling: [GitHub App docs](https://docs.withwrit.com/git-hub-app).
|
|
190
197
|
|
|
191
198
|
## MCP server (`writ-mcp`)
|
|
192
199
|
|
|
193
200
|
Give any MCP-compatible agent point-of-action policy checks. `writ-mcp` is a
|
|
194
201
|
[Model Context Protocol](https://modelcontextprotocol.io) server (stdio transport,
|
|
195
|
-
built on the MCP Python SDK) that exposes the Writ gate as **
|
|
202
|
+
built on the MCP Python SDK) that exposes the Writ gate as **17 MCP tools**:
|
|
196
203
|
the agent calls `writ_check` before a consequential write and gets back `ALLOW`,
|
|
197
204
|
`DENY`, or `STEP_UP` — with a tamper-evident, hash-chained audit receipt for
|
|
198
205
|
every decision.
|
|
@@ -212,13 +219,21 @@ pip install writ-mcp # then run `writ-mcp`
|
|
|
212
219
|
| `writ_receipts` | Read the tenant's audit log |
|
|
213
220
|
| `writ_policy` | Manage the verb policy |
|
|
214
221
|
| `writ_sandbox` | Keyless 90-second demo grant — no API key needed |
|
|
222
|
+
| `writ_github_installations` | List connected GitHub App installations |
|
|
223
|
+
| `writ_github_set_threshold` | Set the check-run fail threshold per install |
|
|
224
|
+
| `writ_github_toggle_pr_comments` | Enable/disable the PR-comment bot |
|
|
225
|
+
| `writ_manifests` | List repos with risk profiles or fetch one manifest |
|
|
226
|
+
| `writ_explain_receipt` | Explain a receipt in plain language |
|
|
227
|
+
| `writ_tenant_notify` | Get or update step-up notification settings |
|
|
228
|
+
| `writ_principals` | List the tenant's principals |
|
|
229
|
+
| `writ_verbs` | List the tenant's verb vocabulary |
|
|
230
|
+
| `writ_keys` | List API key metadata |
|
|
215
231
|
|
|
216
232
|
The gate tools need a free Writ API key (`WRIT_API_KEY`): 10,000 receipts/month
|
|
217
233
|
free, no credit card. `writ_sandbox` works with no key at all.
|
|
218
234
|
|
|
219
235
|
The server implementation lives in [`mcp/`](mcp/) (MIT). Also published on the
|
|
220
|
-
official MCP Registry as `io.github.withwrit/writ
|
|
221
|
-
[Smithery](https://smithery.ai/server/withwrit/writ-mcp), and listed on
|
|
236
|
+
official MCP Registry as `io.github.withwrit/writ` and listed on
|
|
222
237
|
[Glama](https://glama.ai/mcp/servers/withwrit/pywrit).
|
|
223
238
|
|
|
224
239
|
## Python client
|
|
@@ -337,6 +337,49 @@ class MissingExtraTest(unittest.TestCase):
|
|
|
337
337
|
" orders.create\n" % root.resolve()), out)
|
|
338
338
|
|
|
339
339
|
|
|
340
|
+
class NonProductScanTest(unittest.TestCase):
|
|
341
|
+
"""Axios-class noise: non-product paths are suppressed by default,
|
|
342
|
+
counted per class with paths named, and restored by the flag."""
|
|
343
|
+
|
|
344
|
+
WRITE = 'fetch("https://api.example.com/x", {method: "POST"})\n'
|
|
345
|
+
|
|
346
|
+
def _layout(self, root):
|
|
347
|
+
(root / "lib").mkdir(parents=True)
|
|
348
|
+
(root / "lib" / "core.js").write_text(self.WRITE)
|
|
349
|
+
for d in ("docs/scripts", "scripts", "sandbox", "examples"):
|
|
350
|
+
p = root / d
|
|
351
|
+
p.mkdir(parents=True)
|
|
352
|
+
(p / "tool.js").write_text(self.WRITE)
|
|
353
|
+
(root / "gulpfile.js").write_text(self.WRITE)
|
|
354
|
+
(root / "lib" / "benchmark-utils.ts").write_text(self.WRITE)
|
|
355
|
+
|
|
356
|
+
@unittest.skipUnless(HAVE_EXTRA, "polyglot extra not installed")
|
|
357
|
+
def test_suppressed_by_default_and_restored_by_flag(self):
|
|
358
|
+
with tempfile.TemporaryDirectory() as td:
|
|
359
|
+
root = pathlib.Path(td)
|
|
360
|
+
self._layout(root)
|
|
361
|
+
res = cli._tsjs_scan(root, [])
|
|
362
|
+
self.assertEqual(len(res["sites"]), 2) # lib/core.js + benchmark-utils.ts
|
|
363
|
+
total = cli._tsjs_suppressed_total(res["suppressed"])
|
|
364
|
+
self.assertEqual(total, 5)
|
|
365
|
+
res2 = cli._tsjs_scan(root, [], include_non_product=True)
|
|
366
|
+
self.assertEqual(len(res2["sites"]), 7)
|
|
367
|
+
self.assertEqual(res2["suppressed"], {})
|
|
368
|
+
|
|
369
|
+
def test_path_class_units(self):
|
|
370
|
+
root = pathlib.Path("/repo")
|
|
371
|
+
self.assertEqual(
|
|
372
|
+
cli._tsjs_non_product_class(root / "docs" / "a.js", root), "docs")
|
|
373
|
+
self.assertEqual(
|
|
374
|
+
cli._tsjs_non_product_class(root / "gulpfile.js", root),
|
|
375
|
+
"build-tooling")
|
|
376
|
+
self.assertIsNone(
|
|
377
|
+
cli._tsjs_non_product_class(root / "lib" / "benchmark-utils.ts",
|
|
378
|
+
root))
|
|
379
|
+
self.assertIsNone(
|
|
380
|
+
cli._tsjs_non_product_class(root / "lib" / "core.js", root))
|
|
381
|
+
|
|
382
|
+
|
|
340
383
|
class CliSyncTest(unittest.TestCase):
|
|
341
384
|
def test_download_copy_is_byte_identical(self):
|
|
342
385
|
web = HERE.parent.parent / "gate" / "web" / "writ"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|