Use Gitaly raw_info gRPC optimization in SPP
What does this MR do and why?
This MR implements and integrates Gitaly's raw_info gRPC endpoint optimization into Secret Push Protection (SPP) to improve performance when processing file diffs.
Changes:
- Adds
diff_blobs_with_raw_infomethod to Gitaly client and Git repository layers - Updates SPP's PayloadProcessor to use the new
raw_infofield withChangedPathsobjects - Maps GitLab's ChangedPaths status to Gitaly's protobuf format
- Handles proper file mode conversion from octal to decimal for protobuf
Note to reviewer: No tests have been added to payload_processor_spec.rb because this test mocks the private method get_diffs, where all the changes in this MR are made. In a follow up I will refactor the testing so that only the external classes are mocked, not the private functions, ensuring changes like this are tested in the relevant spec file.
References
- SPP - Switch to using raw_info in DiffBlobs RPC... (#554662) • Craig Smith • 18.6 • At risk
- [FF] `secret_detection_transition_to_raw_info_g... (#558983) • Craig Smith • 18.6
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
1. Create a New Project
- Navigate to your GDK GitLab instance at
http://gdk.test:3000 - Click "New project"
- Choose "Create blank project"
- Fill in project details and create the project
2. Enable Secret Push Protection
- In your new project, navigate to Secure -> Security Configuration
- Find Secret push protection section
- Enable the toggle to turn on SPP for this project
3. Clone the Project Locally
# Clone your project (replace with your actual project URL)
git clone http://gdk.test:3000/root/your-project-name.git
cd your-project-name
4. Create a File with a Secret
Run this command to create a file containing a secret:
touch new_file.txt && echo "glpat-00000000000000000000" >> new_file.txt && git add --all && git commit -m "test" && git push origin main
5. Verify SPP is Working
The push should fail with an error
remote: PUSH BLOCKED: Secrets detected in code changes
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.