SECURITY BUGFIX: "false" env var value was parsed as true

This commit is contained in:
DarkCat09 2023-09-25 10:48:34 +04:00
parent 3a8198ea14
commit a8d4b3a2d3
No known key found for this signature in database
GPG Key ID: 0A26CD5B3345D6E3

View File

@ -12,8 +12,19 @@ export class ConfigService {
this.host = process.env.HOST || "0.0.0.0"; this.host = process.env.HOST || "0.0.0.0";
this.port = Number(process.env.PORT) || 8080; this.port = Number(process.env.PORT) || 8080;
this.reverse_proxy = Boolean(process.env.REVERSE_PROXY) || false; this.reverse_proxy = this.parseBool(process.env.REVERSE_PROXY, false);
this.proxy_res = Boolean(process.env.PROXY_RES) || true; this.proxy_res = this.parseBool(process.env.PROXY_RES, true);
}
parseBool(value: string | undefined, def: boolean): boolean {
if (!value) return def;
switch (value) {
case "false":
case "0":
return false;
default:
return Boolean(value);
}
} }
} }