Commit a81d62f
committed
Add audit status tracking, fix duration/rewritten query, and audit write rejections
- Add `status` ("success" | "error" | "denied") and `error_message` columns to
`query_audit_log` via two new migrations (017, 018)
- Restructure `PolicyHook::handle_query` with a labeled block so all paths
(success, error, policy-denied) reach a single audit write site
- Fix `elapsed_ms` to be captured after the labeled block, covering encoding too
- Fix `rewritten_query` to use DataFusion `Unparser` + `BetweenRowsPostgresDialect`
instead of the fake `/* policy-rewritten */` comment
- Swap hook order to [PolicyHook, ReadOnlyHook] and add `audit_write_rejected()`
so write statements rejected by ReadOnlyHook are audited with status "denied"
- Extract `is_allowed_statement()` from ReadOnlyHook as shared public helper
- Add `status` filter to `GET /audit/queries` API
- Add Status column + filter dropdown + error_message detail block to QueryAuditPage
- Add `sql-formatter` for pretty-printing SQL in the detail panel
- Add TC-AUDIT-01 through TC-AUDIT-05 integration tests
- Remove resolved roadmap bug entry; add security vectors 21-241 parent 60558a6 commit a81d62f
17 files changed
Lines changed: 865 additions & 81 deletions
File tree
- admin-ui
- src
- api
- pages
- docs
- migration/src
- proxy
- src
- admin
- engine
- entity
- hooks
- tests
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| |||
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
6 | 15 | | |
7 | 16 | | |
8 | 17 | | |
| |||
11 | 20 | | |
12 | 21 | | |
13 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
14 | 45 | | |
15 | 46 | | |
16 | 47 | | |
17 | 48 | | |
18 | 49 | | |
19 | 50 | | |
20 | 51 | | |
| 52 | + | |
21 | 53 | | |
22 | 54 | | |
23 | 55 | | |
24 | 56 | | |
25 | 57 | | |
| 58 | + | |
26 | 59 | | |
27 | 60 | | |
28 | 61 | | |
| |||
42 | 75 | | |
43 | 76 | | |
44 | 77 | | |
| 78 | + | |
45 | 79 | | |
46 | 80 | | |
47 | 81 | | |
| |||
51 | 85 | | |
52 | 86 | | |
53 | 87 | | |
| 88 | + | |
54 | 89 | | |
55 | 90 | | |
56 | 91 | | |
| |||
81 | 116 | | |
82 | 117 | | |
83 | 118 | | |
84 | | - | |
| 119 | + | |
85 | 120 | | |
86 | 121 | | |
87 | 122 | | |
| |||
120 | 155 | | |
121 | 156 | | |
122 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
123 | 171 | | |
124 | 172 | | |
125 | 173 | | |
| |||
156 | 204 | | |
157 | 205 | | |
158 | 206 | | |
| 207 | + | |
159 | 208 | | |
160 | 209 | | |
161 | 210 | | |
| |||
173 | 222 | | |
174 | 223 | | |
175 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
176 | 228 | | |
177 | 229 | | |
178 | 230 | | |
| |||
196 | 248 | | |
197 | 249 | | |
198 | 250 | | |
199 | | - | |
| 251 | + | |
200 | 252 | | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
201 | 259 | | |
202 | 260 | | |
203 | 261 | | |
204 | | - | |
| 262 | + | |
205 | 263 | | |
206 | 264 | | |
207 | 265 | | |
208 | 266 | | |
209 | 267 | | |
210 | 268 | | |
211 | | - | |
| 269 | + | |
212 | 270 | | |
213 | 271 | | |
214 | 272 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
0 commit comments