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:
@@ -26,6 +26,10 @@ const samplePreview: SettingsImportPreview = {
|
||||
has_gateway_master_key: false,
|
||||
has_web_terminal_access_token: false,
|
||||
enables_web_terminal: false,
|
||||
ollama_base_url: null,
|
||||
llamacpp_base_url: null,
|
||||
openai_compatible_base_url: null,
|
||||
gateway_api_base: null,
|
||||
};
|
||||
|
||||
describe("ImportSettingsModal", () => {
|
||||
|
||||
@@ -14,6 +14,10 @@ function preview(overrides: Partial<SettingsImportPreview> = {}): SettingsImport
|
||||
has_gateway_master_key: false,
|
||||
has_web_terminal_access_token: false,
|
||||
enables_web_terminal: false,
|
||||
ollama_base_url: null,
|
||||
llamacpp_base_url: null,
|
||||
openai_compatible_base_url: null,
|
||||
gateway_api_base: null,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
@@ -59,6 +63,19 @@ describe("describeImport", () => {
|
||||
const items = describeImport(preview({ has_web_terminal_access_token: true }));
|
||||
expect(items).toContain("The web terminal access token");
|
||||
});
|
||||
|
||||
it("names custom base URLs verbatim, since they're endpoints rather than secrets", () => {
|
||||
const items = describeImport(
|
||||
preview({
|
||||
ollama_base_url: "http://10.0.0.5:11434",
|
||||
gateway_api_base: "https://gateway.example/v1",
|
||||
}),
|
||||
);
|
||||
expect(items).toContain("Ollama server: http://10.0.0.5:11434");
|
||||
expect(items).toContain("Gateway upstream: https://gateway.example/v1");
|
||||
expect(items.some((i) => i.includes("llama.cpp"))).toBe(false);
|
||||
expect(items.some((i) => i.includes("OpenAI-compatible"))).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("describeImportWarnings", () => {
|
||||
@@ -79,7 +96,9 @@ describe("describeImportWarnings", () => {
|
||||
).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("does not warn just because a web terminal token is present but the terminal is off", () => {
|
||||
expect(describeImportWarnings(preview({ has_web_terminal_access_token: true }))).toEqual([]);
|
||||
it("warns about a dormant web terminal token even while the terminal stays off", () => {
|
||||
expect(describeImportWarnings(preview({ has_web_terminal_access_token: true }))).toEqual([
|
||||
"Includes a web terminal access token that will activate the next time the web terminal is turned on.",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -310,6 +310,12 @@ export interface SettingsImportPreview {
|
||||
* "this enables a service that listens on your network" must not hide
|
||||
* inside a generic "settings replaced" summary. */
|
||||
enables_web_terminal: boolean;
|
||||
/** Non-blank custom base URLs the import would set — endpoints, not
|
||||
* secrets, so shown verbatim to disclose a redirect of model traffic. */
|
||||
ollama_base_url: string | null;
|
||||
llamacpp_base_url: string | null;
|
||||
openai_compatible_base_url: string | null;
|
||||
gateway_api_base: string | null;
|
||||
}
|
||||
|
||||
/** What `inspect_ca_cert_path` reports about a corporate CA path. Errors ride
|
||||
|
||||
Reference in New Issue
Block a user