Skip to content

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_info method to Gitaly client and Git repository layers
  • Updates SPP's PayloadProcessor to use the new raw_info field with ChangedPaths objects
  • 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

Screenshots or screen recordings

Before After

How to set up and validate locally

1. Create a New Project

  1. Navigate to your GDK GitLab instance at http://gdk.test:3000
  2. Click "New project"
  3. Choose "Create blank project"
  4. Fill in project details and create the project

2. Enable Secret Push Protection

  1. In your new project, navigate to Secure -> Security Configuration
  2. Find Secret push protection section
  3. 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.

Edited by Craig Smith

Merge request reports

Loading