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 ece5faa
Browse filesBrowse the repository at this point in the historyBrowse files
fix(lint): warn on a stdio MCP auth that reaches nothing and on a credential typed into transport.credentialEnv (#29664)
<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8NWPXiR9AzY9UmgJXftg6QH)_Fixes#29607
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:`connector-credential-literal` 提示规则新增两条警告。一条是 stdio 的 `mcp`
连接器声明了 `bearer` / `api-key` / `basic` 的 `auth` 却没写
`transport.credentialEnv`,凭据被解析后被丢掉;另一条是 `transport.credentialEnv`
里填的像密钥而不是环境变量名。
- 为什么改:作者声明的凭据静默无效,没人告诉作者(#29607 第 1 项,路线 A);`credentialEnv`
会在每次元数据读取时原样返回,误填的密钥会被读出(增补评论 6590066946 第 2 项)。
- 风险与回滚:只加警告,任何保存与启动都不被拒,接受集不变。回滚即 revert 本 PR。
- 先看:`packages/lint/src/lint-connector-credential-literals.ts`
末尾两段新判断;`packages/lint/src/credential-literal.ts` 新函数
`isCredentialShapedName`(防误报的门槛);`rule-explanations.ts` 新段落。
- 两分钟验证:`pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2
src/lint-connector-credential-literals.test.ts
src/credential-literal.test.ts`,预期全部通过。
- 需要你做的:无,席位落地。
## What changes
Route A of the card, plus item 2 of addendum 6590066946. Both are
warnings on the existing `connector-credential-literal` advisory; no
accept set moves, nothing is refused, and
`packages/connectors/connector-mcp/src/mcp-provider.ts` is not touched.
- **Item 1, a stdio `auth` that reaches nothing**
(`lint-connector-credential-literals.ts`). A `provider: 'mcp'` entry
whose `providerConfig.transport.kind` is `'stdio'`, with a static `auth`
(`bearer`, `api-key` or `basic`) and no `transport.credentialEnv`, draws
one warning at `connectors[N].auth`. The message says the credential
reaches nothing and names `transport.credentialEnv`. The hint gives the
key to add, and says to drop `auth` when the server takes no credential,
because an unresolved reference still degrades the instance. Not drawn:
an entry that has `credentialEnv`; `auth: { type: 'none' }`; the
grant-bearing kinds (`oauth2`, `app-credential`), which the provider
already refuses loudly at boot on stdio; an http transport; and a
provider other than `mcp`.
- **Item 2, a credential in `transport.credentialEnv`.** The existing
predicate cannot judge this slot.
`isCredentialShapedLiteral('credentialEnv', v)` is true for every
non-blank `v`, because R1 reads the key and `credentialEnv` contains the
segment `credential`. Judging the value as a name is no better:
`GITHUB_TOKEN` draws too. So `credential-literal.ts`, the predicate's
one home, gains a sibling, `isCredentialShapedName(value)`. It reuses
the R2 auth-scheme pattern and the template pattern, and reads no name
list. A value draws when it opens with an auth scheme (`Bearer …`), or
when it has a run of 16 or more letters and digits that switches between
the two at least four times, the way a generated token does. A
conventional name never draws. That includes long capital names with no
digits (`ABCDEFGHIJKLMNOPQRSTUVWXY`), names with underscores, and names
with one or two digit groups (`SERVICEACCOUNTTOKEN2`,
`PROD2024REPOSITORYTOKEN`); the seat asked for those pins. The trade-off
is that a token written in letters only does not draw. The finding sits
at `connectors[N].providerConfig.transport.credentialEnv`, on any
transport (the key is stored and served either way), and never echoes
the value. The function is not on the package entry, so the public
surface is byte-unchanged.
- `rule-explanations.ts`: one new paragraph in `os explain
connector-credential-literal` for the two route findings.
- `.changeset/29607-stdio-auth-unplaced-advisory.md`:
`@objectstack/lint` patch, both declaration lines.
## Why
The card's measurement and the order's hypothesis, reproduced on
`origin/main` 3482f3d:
- **Boot, through the automation service.** This was a scratch copy of
the `declarative stdio instance through the automation service` harness
in `mcp-stdio-credential-env.test.ts`, with `credentialEnv` removed, and
it was deleted after the run. The resolver was asked for the reference
(`asked= ["OS_TEST_MCP_STDIO_CREDENTIAL_REF"]`). The instance came up
`state= ready` with no degraded reason, and the spawned child reported
`unset:0`: the credential never reached it, and nothing said so. The
provider-level control (`control: the same instance with no
credentialEnv …`) passes the same way.
- **Lint, before.** `lintConnectorCredentialLiterals` returned `[]` for
both shapes: a stdio `bearer` entry with no `credentialEnv`, and a
`credentialEnv` holding a token-shaped value.
- **Count: 0.** No shipped template or example declares a static `auth`
on a stdio `mcp` instance. I checked `examples/**`, the
`create-objectstack` templates, `content/docs/**` and `skills/**` here,
plus `objectstack-ai/hotcrm` and `objectstack-ai/docs.objectos.ai`. The
one shipped stdio instance (`examples/app-showcase`
`showcase_mcp_tools`) declares `auth: { type: 'none' }`, and the docs'
stdio example carries `credentialEnv`. So route A breaks nothing and
changes no current output. Option B would also have had no producer to
migrate, but it stays a ruling's call, as the card says.
## Tests
- New pins in `lint-connector-credential-literals.test.ts`:
- each static kind on stdio draws exactly one warning at `auth`, with
the exact message;
- controls for `credentialEnv` set, `none`, `oauth2`, `app-credential`,
no `auth`, http and a non-`mcp` provider;
- an env literal beside an unplaced `auth` draws both findings, once
each;
- `credentialEnv` holding a token run or a `Bearer …` value draws at
that key, never echoes it, and draws on http too;
- four correct names draw nothing;
- one sentence each, at most 210 characters;
- the runtime publish gate case for `connector`;
- three new facts in the `os explain` entry.
- New pins in `credential-literal.test.ts`: why
`isCredentialShapedLiteral` cannot answer this; 11 correct names that
never draw; 5 values that draw; templates, blanks and non-strings draw
nothing.
- `pnpm --filter @objectstack/lint test && pnpm --filter
@objectstack/lint typecheck` under the lock on 9bb1b84: Test Files 192
passed (192), Tests 7924 passed (7924), `tsc --noEmit` and
`check:test-typecheck` clean, VERDICT command-exit 0.
<details><summary>Ablations on 9bb1b84: tests import the rule from src,
so no build leg; each through scripts/ablation-replace.mjs, restored to
the HEAD blob with an empty git diff HEAD</summary>
- Delete `transport.credentialEnv === undefined &&` (the item 1 guard):
8 failed / 23 passed. The `credentialEnv`-set control and the
correct-name pins go red.
- The item 1 condition forced false (anchor `transport.credentialEnv ===
undefined &&` → `false &&`): 6 failed / 25 passed. Every item 1 pin, and
the runtime door case, goes red.
- `if (isCredentialShapedName(transport.credentialEnv))` → `if (false)`:
4 failed / 27 passed (the item 2 pins).
- `alternations(run) >= MIN_TOKEN_ALTERNATIONS` → `>= 0` (the
false-positive floor): 7 failed / 86 passed. Every long-capital-name pin
goes red in both files.
- The first attempt at the item 1 ablation was a no-op that the tool
refused: its anchor was a substring of its replacement, so the count did
not drop. It was redone with the anchor above.
</details>
## Acceptance notes
- One rule id, deliberately. Both route findings ride
`connector-credential-literal`, because they are about where that rule's
steer sends the credential. They need no new registry row, door wiring
or explain entry. `authoring-rules.ts` is untouched, and its row comment
still reads "four header/env maps". That is now incomplete, but it is
not false.
- `content/docs/automation/connectors.mdx` ("A stdio transport that
names no `credentialEnv` does not apply `auth`") is still true. It could
add that the advisory now reports this. That is outside this PR's file
surface.
- `skills/objectstack-automation/references/integration-recipes.md`
recipe 6 still says "a `stdio` server's credentials ride
`transport.env`". That predates `credentialEnv`, and it steers toward
the literal the advisory warns on. `skills/**` is a governed surface, so
this PR leaves it alone (carrier: none, noted for the seat).
## Verification
<details><summary>Derived gates on 9bb1b84</summary>
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` on 9bb1b84: 57 families, from 6 paths vs
merge base 3482f3d (+318/-6). The runner ran each one once and captured
its exit code before any pipe. 56 exited 0.
- `check-plugin-teardown-shape.mjs --self-test` exited 3 on the first
round, because its pinned positive control `621a4876` was not in the
shallow clone. After `git fetch origin 621a487` it exited 0 (48 cases
pass).
- `pnpm check:dual-build-cjs-loads` exited 3 (PREREQUISITE NOT MET: the
workspace is not fully built). NOT MEASURED locally; CI runs it on a
full build.
- `dispatch-gates --ran` reconciled: 57 derived, 56 run, 1 NOT-MEASURED
(dual-build, from its recorded exit 3), 0 UNRUN.
- `pnpm lint` (repo-wide eslint, `--no-inline-config`) on 9bb1b84
exited 0.
- The branch is 4 commits behind `origin/main` e0187d0. None of them
touches `packages/lint`, `packages/connectors` or any derivation input
(the `--ran` banner says the same), so I did not merge main.
- The lint package's dependency closure plus
`@objectstack/connector-mcp`'s were built under the lock (VERDICT
command-exit 0) before the tests and the reproduction ran.
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(No spec change.)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: n/a.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbaSFr2XhX4m1qEAiXy)_
Co-authored-by: Claude <noreply@anthropic.com>
fix(lint): `connector-credential-literal` now also warns when a stdio MCP server's credential goes nowhere, or when a credential is typed into `transport.credentialEnv`
9
+
10
+
Two new findings on the existing advisory. Both are warnings, so nothing is refused and every save still lands. They reach `os validate`, `os build`, `os lint` and the connector save door (`PUT /meta/connector/:name`), the same doors the rule already runs on.
11
+
12
+
-**A stdio `auth` that reaches nothing.** Take a `provider: 'mcp'` entry with a stdio transport and a `bearer`, `api-key` or `basic``auth`, but no `providerConfig.transport.credentialEnv`. Its reference is still resolved, and a missing one still degrades the instance. But the provider hands the credential to a stdio server only in the variable `credentialEnv` names, so the credential was dropped and nothing said so. The finding sits at `auth` and names the fix. Add `credentialEnv`, or drop `auth` if the server takes no credential:
-**A credential in `transport.credentialEnv`.** That key holds the name of an environment variable, and it is served on every metadata read. The rule now warns when the value reads as a credential instead of a name. That means it opens with an auth scheme (`Bearer …`), or it has a run of 16 or more letters and digits that switches between the two at least four times, the way a generated token does. A conventional name such as `REPO_MCP_TOKEN`, or a long capital name, never draws. The finding names the key and never echoes the value.
0 commit comments