kube-auth-proxy: accept only target cluster hostname (#1433)

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen authored and GitHub committed 2020-11-19 08:32:07 +02:00
1 parent 3197e3a1fe
commit c4b98534dc
2 files changed
+16 -11

No files matched your search

+7 -1
View File
@@ -4,6 +4,7 @@ import { broadcastIpc } from "../common/ipc";
import type { Cluster } from "./cluster"
import { Kubectl } from "./kubectl"
import logger from "./logger"
import * as url from "url"
export interface KubeAuthProxyLog {
data: string;
@@ -26,17 +27,22 @@ export class KubeAuthProxy {
this.kubectl = Kubectl.bundled()
}
get acceptHosts() {
return url.parse(this.cluster.apiUrl).hostname;
}
public async run(): Promise<void> {
if (this.proxyProcess) {
return;
}
const proxyBin = await this.kubectl.getPath()
const args = [
"proxy",
"-p", `${this.port}`,
"--kubeconfig", `${this.cluster.kubeConfigPath}`,
"--context", `${this.cluster.contextName}`,
"--accept-hosts", ".*",
"--accept-hosts", this.acceptHosts,
"--reject-paths", "^[^/]"
]
if (process.env.DEBUG_PROXY === "true") {