mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-17 04:11:35 +00:00
The desktop feed base came from config.yaml's updates.desktop_feed_base_url and then an undocumented env var. Config already wins and is the documented override; a second env source only lets a stray variable redirect where updates are fetched from. Remove the fallback from resolveFeedBaseUrl, its caller, its test cases and the Windows bundled E2E that blanked it.
52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
import { readFileSync } from 'node:fs'
|
|
|
|
import { load } from 'js-yaml'
|
|
|
|
import { channelPublicBase } from './channel-protocol'
|
|
|
|
/**
|
|
* The feed base a bundled install downloads its update descriptor from:
|
|
* config.yaml's `updates.desktop_feed_base_url`, else '' (the OS-registered
|
|
* App Installer source / no feed). Config is the one override: a second env
|
|
* source would let a stray variable silently redirect updates. A configured
|
|
* value is held to the same rule as every other update origin
|
|
* (channelPublicBase: HTTPS or loopback, no credentials/traversal) — the
|
|
* descriptor is fetched and opened unverified, so a plain-http base would
|
|
* hand a network attacker the update source. Throws on a bad value rather
|
|
* than silently falling back, so the misconfiguration is named.
|
|
*/
|
|
export function resolveFeedBaseUrl(configured: string): string {
|
|
const value: string = configured.trim()
|
|
|
|
if (!value) {
|
|
return ''
|
|
}
|
|
|
|
channelPublicBase(value)
|
|
|
|
return value
|
|
}
|
|
|
|
export function readUpdatesFeedBaseFromConfig(configPath: string): string {
|
|
try {
|
|
// YAML permits scalar and sequence roots; validate the nested string at this I/O boundary.
|
|
const config: unknown = load(readFileSync(configPath, 'utf8'))
|
|
|
|
if (!config || typeof config !== 'object' || !('updates' in config)) {
|
|
return ''
|
|
}
|
|
|
|
const updates: unknown = config.updates
|
|
|
|
if (!updates || typeof updates !== 'object' || !('desktop_feed_base_url' in updates)) {
|
|
return ''
|
|
}
|
|
|
|
const value: unknown = updates.desktop_feed_base_url
|
|
|
|
return typeof value === 'string' ? value.trim() : ''
|
|
} catch {
|
|
// An absent/unreadable override leaves the registered feed eligible.
|
|
return ''
|
|
}
|
|
}
|