pywrit 0.2.14__tar.gz → 0.2.16__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.
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pywrit
3
- Version: 0.2.14
3
+ Version: 0.2.16
4
4
  Summary: Python client + CLI for Writ — the gate before the write
5
5
  License-Expression: MIT
6
- Project-URL: Homepage, https://github.com/withwrit/pywrit
7
- Project-URL: Documentation, https://withwrit.com/docs
6
+ Project-URL: Homepage, https://withwrit.com
7
+ Project-URL: Documentation, https://docs.withwrit.com
8
8
  Requires-Python: >=3.9
9
9
  Description-Content-Type: text/markdown
10
10
  License-File: LICENSE
@@ -61,7 +61,7 @@ install test.
61
61
  | --- | --- | --- | --- |
62
62
  | Python | Yes | Yes, inserts `_writ_check` gates | Parsed with the stdlib `ast`, no extra needed |
63
63
  | TypeScript / JavaScript | Yes, with `pywrit[polyglot]` | No, scan only | Needs the extra: `pip install 'pywrit[polyglot]'`. Without it, the report says so loudly: a warning block names the unscanned files instead of reporting zero findings |
64
- | Go | Yes, with `pywrit[polyglot]` | No, scan only | First detection family only: database/sql Exec/ExecContext, GORM Create/Save/Update/Updates/Delete, HTTP client writes and http.NewRequest with a write method, generated-client <client>.<Resource>.<New\|Update\|Delete\|Create>; package-level generated clients not yet covered. Without the extra, the report names the unscanned Go files in the same warning block as TS/JS |
64
+ | Go | Yes, with `pywrit[polyglot]` | No, scan only | First detection family plus request-pipeline detection: database/sql Exec/ExecContext, GORM Create/Save/Update/Updates/Delete, HTTP client writes and http.NewRequest with a write method, generated-client <client>.<Resource>.<New\|Update\|Delete\|Create>, request-pipeline X.Call/X.RawRequest with a write method; package-level generated clients not yet covered. Without the extra, the report names the unscanned Go files in the same warning block as TS/JS |
65
65
 
66
66
  ## 60-second quickstart: scan → wrap → gate
67
67
 
@@ -191,7 +191,7 @@ pipeline (twilio-style generated clients, e.g. `twilio-node`).
191
191
 
192
192
  pip install 'pywrit[polyglot]'
193
193
 
194
- Covered in this first family: `database/sql` `Exec` / `ExecContext`, GORM `Create` / `Save` / `Update` / `Updates` / `Delete`, HTTP client `Post` / `Put` / `Patch` / `Delete` and `http.NewRequest` / `NewRequestWithContext` with a write method, and generated-client calls shaped `<client>.<Resource>.<New|Update|Delete|Create>` with an uppercase resource segment (the stripe-go shape). GET/HEAD requests, `db.Query` / `QueryRow`, and bare constructors are not flagged. `_test.go` files and `vendor/` trees are skipped. Go is **scan-only**: `writ scan --apply` never rewrites `.go` files, gate those by hand. Not yet covered: package-level generated clients (`charge.New(...)`, the pre-v87 stripe-go shape), request-pipeline calls with a variable method, and raw-SQL helpers.
194
+ Covered in this first family plus request-pipeline detection: `database/sql` `Exec` / `ExecContext`, GORM `Create` / `Save` / `Update` / `Updates` / `Delete`, HTTP client `Post` / `Put` / `Patch` / `Delete` and `http.NewRequest` / `NewRequestWithContext` with a write method, generated-client calls shaped `<client>.<Resource>.<New|Update|Delete|Create>` with an uppercase resource segment (the stripe-go shape), and request-pipeline calls `X.Call(method, ...)` / `X.RawRequest(method, ...)` where argument 0 is a write method (the `stripe.Backend` shape, e.g. `c.B.Call(http.MethodPost, "/v1/accounts", ...)`). GET/HEAD requests, `db.Query` / `QueryRow`, bare constructors, and pipeline calls with a variable method or a non-method first argument are not flagged. `_test.go` files and `vendor/` trees are skipped. Go is **scan-only**: `writ scan --apply` never rewrites `.go` files, gate those by hand. Not yet covered: package-level generated clients (`charge.New(...)`, the pre-v87 stripe-go shape), GORM raw-SQL helpers, and other Go write patterns.
195
195
 
196
196
  ## GitHub Action
197
197
 
@@ -38,7 +38,7 @@ install test.
38
38
  | --- | --- | --- | --- |
39
39
  | Python | Yes | Yes, inserts `_writ_check` gates | Parsed with the stdlib `ast`, no extra needed |
40
40
  | TypeScript / JavaScript | Yes, with `pywrit[polyglot]` | No, scan only | Needs the extra: `pip install 'pywrit[polyglot]'`. Without it, the report says so loudly: a warning block names the unscanned files instead of reporting zero findings |
41
- | Go | Yes, with `pywrit[polyglot]` | No, scan only | First detection family only: database/sql Exec/ExecContext, GORM Create/Save/Update/Updates/Delete, HTTP client writes and http.NewRequest with a write method, generated-client <client>.<Resource>.<New\|Update\|Delete\|Create>; package-level generated clients not yet covered. Without the extra, the report names the unscanned Go files in the same warning block as TS/JS |
41
+ | Go | Yes, with `pywrit[polyglot]` | No, scan only | First detection family plus request-pipeline detection: database/sql Exec/ExecContext, GORM Create/Save/Update/Updates/Delete, HTTP client writes and http.NewRequest with a write method, generated-client <client>.<Resource>.<New\|Update\|Delete\|Create>, request-pipeline X.Call/X.RawRequest with a write method; package-level generated clients not yet covered. Without the extra, the report names the unscanned Go files in the same warning block as TS/JS |
42
42
 
43
43
  ## 60-second quickstart: scan → wrap → gate
44
44
 
@@ -168,7 +168,7 @@ pipeline (twilio-style generated clients, e.g. `twilio-node`).
168
168
 
169
169
  pip install 'pywrit[polyglot]'
170
170
 
171
- Covered in this first family: `database/sql` `Exec` / `ExecContext`, GORM `Create` / `Save` / `Update` / `Updates` / `Delete`, HTTP client `Post` / `Put` / `Patch` / `Delete` and `http.NewRequest` / `NewRequestWithContext` with a write method, and generated-client calls shaped `<client>.<Resource>.<New|Update|Delete|Create>` with an uppercase resource segment (the stripe-go shape). GET/HEAD requests, `db.Query` / `QueryRow`, and bare constructors are not flagged. `_test.go` files and `vendor/` trees are skipped. Go is **scan-only**: `writ scan --apply` never rewrites `.go` files, gate those by hand. Not yet covered: package-level generated clients (`charge.New(...)`, the pre-v87 stripe-go shape), request-pipeline calls with a variable method, and raw-SQL helpers.
171
+ Covered in this first family plus request-pipeline detection: `database/sql` `Exec` / `ExecContext`, GORM `Create` / `Save` / `Update` / `Updates` / `Delete`, HTTP client `Post` / `Put` / `Patch` / `Delete` and `http.NewRequest` / `NewRequestWithContext` with a write method, generated-client calls shaped `<client>.<Resource>.<New|Update|Delete|Create>` with an uppercase resource segment (the stripe-go shape), and request-pipeline calls `X.Call(method, ...)` / `X.RawRequest(method, ...)` where argument 0 is a write method (the `stripe.Backend` shape, e.g. `c.B.Call(http.MethodPost, "/v1/accounts", ...)`). GET/HEAD requests, `db.Query` / `QueryRow`, bare constructors, and pipeline calls with a variable method or a non-method first argument are not flagged. `_test.go` files and `vendor/` trees are skipped. Go is **scan-only**: `writ scan --apply` never rewrites `.go` files, gate those by hand. Not yet covered: package-level generated clients (`charge.New(...)`, the pre-v87 stripe-go shape), GORM raw-SQL helpers, and other Go write patterns.
172
172
 
173
173
  ## GitHub Action
174
174
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pywrit"
7
- version = "0.2.14"
7
+ version = "0.2.16"
8
8
  description = "Python client + CLI for Writ — the gate before the write"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -23,8 +23,8 @@ polyglot = [
23
23
  keywords = ["ai-agents", "policy", "audit-log", "guardrails"]
24
24
 
25
25
  [project.urls]
26
- Homepage = "https://github.com/withwrit/pywrit"
27
- Documentation = "https://withwrit.com/docs"
26
+ Homepage = "https://withwrit.com"
27
+ Documentation = "https://docs.withwrit.com"
28
28
 
29
29
  [project.scripts]
30
30
  writ = "pywrit.cli:main"
@@ -27,7 +27,7 @@ from .errors import (
27
27
  WritError,
28
28
  )
29
29
 
30
- __version__ = "0.2.14"
30
+ __version__ = "0.2.16"
31
31
 
32
32
  __all__ = [
33
33
  "WritClient",
@@ -1452,6 +1452,13 @@ _GO_RESOURCE_METHODS = {"new", "update", "delete", "create"}
1452
1452
  # or ends in "db"/"tx" (db, tx, gormDB, dbtx, r.db, s.tx). Function roots
1453
1453
  # (createUser(...)) never qualify: "user" does not end in db/tx.
1454
1454
  _GO_HANDLE_RX = _re.compile(r"(db|tx)$")
1455
+ # Request-pipeline tails (slice 2): clients that route every call
1456
+ # through an internal pipeline method taking the HTTP method as
1457
+ # argument 0 (stripe-go: Backend.Call / RawRequest, so c.B.Call(
1458
+ # http.MethodPost, ...)). Argument 0 is graded by _go_write_method:
1459
+ # write methods (Post/Put/Patch/Delete string or http.MethodX
1460
+ # constant) fire, Get/Head and variables do not.
1461
+ _GO_PIPELINE_METHODS = {"call", "rawrequest"}
1455
1462
 
1456
1463
 
1457
1464
  class _GoFile:
@@ -1537,7 +1544,8 @@ def _go_write_method(call, f, idx):
1537
1544
 
1538
1545
 
1539
1546
  def _go_classify(call, chain, f, pkg_paths=None):
1540
- """First match wins; returns (rule_id, kind). Slice-1 family only.
1547
+ """First match wins; returns (rule_id, kind). Slice-1 family plus
1548
+ the slice-2 request-pipeline family (Call / RawRequest).
1541
1549
 
1542
1550
  `chain` is the raw (un-lowercased) callee chain. Handle receivers
1543
1551
  match by convention on any receiver segment (db, tx, gormDB, r.db,
@@ -1584,6 +1592,17 @@ def _go_classify(call, chain, f, pkg_paths=None):
1584
1592
  # pre-v87 shape (charge.New) is a later slice, not this
1585
1593
  # branch: two-segment chains never reach it.
1586
1594
  return "go-sdk-write", "sdk"
1595
+ if tail in _GO_PIPELINE_METHODS and len(norm) >= 2:
1596
+ # request pipeline: <recv>.Call / .RawRequest with a write
1597
+ # method as argument 0 (the stripe-go Backend shape:
1598
+ # c.B.Call(http.MethodPost, "/v1/accounts", ...)). The
1599
+ # arg-0 method check does the grading: http.MethodGet/Head is
1600
+ # a read, a variable or context first argument never matches,
1601
+ # and reflect.Value.Call (whose argument is a []Value) is
1602
+ # excluded the same way. No receiver check: the Call /
1603
+ # RawRequest tails collide with no other family.
1604
+ if _go_write_method(call, f, 0):
1605
+ return "go-pipeline-write", "http"
1587
1606
  return None
1588
1607
 
1589
1608
 
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pywrit
3
- Version: 0.2.14
3
+ Version: 0.2.16
4
4
  Summary: Python client + CLI for Writ — the gate before the write
5
5
  License-Expression: MIT
6
- Project-URL: Homepage, https://github.com/withwrit/pywrit
7
- Project-URL: Documentation, https://withwrit.com/docs
6
+ Project-URL: Homepage, https://withwrit.com
7
+ Project-URL: Documentation, https://docs.withwrit.com
8
8
  Requires-Python: >=3.9
9
9
  Description-Content-Type: text/markdown
10
10
  License-File: LICENSE
@@ -61,7 +61,7 @@ install test.
61
61
  | --- | --- | --- | --- |
62
62
  | Python | Yes | Yes, inserts `_writ_check` gates | Parsed with the stdlib `ast`, no extra needed |
63
63
  | TypeScript / JavaScript | Yes, with `pywrit[polyglot]` | No, scan only | Needs the extra: `pip install 'pywrit[polyglot]'`. Without it, the report says so loudly: a warning block names the unscanned files instead of reporting zero findings |
64
- | Go | Yes, with `pywrit[polyglot]` | No, scan only | First detection family only: database/sql Exec/ExecContext, GORM Create/Save/Update/Updates/Delete, HTTP client writes and http.NewRequest with a write method, generated-client <client>.<Resource>.<New\|Update\|Delete\|Create>; package-level generated clients not yet covered. Without the extra, the report names the unscanned Go files in the same warning block as TS/JS |
64
+ | Go | Yes, with `pywrit[polyglot]` | No, scan only | First detection family plus request-pipeline detection: database/sql Exec/ExecContext, GORM Create/Save/Update/Updates/Delete, HTTP client writes and http.NewRequest with a write method, generated-client <client>.<Resource>.<New\|Update\|Delete\|Create>, request-pipeline X.Call/X.RawRequest with a write method; package-level generated clients not yet covered. Without the extra, the report names the unscanned Go files in the same warning block as TS/JS |
65
65
 
66
66
  ## 60-second quickstart: scan → wrap → gate
67
67
 
@@ -191,7 +191,7 @@ pipeline (twilio-style generated clients, e.g. `twilio-node`).
191
191
 
192
192
  pip install 'pywrit[polyglot]'
193
193
 
194
- Covered in this first family: `database/sql` `Exec` / `ExecContext`, GORM `Create` / `Save` / `Update` / `Updates` / `Delete`, HTTP client `Post` / `Put` / `Patch` / `Delete` and `http.NewRequest` / `NewRequestWithContext` with a write method, and generated-client calls shaped `<client>.<Resource>.<New|Update|Delete|Create>` with an uppercase resource segment (the stripe-go shape). GET/HEAD requests, `db.Query` / `QueryRow`, and bare constructors are not flagged. `_test.go` files and `vendor/` trees are skipped. Go is **scan-only**: `writ scan --apply` never rewrites `.go` files, gate those by hand. Not yet covered: package-level generated clients (`charge.New(...)`, the pre-v87 stripe-go shape), request-pipeline calls with a variable method, and raw-SQL helpers.
194
+ Covered in this first family plus request-pipeline detection: `database/sql` `Exec` / `ExecContext`, GORM `Create` / `Save` / `Update` / `Updates` / `Delete`, HTTP client `Post` / `Put` / `Patch` / `Delete` and `http.NewRequest` / `NewRequestWithContext` with a write method, generated-client calls shaped `<client>.<Resource>.<New|Update|Delete|Create>` with an uppercase resource segment (the stripe-go shape), and request-pipeline calls `X.Call(method, ...)` / `X.RawRequest(method, ...)` where argument 0 is a write method (the `stripe.Backend` shape, e.g. `c.B.Call(http.MethodPost, "/v1/accounts", ...)`). GET/HEAD requests, `db.Query` / `QueryRow`, bare constructors, and pipeline calls with a variable method or a non-method first argument are not flagged. `_test.go` files and `vendor/` trees are skipped. Go is **scan-only**: `writ scan --apply` never rewrites `.go` files, gate those by hand. Not yet covered: package-level generated clients (`charge.New(...)`, the pre-v87 stripe-go shape), GORM raw-SQL helpers, and other Go write patterns.
195
195
 
196
196
  ## GitHub Action
197
197
 
@@ -30,7 +30,7 @@ HAVE_EXTRA = bool(cli._go_parsers())
30
30
  _BLOCK_EXTRA = {m: None for m in ("tree_sitter", "tree_sitter_go",
31
31
  "tree_sitter_language_pack")}
32
32
  _GO_RULES = {"go-db-write", "go-orm-write", "go-http-client-write",
33
- "go-http-request-write", "go-sdk-write"}
33
+ "go-http-request-write", "go-sdk-write", "go-pipeline-write"}
34
34
  _EXPECT = re.compile(r"//\s*expect:\s*([a-z0-9-]+)")
35
35
  _FINDING = re.compile(
36
36
  r"^ (?P<file>\S+\.go):(?P<line>\d+) \[(?P<kind>[a-z]+)\] "
@@ -112,8 +112,8 @@ class FixtureRulesTest(unittest.TestCase):
112
112
  verbs = __import__("json").loads(policy.read_text())
113
113
  self.assertEqual(code, 0)
114
114
  n = len(_expected())
115
- self.assertIn("go files scanned: 5 skipped: 0 (scan only, no --apply)", out)
116
- self.assertIn("go write sites: %d in 6 function(s)" % n, out)
115
+ self.assertIn("go files scanned: 6 skipped: 0 (scan only, no --apply)", out)
116
+ self.assertIn("go write sites: %d in 7 function(s)" % n, out)
117
117
  self.assertIn("go gated: 0/%d (0%%)" % n, out)
118
118
  self.assertIn(" db.go:13 [db] go-db-write deleteOrder(): "
119
119
  "db.Exec(\"DELETE FROM orders WHERE id = $1\", id)", out)
@@ -311,7 +311,7 @@ class JsonReportTest(unittest.TestCase):
311
311
  self.assertEqual(code, 0, out)
312
312
  doc = j.loads(out)
313
313
  self.assertFalse(doc["go_hint"])
314
- self.assertEqual(doc["files_scanned"], 5)
314
+ self.assertEqual(doc["files_scanned"], 6)
315
315
  go_findings = [f for f in doc["findings"]
316
316
  if f["language"] == "go"]
317
317
  self.assertEqual(len(go_findings), len(_expected()), doc)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes