mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
Fix: some error URLs aren't sanitized (#3385)
This commit is contained in:
parent
daa51f9740
commit
ea63716b61
@ -57,7 +57,7 @@ export function jsonArrayFilter(data, filter) {
|
|||||||
export function sanitizeErrorURL(errorURL) {
|
export function sanitizeErrorURL(errorURL) {
|
||||||
// Dont display sensitive params on frontend
|
// Dont display sensitive params on frontend
|
||||||
const url = new URL(errorURL);
|
const url = new URL(errorURL);
|
||||||
["apikey", "api_key", "token", "t", "access_token"].forEach((key) => {
|
["apikey", "api_key", "token", "t", "access_token", "auth"].forEach((key) => {
|
||||||
if (url.searchParams.has(key)) url.searchParams.set(key, "***");
|
if (url.searchParams.has(key)) url.searchParams.set(key, "***");
|
||||||
});
|
});
|
||||||
return url.toString();
|
return url.toString();
|
||||||
|
@ -5,6 +5,7 @@ import { createUnzip, constants as zlibConstants } from "node:zlib";
|
|||||||
import { http, https } from "follow-redirects";
|
import { http, https } from "follow-redirects";
|
||||||
|
|
||||||
import { addCookieToJar, setCookieHeader } from "./cookie-jar";
|
import { addCookieToJar, setCookieHeader } from "./cookie-jar";
|
||||||
|
import { sanitizeErrorURL } from "./api-helpers";
|
||||||
|
|
||||||
import createLogger from "utils/logger";
|
import createLogger from "utils/logger";
|
||||||
|
|
||||||
@ -113,6 +114,11 @@ export async function httpProxy(url, params = {}) {
|
|||||||
constructedUrl.pathname,
|
constructedUrl.pathname,
|
||||||
);
|
);
|
||||||
if (err) logger.error(err);
|
if (err) logger.error(err);
|
||||||
return [500, "application/json", { error: { message: err?.message ?? "Unknown error", url, rawError: err } }, null];
|
return [
|
||||||
|
500,
|
||||||
|
"application/json",
|
||||||
|
{ error: { message: err?.message ?? "Unknown error", url: sanitizeErrorURL(url), rawError: err } },
|
||||||
|
null,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user