Validate settings imports before writing secrets; disclose base URLs
Secret Scan / scan (push) Successful in 14s
Build App (Preview) / compute-version (pull_request) Successful in 7s
Secret Scan / scan (pull_request) Successful in 6s
Build App (Preview) / create-release (pull_request) Successful in 2s
Build App (Preview) / build-macos (pull_request) Successful in 2m43s
Build App (Preview) / build-windows (pull_request) Successful in 4m59s
Build App (Preview) / build-linux (pull_request) Successful in 7m29s
Build App (Preview) / prune-previews (pull_request) Successful in 1s
Secret Scan / scan (push) Successful in 14s
Build App (Preview) / compute-version (pull_request) Successful in 7s
Secret Scan / scan (pull_request) Successful in 6s
Build App (Preview) / create-release (pull_request) Successful in 2s
Build App (Preview) / build-macos (pull_request) Successful in 2m43s
Build App (Preview) / build-windows (pull_request) Successful in 4m59s
Build App (Preview) / build-linux (pull_request) Successful in 7m29s
Build App (Preview) / prune-previews (pull_request) Successful in 1s
A rejected import (bad env var name, disallowed host path) used to leave keychain secrets already overwritten while the settings themselves stayed unchanged. apply_settings_import now runs update_settings's validation (extracted into validate_settings_update) before any secret write. Also from this review round: sharpened two format-version tests that previously passed against the pre-fix code too, added a direct test for split_settings_and_secrets, warned on a dormant web terminal token even when the terminal import leaves it off, matched the password-length check to the frontend's unit of measure, zeroized the export plaintext buffer, and surfaced non-blank Ollama/llama.cpp/OpenAI-compatible/gateway base URLs in the import preview so a traffic redirect isn't silent.
This commit is contained in:
@@ -19,21 +19,37 @@ export function describeImport(preview: SettingsImportPreview): string[] {
|
||||
if (preview.has_gateway_api_key) items.push("The gateway provider API key");
|
||||
if (preview.has_gateway_master_key) items.push("The gateway master key");
|
||||
if (preview.has_web_terminal_access_token) items.push("The web terminal access token");
|
||||
if (preview.ollama_base_url) items.push(`Ollama server: ${preview.ollama_base_url}`);
|
||||
if (preview.llamacpp_base_url) items.push(`llama.cpp server: ${preview.llamacpp_base_url}`);
|
||||
if (preview.openai_compatible_base_url) {
|
||||
items.push(`OpenAI-compatible server: ${preview.openai_compatible_base_url}`);
|
||||
}
|
||||
if (preview.gateway_api_base) items.push(`Gateway upstream: ${preview.gateway_api_base}`);
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Things about an import that deserve more attention than a bullet in a
|
||||
* long list — currently just the one, but deliberately its own function
|
||||
* rather than a flag inside `describeImport`: a setting that turns on a
|
||||
* network-listening service is exactly the kind of change a "your settings
|
||||
* were replaced" summary is bad at surfacing, on purpose or (if the file
|
||||
* came from someone else) not.
|
||||
* long list — deliberately its own function rather than a flag inside
|
||||
* `describeImport`: a setting that turns on a network-listening service is
|
||||
* exactly the kind of change a "your settings were replaced" summary is bad
|
||||
* at surfacing, on purpose or (if the file came from someone else) not.
|
||||
*
|
||||
* A token that arrives with the terminal left *off* gets its own warning
|
||||
* too, distinct from the "enables it now" one: `start_web_terminal` only
|
||||
* mints a fresh token when none is already set, so a planted token here
|
||||
* would silently become live the next time someone flips the terminal on
|
||||
* through the UI, with no import-time signal that it wasn't freshly
|
||||
* generated.
|
||||
*/
|
||||
export function describeImportWarnings(preview: SettingsImportPreview): string[] {
|
||||
const warnings: string[] = [];
|
||||
if (preview.enables_web_terminal) {
|
||||
warnings.push("Enables the remote web terminal, which listens on your network.");
|
||||
} else if (preview.has_web_terminal_access_token) {
|
||||
warnings.push(
|
||||
"Includes a web terminal access token that will activate the next time the web terminal is turned on.",
|
||||
);
|
||||
}
|
||||
return warnings;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user