Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to completely disable rust-analyzer for a project or directory? #7362

Closed
kornelski opened this issue Jan 20, 2021 · 4 comments
Closed

How to completely disable rust-analyzer for a project or directory? #7362

kornelski opened this issue Jan 20, 2021 · 4 comments

Comments

@kornelski
Copy link
Contributor

kornelski commented Jan 20, 2021

I'm writing a code review tool (cargo-crev). It's meant for reviewing untrusted 3rd party code. There's a risk that malicious code could use build-time code execution (build.rs or proc-macros) to launch an attack on the reviewer's machine and/or use it to hide the malicious code.

I've noticed that IDEs that integrate with rust-analyzer automatically build any Rust project they open (target dir appears), so just looking at a Rust crate executes untrusted code! I'm not entirely sure whether that's caused by rust-analyzer itself, or just cargo check that usually goes with it.

Is there a way to disable rust-analyzer for such project folder? Or tell it not to trust any code nor any of its dependencies?

There's a request for a single file #3660, but I'm looking for a crate-wide solution. I'd rather not modify source code, but I can inject/change config files.

@lnicola
Copy link
Member

lnicola commented Jan 20, 2021

You can disable proc macro and build script support (off by default for now) and running cargo check (on by default).

There's no editor-agnostic configuration yet, but for Code you can add a project-specific configuration file.

@kornelski
Copy link
Contributor Author

It'd be great if there was editor-agnostic way for it, something like .rust-analyzer.toml that I could drop into a directory.

@matklad
Copy link
Member

matklad commented Jan 20, 2021

Setting cargo target dir to /dev/null in .cargo/config might do the trick

@lnicola
Copy link
Member

lnicola commented Jan 20, 2021

That's #6113. Let's close this in favour of that to keep things tidy.

cargo target dir

Or even the cargo target.

@lnicola lnicola closed this as completed Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants