Scope regex replacement to the specific block of code
Summary
Identified at #435721 (comment 1838413829), we may be applying the Regex replacement to the entire file, where it should only replace the locations within the specific code block.
Steps to reproduce
Example Project
What is the current bug behavior?
What is the expected correct behavior?
Relevant logs and/or screenshots
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true
)(we will only investigate if the tests are passing)
Implementation Plan
-
Update the MergeRequests::CreateFromVulnerabilityData service to scope the code change to the line described as vulnerable by the scanner.
This may necessitate sending a wider context to the AI so that it might hopefully give a larger diff patch that can be more accurately substituted into the file.
Edited by Gregory Havenga