Skip to content

Commit 413c0bb

Browse files
committed
fix: use 0600 permissions on config.yaml
1 parent 698ad37 commit 413c0bb

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

core/util/paths.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ export function getConfigYamlPath(ideType?: IdeType): string {
113113
// https://github.com/continuedev/continue/pull/7224
114114
// This was here because we had different context provider support between jetbrains and vs code
115115
// Leaving so we could differentiate later but for now configs are the same between IDEs
116-
fs.writeFileSync(p, YAML.stringify(defaultConfig));
116+
fs.writeFileSync(p, YAML.stringify(defaultConfig), { mode: 0o600 });
117117
} else {
118-
fs.writeFileSync(p, YAML.stringify(defaultConfig));
118+
fs.writeFileSync(p, YAML.stringify(defaultConfig), { mode: 0o600 });
119119
}
120120
}
121121
return p;
@@ -255,12 +255,13 @@ function editConfigJson(
255255
}
256256

257257
function editConfigYaml(callback: (config: ConfigYaml) => ConfigYaml): void {
258-
const config = fs.readFileSync(getConfigYamlPath(), "utf8");
258+
const configPath = getConfigYamlPath();
259+
const config = fs.readFileSync(configPath, "utf8");
259260
let configYaml = YAML.parse(config);
260261
// Check if it's an object
261262
if (typeof configYaml === "object" && configYaml !== null) {
262263
configYaml = callback(configYaml as any) as any;
263-
fs.writeFileSync(getConfigYamlPath(), YAML.stringify(configYaml));
264+
fs.writeFileSync(configPath, YAML.stringify(configYaml), { mode: 0o600 });
264265
} else {
265266
console.warn("config.yaml is not a valid object");
266267
}

extensions/cli/src/freeTrialTransition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async function createOrUpdateConfig(apiKey: string): Promise<void> {
3131
: "";
3232

3333
const updatedContent = updateAnthropicModelInYaml(existingContent, apiKey);
34-
fs.writeFileSync(CONFIG_PATH, updatedContent);
34+
fs.writeFileSync(CONFIG_PATH, updatedContent, { mode: 0o600 });
3535
}
3636

3737
/**

extensions/cli/src/onboarding.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export async function createOrUpdateConfig(apiKey: string): Promise<void> {
4343
: "";
4444

4545
const updatedContent = updateAnthropicModelInYaml(existingContent, apiKey);
46-
fs.writeFileSync(CONFIG_PATH, updatedContent);
46+
fs.writeFileSync(CONFIG_PATH, updatedContent, { mode: 0o600 });
4747
}
4848

4949
export async function runOnboardingFlow(

extensions/vscode/src/commands.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,9 @@ const getCommandsMap: (
715715
const configYaml = convertJsonToYamlConfig(parsed);
716716

717717
const configYamlPath = getConfigYamlPath();
718-
fs.writeFileSync(configYamlPath, YAML.stringify(configYaml));
718+
fs.writeFileSync(configYamlPath, YAML.stringify(configYaml), {
719+
mode: 0o600,
720+
});
719721

720722
// Open config.yaml
721723
await openEditorAndRevealRange(

0 commit comments

Comments
 (0)