Skip to content

Commit c01ba4a

Browse files
committed
Reject symlinks in project-json
1 parent 6d75119 commit c01ba4a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

crates/project-model/src/workspace.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
use std::{collections::VecDeque, fmt, fs, process::Command, sync::Arc};
66

7-
use anyhow::{format_err, Context, Result};
7+
use anyhow::{bail, format_err, Context, Result};
88
use base_db::{
99
CrateDisplayName, CrateGraph, CrateId, CrateName, CrateOrigin, Dependency, Edition, Env,
1010
FileId, LangCrateOrigin, ProcMacroLoadResult, TargetLayoutLoadResult,
@@ -154,6 +154,12 @@ impl ProjectWorkspace {
154154
) -> Result<ProjectWorkspace> {
155155
let res = match manifest {
156156
ProjectManifest::ProjectJson(project_json) => {
157+
let metadata = fs::symlink_metadata(&project_json).with_context(|| {
158+
format!("Failed to read json file {}", project_json.display())
159+
})?;
160+
if metadata.is_symlink() {
161+
bail!("The project-json may not currently point to a symlink");
162+
}
157163
let file = fs::read_to_string(&project_json).with_context(|| {
158164
format!("Failed to read json file {}", project_json.display())
159165
})?;

0 commit comments

Comments
 (0)