diff options
| author | bors <bors@rust-lang.org> | 2023-03-25 13:34:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-03-25 13:34:10 +0000 |
| commit | fc848495f45e4741849940a2be437a46b742ce53 (patch) | |
| tree | 803504cfac068408d70b0045a47f61ce0fc06af2 | |
| parent | 68aa1331087e51857e91be2a3dc38a5b7ac49bad (diff) | |
| parent | c01ba4a3101e343464093603b12bb5327d8a320f (diff) | |
| download | rust-fc848495f45e4741849940a2be437a46b742ce53.tar.gz rust-fc848495f45e4741849940a2be437a46b742ce53.zip | |
Auto merge of #14402 - Veykril:project-json-sym-link, r=Veykril
internal: Reject symlinks in project-json cc https://github.com/rust-lang/rust-analyzer/pull/14168
| -rw-r--r-- | crates/project-model/src/workspace.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/project-model/src/workspace.rs b/crates/project-model/src/workspace.rs index d1e53e12eeb..2158485a330 100644 --- a/crates/project-model/src/workspace.rs +++ b/crates/project-model/src/workspace.rs @@ -4,7 +4,7 @@ use std::{collections::VecDeque, fmt, fs, process::Command, sync::Arc}; -use anyhow::{format_err, Context, Result}; +use anyhow::{bail, format_err, Context, Result}; use base_db::{ CrateDisplayName, CrateGraph, CrateId, CrateName, CrateOrigin, Dependency, Edition, Env, FileId, LangCrateOrigin, ProcMacroLoadResult, TargetLayoutLoadResult, @@ -154,6 +154,12 @@ impl ProjectWorkspace { ) -> Result<ProjectWorkspace> { let res = match manifest { ProjectManifest::ProjectJson(project_json) => { + let metadata = fs::symlink_metadata(&project_json).with_context(|| { + format!("Failed to read json file {}", project_json.display()) + })?; + if metadata.is_symlink() { + bail!("The project-json may not currently point to a symlink"); + } let file = fs::read_to_string(&project_json).with_context(|| { format!("Failed to read json file {}", project_json.display()) })?; |
