Fix: kubeconfig tmp file security (#2894)

Signed-off-by: Yin Da <yd219913@alibaba-inc.com>
This commit is contained in:
Somefive
2021-12-08 09:12:07 +08:00
committed by GitHub
parent 41e6a895a1
commit 330c3e269c
+1 -1
View File
@@ -184,7 +184,7 @@ func (c *clusterUsecaseImpl) ListKubeClusters(ctx context.Context, query string,
}
func joinClusterByKubeConfigString(ctx context.Context, k8sClient client.Client, clusterName string, kubeConfig string) (string, error) {
tmpFileName := fmt.Sprintf("/tmp/cluster-secret-%s-%s-%d.kubeconfig", clusterName, utils.RandomString(8), time.Now().UnixNano())
tmpFileName := fmt.Sprintf("/tmp/cluster-secret-%s-%d.kubeconfig", utils.RandomString(8), time.Now().UnixNano())
if err := ioutil.WriteFile(tmpFileName, []byte(kubeConfig), 0600); err != nil {
return "", errors.Wrapf(err, "failed to write kubeconfig to temp file %s", tmpFileName)
}