You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 755e285
Browse filesBrowse the repository at this point in the historyBrowse files
feat(lint)!: report a searchableFields entry that names a secret or password field (#27811)
<!-- claude-projects-attribution: {"github_login":"marchtian"} -->
_Requested by **田騏** · [project
thread](https://claude.ai/code/project/chan_01VmuUhXU9SSUzqJYyXSmYSi?thread=cmsg_01VmuUhXU9SSUzqJYyXSmYSiEosMC3zDfHaauURHFNq1GJ)_Fixes#27705
Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: follow-up #27660
## 维护者速读
- **改了什么:** `os validate`、`os build` 和元数据发布门现在把 `searchableFields` 里指向
`secret` / `password` 字段的条目报为错误(沿用规则
`searchable-field-unsearchable`),对象自身集合、列表视图、React 页面 ListView 组件的
`searchableFields` 属性 全覆盖。
- **为什么改:**
引擎搜索时会静默跳过凭据字段,作者声明的搜索范围悄悄变窄;全是凭据字段时还会退回自动默认集。现在写的时候就告诉作者,严重级别与
`formula` 条目一致。
- **风险与回滚:** 这是收窄:以前能通过的元数据现在会报错。仓内没有这样的元数据(dogfood 全绿)。引擎行为不变。回滚就是
revert 本 PR。
- **先看:** `packages/lint/src/validate-searchable-fields.ts`(新增的凭据检查段,位于
formula
检查之后、可接受性检查之前)、`packages/spec/src/data/masked-field-types.ts`(新谓词
`isCredentialFieldType`)、`packages/objectql/src/secret-fields.ts`(一行替换,行为不变)。
- **两分钟验证:** `pnpm --filter @objectstack/lint exec vitest run
src/validate-searchable-fields.test.ts`,预期全部通过,其中包括 "a secret or
password entry" 这一组。
- **需要你做的:** 无,席位落地。
Independent review: none run (quota); the PR waits for the seat's
contract-review hand-off.
## What changes
- **`packages/lint/src/validate-searchable-fields.ts`.** A credential
check sits beside the `formula` check from #6674. It reports a
`searchableFields` entry whose field type is `secret` or `password`
under `searchable-field-unsearchable` at `error`. It runs on every
surface the virtual check covers: the object's own set, an object's
built-in list views, `defineView` lists and named list views, a
flattened list overlay, a ViewItem record, and a react page's ListView
`searchableFields` prop (through the shared `checkSearchableFieldList`
core). The remedy line is `Drop "NAME": credential fields are never
searched`. The module note (check 4) gives the reason for the severity.
The check runs before the #4830 admissibility pass, so a view over an
auto-default object gets this verdict instead of the generic "of type
'password'… target a text-like field".
- **`packages/spec/src/data/masked-field-types.ts`.** Adds
`isCredentialFieldType(fieldType)`. It answers whether a type is masked
on read on at least one object, which today means `secret` and
`password`. It reads that from the keys of `MASKED_ON_READ_FIELD_TYPES`,
so it adds no second type literal, and it ignores the better-auth
exemption. `isMaskedOnReadFieldType` now uses it for its own-key test,
and its answers are unchanged.
- **`packages/objectql/src/secret-fields.ts`.**
`collectCredentialFields` now reads `isCredentialFieldType` instead of
its own `def.type === 'secret' || def.type === 'password'` literal. This
is the one-line swap the order allows. The linter and the engine's
search withhold (`expandSearchOnAst`, unchanged) now judge credential
types from one predicate. `packages/objectql/src/engine.ts` is not
touched.
- **`packages/lint/src/rule-explanations.ts`.** `os explain
searchable-field-unsearchable` gains a paragraph on what the engine does
with a credential entry on each surface, why there is no exemption, and
why the finding is an error.
- **`packages/spec/api-surface/data.json`,
`packages/spec/export-origins/data.json`.** Regenerated by
`check:generated --fix` (one line each, the new export).
- **`.changeset/27705-searchable-credential-fields.md`.**
`@objectstack/lint` minor, `@objectstack/spec` and
`@objectstack/objectql` patch. It carries both declaration lines and an
ADR-0087 `not-required (no-migration-prescription)` disposition, the
precedent of `27225-mail-formatter-shape-lint.md`.
## Tests
- `validate-searchable-fields.test.ts`: `secret` and `password` on the
object's own set, and on a list view narrowing (it.each). Also a view
entry the object itself declares (both findings), a better-auth
`password` (exemption-free), a control where text and email entries in
the same declarations stay clean, and the `os explain` text. The
`fix:`-line coverage control adds the credential arm.
- `validate-react-page-props.test.ts`: a ListView
`searchableFields={['name', 'api_key', 'portal_password']}` prop reports
both credential entries at `error`.
- `runtime-gate.object-writes.test.ts`: the object publish door refuses
`searchableFields: ['owner', 'api_key']` (`api_key` is `secret`).
- `masked-field-types.test.ts`: `isCredentialFieldType` over every
`FieldType`, its agreement with "masked on some object", the one cell
where it and `isMaskedOnReadFieldType` differ (`password` ×
better-auth), and unvalidated input.
## Acceptance notes
- **Severity.** `error`, the severity the triage ruling sets (the same
as the #6674 `formula` entry). Hence `Clause-②: no (narrowing)`.
- **Predicate home.** No credential-type predicate existed in
`packages/spec`. `SEARCH_AUTO_EXCLUDED_TYPES` also lists `json`,
`lookup` and other types an author may declare, and
`isMaskedOnReadFieldType` applies the better-auth exemption that the
search withhold does not apply. So the predicate was added next to the
mask table it reads.
- **Observed, not measured (not filed).** The REST ingress
(`assertSearchFieldsAreSearchable`) admits a `$searchFields` entry
naming a credential field that the object itself declares, and the
engine then withholds it. Reading `resolveSearchFields`, a request
naming only such fields would be answered over the object's whole
allowed set. That is a narrower request answered more widely. This is a
reading of the code, not a measurement through a public door, so it is
left here for the seat. It sits outside this card's "no runtime change"
scope.
- **Skills.** #27660 teaches `searchableFields should not list it` in
`skills/objectstack-data`. The boundary table in
`skills/objectstack-ui/rules/list-views.md`, which lists each
`searchable-field-unsearchable` row, has no credential row. #27660 could
take that row as well. This PR touches no `skills/**` file.
- **Ablation.** Run once against the committed fix, not kept as a test.
## Verification
<details><summary>Ablation: new pins fail without the fix</summary>
`node scripts/ablation-replace.mjs --file
packages/lint/src/validate-searchable-fields.ts --anchor " if
(isCredentialFieldType(ctype)) {" --replacement " if (false &&
isCredentialFieldType(ctype)) {" -- …vitest run
src/validate-searchable-fields.test.ts
src/validate-react-page-props.test.ts`
- mutation landed: anchor 1 to 0, blob `1343dd89e129` to `892e53b49026`
- `Tests 8 failed | 241 passed (249)`: the 7 credential pins plus the
`fix:`-line coverage control. The text-field control and the `os
explain` pin stayed green, as expected.
- restored: blob == HEAD (`1343dd89e129`), `git diff HEAD` empty
</details>
<details><summary>Package tests and typecheck</summary>
- `@objectstack/lint` test: `Test Files 178 passed (178)`, `Tests 7633
passed (7633)`. typecheck: `tsc --noEmit` clean, `check:test-typecheck:
OK`.
- `@objectstack/spec` test: `Test Files 755 passed (755)`, `Tests 22452
passed | 1 todo`. typecheck exit 0.
- `@objectstack/objectql` test (`--project local`): `Test Files 490
passed (490)`, `Tests 9244 passed (9244)`. typecheck:
`check:test-typecheck: OK`.
- `@objectstack/spec check:generated`: 2 artifacts stale before
regeneration (`api-surface`, `export-origins`) and regenerated with
`--fix`.
</details>
<details><summary>Gates (dispatch-gates --commands, 85 families, at
257e83d)</summary>
All 85 exit 0 at head `257e83df2f`, each exit code captured before any
pipe. `--ran` reconciliation: 85 derived, 85 run, 0 NOT-MEASURED, 0
UNRUN. A first run at `340955697a` had `pnpm check:dual-build-cjs-loads`
at exit 3 (PREREQUISITE NOT MET, no full build yet). It was re-run in
the final union after the dogfood closure build: 112 require entry
points across 69 packages load. `check-adr-0087-registration` found one
declared-breaking changeset, and it carries its disposition. The level
axis of `check-changeset-no-major` is scoped to the PR and reads this
body on CI.
</details>
<details><summary>Dogfood</summary>
At `257e83df2f`, after the `@objectstack/dogfood^...` closure build,
under the lock: `pnpm --filter @objectstack/dogfood test`, VERDICT
command-exit 0, `Test Files 355 passed | 3 skipped (358)`, `Tests 2867
passed | 20 skipped (2887)`. No shipped metadata names a credential
field in `searchableFields`.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude <noreply@anthropic.com>
feat(lint)!: `searchable-field-unsearchable` reports a `searchableFields` entry that names a `secret` or `password` field, which the engine leaves out of every search without a word
8
+
9
+
Clause-②: no (narrowing) — `os validate`, `os build`, `os lint` and the metadata publish door refuse a `searchableFields` entry whose field type is `secret` or `password`, on the object's own set, on every list view surface and on a react page's ListView `searchableFields` prop, which they accepted before. The finding takes the severity of the `formula`-entry finding (`error`). No rule id is added or removed.
10
+
Metadata-protocol: narrowed
11
+
12
+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped: a searchableFields entry the engine already withheld from every search (ADR-0100) is now refused where it is authored. The one remedy is to delete the entry, which a conversion cannot decide for the author, so there is no key for a migration to rewrite and no tombstone. -->
13
+
14
+
**BREAKING** accept-set narrowing at every authoring door for `searchableFields`.
15
+
16
+
-**Before.** The engine's search expansion leaves every credential column (`secret`, `password`) out of the set it scans (ADR-0100), an author-declared one included, and says nothing. A declaration naming one passed every gate and searched a narrower set than written; a declaration naming only credential fields fell through to the auto-default set.
17
+
-**Now.** The rule refuses the entry at `error`, naming the entry, its type and the object. It is judged on every object, a better-auth `password` included: the read mask spares that one, the search withhold does not.
18
+
-**Who sees it.** An object or list view whose `searchableFields` names a `secret` or `password` field. No metadata shipped in this repository does.
19
+
20
+
**The remedy.** Drop the entry: credential fields are never searched. `os explain searchable-field-unsearchable` states what the engine does with it on each surface.
21
+
22
+
`@objectstack/spec` exports `isCredentialFieldType(fieldType)` from `@objectstack/spec/data`: whether a field type is masked on read on at least one object (`secret`, `password`), the exemption-free question. `@objectstack/objectql`'s `collectCredentialFields` now reads it instead of its own type literal; its answer is unchanged.
0 commit comments