mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Restrict file permissions to only the user for pasted kubeconfigs that are kept in the app dir (#805)
Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
This commit is contained in:
parent
435baaea00
commit
7d2215b5b4
@ -60,7 +60,7 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
|
||||
static embedCustomKubeConfig(clusterId: ClusterId, kubeConfig: KubeConfig | string): string {
|
||||
const filePath = ClusterStore.getCustomKubeConfigPath(clusterId);
|
||||
const fileContents = typeof kubeConfig == "string" ? kubeConfig : dumpConfigYaml(kubeConfig);
|
||||
saveToAppFiles(filePath, fileContents);
|
||||
saveToAppFiles(filePath, fileContents, { mode: 0o600});
|
||||
return filePath;
|
||||
}
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
// Save file to electron app directory (e.g. "/Users/$USER/Library/Application Support/Lens" for MacOS)
|
||||
import path from "path";
|
||||
import { app, remote } from "electron";
|
||||
import { ensureDirSync, writeFileSync } from "fs-extra";
|
||||
import { ensureDirSync, writeFileSync, WriteFileOptions } from "fs-extra";
|
||||
|
||||
export function saveToAppFiles(filePath: string, contents: any): string {
|
||||
export function saveToAppFiles(filePath: string, contents: any, options?: WriteFileOptions): string {
|
||||
const absPath = path.resolve((app || remote.app).getPath("userData"), filePath);
|
||||
ensureDirSync(path.dirname(absPath));
|
||||
writeFileSync(absPath, contents);
|
||||
writeFileSync(absPath, contents, options);
|
||||
return absPath;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user