fix(plugin): don't cache error responses, add SSRF guard to plugin_get

This commit is contained in:
2026-07-13 05:13:01 +08:00
parent 4dfc23d35f
commit ed04b87f16
2 changed files with 7 additions and 1 deletions
+3
View File
@@ -849,6 +849,9 @@ exec mangohud "$@"
import urllib.request
import urllib.error
try:
# SSRF guard: only allow http/https schemes
if not base_url.startswith(("http://", "https://")):
return {"error": "Invalid base_url scheme", "status": 0}
if not path.startswith("/"):
path = "/" + path
url = f"{base_url}/api{path}"
+4 -1
View File
@@ -56,7 +56,10 @@ export async function fetchPluginGame(
const path = `/plugin/game/${steamAppId}?limit=${limit}${hardware ? `&hardware=${encodeURIComponent(hardware)}` : ""}`
const raw = await pluginGet(path, settingsRef.baseUrl)
const value = raw as unknown as PluginGameResponse
cache.set(key, { value, expires: Date.now() + TTL_MS })
// Don't cache error responses — transient failures shouldn't poison the cache
if (!raw.error) {
cache.set(key, { value, expires: Date.now() + TTL_MS })
}
return value
}