@timidan/rite 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rite Contributors
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.
package/README.md ADDED
@@ -0,0 +1,195 @@
1
+ # Rite
2
+
3
+ **Authorization checks for the paths ordinary tests miss.**
4
+
5
+ Rite turns an authorization rule and an explicit map of sensitive entry paths
6
+ into black-box behavior checks. It records what the system actually did, so a
7
+ failure is evidence of an unauthorized effect—not merely a crash, static
8
+ warning, or unexercised branch.
9
+
10
+ This repository is a working prototype built for the IBM Bob 2.0 Hackathon. The
11
+ included demonstration covers two paths through a synthetic refund service; it
12
+ does not claim exhaustive analysis of arbitrary repositories.
13
+
14
+ ## The problem Rite demonstrates
15
+
16
+ Both callers below reach the same refund sink, but the original support path
17
+ skipped the ownership check:
18
+
19
+ ```text
20
+ customerRefund ─┐
21
+ ├─ authorizeAndRefund ── issueRefund
22
+ supportRefund ─┘
23
+ ```
24
+
25
+ Rite checks the observable invariants at both mapped entries: the order exists,
26
+ the caller owns it, it is paid, and it has not already been refunded. The proof
27
+ run shows the vulnerable baseline failing, the repaired implementation passing,
28
+ an intentional guard-removal mutation failing, and the restored source passing
29
+ again.
30
+
31
+ ## Try it locally
32
+
33
+ Requires Node.js 20 or newer with `npm`.
34
+
35
+ ```bash
36
+ npm install
37
+ npm test
38
+ npm run prove
39
+ npm run dev
40
+ ```
41
+
42
+ Open `http://localhost:5173` for the interactive workbench. The browser runs the
43
+ same synthetic cases and labels the bundled four-phase proof as a recorded CLI
44
+ capture, not a fresh browser execution.
45
+
46
+ For a production build:
47
+
48
+ ```bash
49
+ npm run build
50
+ npm run preview
51
+ ```
52
+
53
+ ## CLI
54
+
55
+ Run Rite without a global installation:
56
+
57
+ ```bash
58
+ # Create rite.config.json, rite.adapter.mjs, and the GitHub workflow
59
+ npx --yes @timidan/rite@0.1.0 init
60
+
61
+ # Review the generated rule and adapter, then verify
62
+ npx --yes @timidan/rite@0.1.0 verify \
63
+ --config rite.config.json \
64
+ --out report.json \
65
+ --sarif report.sarif
66
+
67
+ # Inspect an existing report
68
+ npx --yes @timidan/rite@0.1.0 report report.json
69
+
70
+ # Trace configured entries to a sink in one JavaScript file
71
+ npx --yes @timidan/rite@0.1.0 graph \
72
+ --file src/refunds.js \
73
+ --entries customerRefund,supportRefund \
74
+ --sink issueRefund
75
+
76
+ ```
77
+
78
+ Additional commands:
79
+
80
+ | Command | Purpose |
81
+ |---|---|
82
+ | `instrument` | Generate a starter adapter for a JavaScript module |
83
+ | `draft` | Ask watsonx.ai for candidate paths and cases; requires IBM Cloud credentials |
84
+ | `server` | Run the GitHub App web server |
85
+ | `mcp` | Run the local MCP stdio server |
86
+
87
+ `verify` exits with `0` for PASS, `1` for FAIL, `2` for ERROR, and `3` for
88
+ invalid usage.
89
+
90
+ ## Configuration model
91
+
92
+ A Rite target consists of three explicit inputs:
93
+
94
+ 1. A written authorization rule.
95
+ 2. A map of the entry functions and sensitive sink in scope.
96
+ 3. An adapter that invokes those entries and exposes observable effects.
97
+
98
+ The verifier compares each observed effect with literal expectations. Rite does
99
+ not infer that unmapped paths are safe. The included static graph walker is
100
+ single-file assistance for reviewing a path map, not a whole-program security
101
+ proof.
102
+
103
+ ## Evidence model
104
+
105
+ Run `npm run prove` to reproduce the demonstration in an isolated temporary
106
+ directory. Workspace source is not modified.
107
+
108
+ | Phase | Expected observation |
109
+ |---|---|
110
+ | Baseline | `wrong-owner:support` fails and records the unauthorized refund event |
111
+ | Fixed | All 10 mapped entry/case combinations pass |
112
+ | Mutation | Removing the shared ownership guard makes both wrong-owner cases fail |
113
+ | Restored | The exact fixed source passes all 10 checks again |
114
+
115
+ A red phase counts only when the intended behavioral assertion fails and the
116
+ forbidden effect is observed. A syntax error or process failure is reported as
117
+ an error, not vulnerability evidence. The generated record is written to
118
+ `evidence/proof.json` and copied to `public/evidence/proof.json` for the web UI.
119
+
120
+ ## GitHub App
121
+
122
+ The GitHub integration implements OAuth, installation and repository selection,
123
+ workflow-run discovery, and SHA-bound report artifact reads. `rite init` creates
124
+ the reviewed local files; Rite never silently writes to a connected repository.
125
+
126
+ Registration, environment variables, callback URLs, permissions, and the
127
+ webhook setting are documented in
128
+ [`docs/github-app-setup.md`](./docs/github-app-setup.md). The live GitHub flow
129
+ has verified OAuth and repository discovery; report display still requires a
130
+ target repository to produce its first Rite workflow artifact.
131
+
132
+ ## MCP server
133
+
134
+ Configure an MCP client with:
135
+
136
+ ```json
137
+ {
138
+ "mcpServers": {
139
+ "rite": {
140
+ "command": "npx",
141
+ "args": ["--yes", "@timidan/rite@0.1.0", "mcp"]
142
+ }
143
+ }
144
+ }
145
+ ```
146
+
147
+ It exposes `rite_analyze`, `rite_verify`, and `rite_report`, all backed by the
148
+ same core verifier used by the CLI.
149
+
150
+ ## Project structure
151
+
152
+ ```text
153
+ src/
154
+ cli/ CLI entry point
155
+ core/ Config loading, verification, and SARIF output
156
+ github/ GitHub App helpers and Express server
157
+ graph/ Single-file JavaScript call-path walker
158
+ instrument/ Adapter generation and effect comparison
159
+ mcp/ MCP stdio server
160
+ watsonx/ Optional candidate-drafting integration
161
+ App.jsx Browser workbench
162
+ checks.js Browser-safe sample case runner
163
+ refunds.js Synthetic refund service
164
+ examples/refund/ Sample config and adapter
165
+ scripts/prove.mjs Reproducible four-phase proof
166
+ test/ Node test suite
167
+ docs/ Policy, path map, and GitHub setup
168
+ evidence/ Saved vulnerable source and proof records
169
+ ```
170
+
171
+ ## Current boundaries
172
+
173
+ - The sample covers only `customerRefund` and `supportRefund` in
174
+ `src/refunds.js`.
175
+ - All orders, payments, users, and effects are synthetic and held in memory.
176
+ - No payment provider is contacted and no money moves.
177
+ - External repositories require a reviewed config, adapter, and workflow.
178
+ - GitHub sessions use the in-memory Express store and are lost on restart; the
179
+ current deployment shape is suitable for a single-process demo, not a
180
+ horizontally scaled production service.
181
+ - The optional watsonx.ai drafting request has not been verified with live
182
+ credentials.
183
+
184
+ ## IBM Bob build record
185
+
186
+ The build session established the rule and expected cases before the repair,
187
+ captured the baseline failure, routed both entries through one shared guard,
188
+ captured the passing result, then removed that guard to prove the checks could
189
+ detect the defect. Instructions for preserving genuine Bob screenshots live in
190
+ [`bob_sessions/README.md`](./bob_sessions/README.md).
191
+
192
+ ## License
193
+
194
+ MIT. See [`LICENSE`](./LICENSE). Third-party packages remain subject to their
195
+ respective licenses.
Binary file