Repository navigation
Commit fec1f58
fix(cli): a connection label printed by the CLI removes a password or a credential query pair wherever the URL rules read one (#30171)
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:CLI 打印的数据库连接标签(`os dev` / `os start` / `os serve` 启动横幅与迁移确认)改为通过
spec 的共享 URL 凭据函数 `redactUrlCredentials` 去掉密码与凭据查询参数,不再自带一套规则或参数名单。
- 为什么改:凡是平台 URL 规则读出凭据(userinfo
密码或凭据查询参数)的值,终端标签都必须去掉它;标签与数据源读门共用同一套规则,规则扩展时标签自动跟随。
- 风险与回滚:仅影响打印文本;共享规则读不出凭据的值输出逐字节不变(已用对照用例钉住)。回滚即还原单个函数。
- 先看:`packages/cli/src/utils/connection-display.ts` 的
`redactConnectionUrl` 前两行;`connection-display.test.ts` 新增的两个 describe 块。
- 两分钟验证:`pnpm --filter @objectstack/cli exec vitest run --maxWorkers=2
src/utils/connection-display.test.ts`,预期 33 个用例全绿。
- 需要你做的:无,席位落地。
## What changes
- `redactConnectionUrl` (the database label the CLI prints) first
removes credentials through `redactUrlCredentials` from
`@objectstack/spec/data`, the composite the datasource read path
applies. That covers the userinfo password and every credential query
pair judged by the shared query-pair judge and its one list of names.
Rule: a connection label printed by the CLI removes a password or a
credential query pair wherever the URL rules read one, on every path the
label takes.
- The CLI keeps no second grammar and no second list of names. The
existing display shaping runs unchanged after that step: the URL parser
drops the username and query string, and when the parser rejects the
value the userinfo segment is dropped by hand.
- `@objectstack/cli` already depends on `@objectstack/spec`
(`dependencies`, `workspace:*`), so no dependency is added.
- Changeset: `@objectstack/cli` patch.
## Tests
Two new top-level describes in the existing harness file
`packages/cli/src/utils/connection-display.test.ts`, named for the rule.
Password rule:
- the password is removed wherever the shared grammar reads one,
including a special scheme's authority;
- the whole password is removed up to the boundary the shared grammar
draws;
- property pin: across a corpus of URL shapes, the label never contains
a password that `urlUserinfoPassword` reads, and every shape in the
corpus is judged;
- controls, byte for byte against today's output.
Query rule:
- a credential query pair is removed on each of the three paths: a value
with no `://`, the URL parser path, and the hand fallback;
- property pin: the label never contains a value that
`urlCredentialQueryParams` judges a credential;
- controls, byte for byte, for values with no credential pair: a
non-credential query on the fallback path and on a value with no `://`,
and an empty-valued pair.
Expected outputs for the controls were computed from the pre-change
function before they were written into the pins.
## Acceptance notes
- One-shot ablations (not kept as files), each restored to the HEAD blob
with `git diff HEAD` empty:
- the password step replaced by the identity: the three password-rule
pins go red and every control stays green;
- the query half removed (the import aliased to the password-only
function): 3 failed, 30 passed. The no-`://` and hand-fallback pins and
the query property pin go red. The URL-parser path pin stays green as
expected, because that path already drops the whole query string.
- The label follows any future widening of the shared grammar with no
edit here; the property pins cover new shapes through their oracles.
## Verification
- `connection-display.test.ts`: 33/33 passed.
- Query-token coverage: a credential query pair is pinned removed on the
no-`://` path, the hand-fallback path and the URL-parser path.
- `pnpm --filter @objectstack/cli typecheck`: exit 0.
- Full `@objectstack/cli` suite, both tiers, under the verify lock at
1e01266: Test Files 577 passed, 1 skipped (578); Tests 7074 passed, 9
skipped (7083); VERDICT command-exit 0.
- Derived gate families (`dispatch-gates.mjs --commands`): 59 commands
run locally, 56 exited 0. Three answered `PREREQUISITE NOT MET` (exit 3)
because they need a whole-repo build: `check:dual-build-cjs-loads`,
`check:i18n-coverage`, `check:type-check-debt`. Those three are NOT
MEASURED locally and are left to `Lint & Repo Gates` in CI.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj)_
<!-- signed: security#1 · os-justin · session_01QSeKYn5CmmdShCJifm6WYj
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 59e6463 commit fec1f58
3 files changed
Lines changed: 177 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
15 | 20 | | |
16 | 21 | | |
17 | 22 | | |
| |||
56 | 61 | | |
57 | 62 | | |
58 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
59 | 203 | | |
60 | 204 | | |
61 | 205 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
34 | 48 | | |
35 | 49 | | |
36 | | - | |
| 50 | + | |
| 51 | + | |
37 | 52 | | |
38 | | - | |
| 53 | + | |
39 | 54 | | |
40 | 55 | | |
41 | 56 | | |
| |||
45 | 60 | | |
46 | 61 | | |
47 | 62 | | |
48 | | - | |
| 63 | + | |
49 | 64 | | |
50 | 65 | | |
51 | 66 | | |
| |||
0 commit comments