From 8213bbb14a02fb6cee64dc300f2e54ccf378b647 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Tue, 10 Sep 2024 15:28:37 +0100 Subject: [PATCH] Rust: Add a README.md --- rust/README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 rust/README.md diff --git a/rust/README.md b/rust/README.md new file mode 100644 index 00000000000..1dcfdd330ae --- /dev/null +++ b/rust/README.md @@ -0,0 +1,42 @@ +# Rust on CodeQL + +## Development + +### Dependencies + +At present you need to be in the `rust-experiment` branch (or a branch on top of that) in both the `semmle-code` and `codeql` repos. + +TODO: are there any dependencies that aren't already CodeQL dependencies? bazel and rustc? + +### Building the Rust Extractor + +This approach uses a released `codeql` version and is simpler to use for QL development. From your `semmle-code` directory run: +```bash +bazel run @codeql//rust:rust-installer +``` +You now need to create a [per-user CodeQL configuration file](https://docs.github.com/en/code-security/codeql-cli/using-the-advanced-functionality-of-the-codeql-cli/specifying-command-options-in-a-codeql-configuration-file#using-a-codeql-configuration-file) and specify the option: +``` +--search-path Users/YOURUSERNAME/semmle-code/ql +``` +(or wherever the `ql` directory is on your system) + +You can now use the Rust extractor e.g. to run Rust tests from the command line or in VSCode. + +### Building the Rust Extractor (as a sembuild target) + +This approach allows you to build a Rust extractor with a CLI built from source. From your `semmle-code` directory run: +```bash +./build target/intree/codeql-rust +``` +You can now invoke it directly, for example to run some tests: +```bash +./target/intree/codeql-rust/codeql test run ql/rust/ql/test/PATH/TO/TEST/ +``` + +### Building a Database + +TODO + +### Code Generation + +TODO