mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 14:13:58 +00:00
Reject symlinks in project-json
This commit is contained in:
parent
6d7511938a
commit
c01ba4a310
1 changed files with 7 additions and 1 deletions
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use std::{collections::VecDeque, fmt, fs, process::Command, sync::Arc};
|
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::{
|
use base_db::{
|
||||||
CrateDisplayName, CrateGraph, CrateId, CrateName, CrateOrigin, Dependency, Edition, Env,
|
CrateDisplayName, CrateGraph, CrateId, CrateName, CrateOrigin, Dependency, Edition, Env,
|
||||||
FileId, LangCrateOrigin, ProcMacroLoadResult, TargetLayoutLoadResult,
|
FileId, LangCrateOrigin, ProcMacroLoadResult, TargetLayoutLoadResult,
|
||||||
|
@ -154,6 +154,12 @@ impl ProjectWorkspace {
|
||||||
) -> Result<ProjectWorkspace> {
|
) -> Result<ProjectWorkspace> {
|
||||||
let res = match manifest {
|
let res = match manifest {
|
||||||
ProjectManifest::ProjectJson(project_json) => {
|
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(|| {
|
let file = fs::read_to_string(&project_json).with_context(|| {
|
||||||
format!("Failed to read json file {}", project_json.display())
|
format!("Failed to read json file {}", project_json.display())
|
||||||
})?;
|
})?;
|
||||||
|
|
Loading…
Reference in a new issue