stable

Clone or download

Read-only

Add WebAssembly to the git:pre-receive-analyze command

Git object content analysis in the git:pre-receive-analyze command is now performed by a WebAssembly module. This patch adds our Rust library called wasmtime-wrapper-lib, it is in charge of instantiating and executing WebAssembly modules. It exposes two functions, they are called by using PHP's FFI. In plugins/git/additional-packages/pre-receive-hook-example we provide Rust code to create a WebAssembly module for testing purposes. This module expects a JSON string as input, it simply checks if the word 'Tuleap' is found in the git object content. If that is the case a rejection message in JSON format, explaining the issue is returned. Otherwise, if everything is good, the rejection message will be 'null'. To build libwasmtimewrapper.so (required for proper testing): - cd plugins/git/additional-packages/wasmtime-wrapper-lib/ - nix-shell (you need to have nix installed) - cargo zigbuild --target x86_64-unknown-linux-gnu.2.17 --release To build pre-receive-hook-example.wasm (required for proper testing): - cd plugins/git/additional-packages/pre-receive-hook-example/ - nix-shell (you need to have nix installed) - cargo build --target wasm32-wasi --release To test: - tuleap config-set feature_flag_enable_pre_receive_analyze_command 1 (set the feature flag) - tuleap git:pre-receive-analyze <repo_id> <git_object_sha1> (launch the command with valid parameters) Part of story #28845 have an hidden command executing custom command to determine if the reference should have been rejected Change-Id: Iebe6d930ba46e3be6f2824d576c22add348a922a

Modified Files

Name
A plugins/git/additional-packages/pre-receive-hook-example/.gitignore +8 −0 Go to diff View file
A plugins/git/additional-packages/pre-receive-hook-example/Cargo.lock +89 −0 Go to diff View file
A plugins/git/additional-packages/pre-receive-hook-example/Cargo.toml +8 −0 Go to diff View file
A plugins/git/additional-packages/pre-receive-hook-example/shell.nix +10 −0 Go to diff View file
A plugins/git/additional-packages/pre-receive-hook-example/src/main.rs +45 −0 Go to diff View file
R plugins/git/additional-packages/pre-receive-rs/src/wire.rs Go to diff View file
D plugins/git/additional-packages/pre-receive-rs/Cargo.lock +0 −314 Go to diff View file
D plugins/git/additional-packages/pre-receive-rs/Cargo.toml +0 −16 Go to diff View file
D plugins/git/additional-packages/pre-receive-rs/cbindgen.toml +0 −2 Go to diff View file
D plugins/git/additional-packages/pre-receive-rs/src/lib.rs +0 −92 Go to diff View file
R plugins/git/additional-packages/pre-receive-rs/.gitignore Go to diff View file
A plugins/git/additional-packages/wasmtime-wrapper-lib/Cargo.lock +1798 −0 Go to diff View file
A plugins/git/additional-packages/wasmtime-wrapper-lib/Cargo.toml +20 −0 Go to diff View file
R plugins/git/additional-packages/pre-receive-rs/build.rs Go to diff View file
A plugins/git/additional-packages/wasmtime-wrapper-lib/cbindgen.toml +2 −0 Go to diff View file
R plugins/git/additional-packages/pre-receive-rs/shell.nix Go to diff View file
A plugins/git/additional-packages/wasmtime-wrapper-lib/src/lib.rs +215 −0 Go to diff View file
A plugins/git/additional-packages/wasmtime-wrapper-lib/src/wire.rs +39 −0 Go to diff View file
M plugins/git/include/Hook/PreReceive/PreReceiveAnalyzeFFI.php +4 −3 Go to diff View file
M plugins/git/include/Hook/PreReceive/WASMFFICallerStub.php +2 −2 Go to diff View file