Repository navigation
fix: make models list read-only - #70847
Conversation
🔒 Aisle Security AnalysisWe found 1 potential security issue(s) in this PR:
1. 🟡 Credential injection/confusion via legacy auth.json when discovery runs in read-only mode
Description
Vulnerable code (read-only skips scrubbing): if (options?.readOnly !== true) {
scrubLegacyStaticAuthJsonEntriesForDiscovery(authPath);
}
return createAuthStorage(PiAuthStorageClass, authPath, credentials);RecommendationEnsure legacy Options:
export function discoverAuthStorage(agentDir: string, options?: DiscoverAuthStorageOptions): PiAuthStorage {
const credentials = resolvePiCredentialsForDiscovery(agentDir, options);
const authPath = path.join(agentDir, "auth.json");
// In read-only mode, never consume legacy static api_key entries from disk
if (options?.readOnly === true) {
// Construct storage from `credentials` only (no file)
return createAuthStorage(PiAuthStorageClass, "", credentials); // or use inMemory/fromStorage path explicitly
}
scrubLegacyStaticAuthJsonEntriesForDiscovery(authPath);
return createAuthStorage(PiAuthStorageClass, authPath, credentials);
}If pi-coding-agent requires a file path, then parse Analyzed PR: #70847 at commit Last updated on: 2026-04-24T01:01:37Z |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1476475ea5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Greptile SummaryThis PR makes Confidence Score: 5/5Safe to merge; all remaining findings are minor P2 observability concerns that do not affect correctness. The changes are logically sound, well-tested with new assertions that confirm no models.json writes occur, and the read-only path is correctly propagated through all affected layers. The single flagged issue (shared hasLoggedModelCatalogError flag) is a pre-existing pattern and is P2. No files require special attention.
|
1476475 to
2487843
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2487843940
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
2487843 to
2a4778d
Compare
2a4778d to
ad54de3
Compare
|
Merged via rebase. Thanks @shakkernerd! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ad54de3ea2
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Summary
This PR makes
openclaw models lista read-only command. Before this change, list paths could callensureOpenClawModelsJson()and rewrite the agentmodels.jsonfile while only displaying available models. That made a read command mutate user state, and it also kept the command tied to heavier write-through catalog preparation.The new path keeps the visible model-list behavior, but avoids persistence side effects.
What changed
models listcall path toensureOpenClawModelsJson().models listcan passreadOnly: trueand avoid legacy auth cleanup/mutation.models.json.main.models listdoes not persistmodels.jsonensureOpenClawModelsJsonmodels list --allstill includes eligible config-defined provider rowsdocs/cli/models.mdto document thatmodels listis read-only.Before
openclaw models list --allcould rewrite:That happened through catalog preparation, even though the user only asked to list models.
The old write-through behavior also made some config-defined providers visible indirectly after persistence, so removing the write path required a read-only replacement for the visible configured-provider rows.
After
openclaw models listreads from:It does not rewrite
models.json.For configured provider rows, the command now preserves the verified existing visible behavior: documented custom provider entries with explicit transport/auth shape still appear in
models list --all, without relying onmodels.jsonbeing rewritten first.Verification
pnpm test src/commands/models.list.e2e.test.ts src/commands/models/list.list-command.forward-compat.test.ts src/commands/models/list.rows.test.tspnpm check:changedpnpm buildI also verified the behavior against
origin/mainwith isolated config/state directories:api+apiKeyappeared onorigin/main, and still appears on this branchorigin/main, so this PR does not broaden that behaviormodels.json