feat: add patch generation for OSV dependency fixes#68
Open
Aharshi3614 wants to merge 7 commits into
Open
Conversation
|
@ionfwsrijan this pr is mergeble but there is one thing by this pr the mock data is getting pushed instead of using real OSV database, also check the ci passes too |
Author
|
@Tushar-sonawane06 Fixed — mock data removed, now raises FileNotFoundError when osv_output.json is missing |
Owner
|
@Aharshi3614 Great work! I'm running the tests now |
Owner
|
@Aharshi3614 Fix the failing tests |
Author
|
@ionfwsrijan I guess it should run now |
Owner
|
@Aharshi3614 It needs formatting |
Author
|
@ionfwsrijan Formatter applied. CI should pass now.
|
Owner
|
@Aharshi3614 Still failing. Join our dc server to connect with fellow contributors and mentors. They'll help you out. |
7292fdc to
29f6eb9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Closes #62
What this PR does
Adds actual code patch generation to the remediation engine for OSV dependency findings. Previously, the
/fixendpoint only returned text recommendations withdiff: null. Now, for dependency vulnerabilities, it generates unified diffs showing exactly what changes to make (e.g., upgradingrequests==2.28.0torequests==2.31.0in requirements.txt). This makes remediation suggestions actionable and ready for PR generation.Type of change
ML tier (if applicable)
Changes
Backend
backend/app/remediation/patch_generator.py- Core patch generation logic using Python's difflibbackend/app/remediation/diff_utils.py- Utility functions for unified diff formattingbackend/app/remediation/osv_parser.py- Parses OSV finding data to extract package name and version infobackend/app/remediation/engine.py- Integrates patch generation intopropose_fixes()for OSV findingsdifffield inFixmodel (already existed) is now populated with actual unified diff stringsFrontend
New dependencies
difflib,json,pathlib)Database / schema changes
Testing
How did you test this?
requirements.txt(requests==2.28.0)/fixendpoint with the finding IDpytest tests/test_patch_generator.pypytest tests/test_integration_patches.pyChecklist
console.erroror unhandled Python exceptions introducedrequirements.txt/package.jsonupdated if new dependencies added (no new deps).pkl,.pt, etc.) are gitignored, not committed (N/A)Anything reviewers should focus on
requirements.txtandpackage.json. Should we addgo.mod,Cargo.toml, etc. in this PR or follow-up?Screenshots (if UI changed)
N/A - backend change only. Example API response:
{ "finding_id": "osv:PYSEC-2024-123", "diff": "--- a/requirements.txt\n+++ b/requirements.txt\n-requests==2.28.0\n+requests==2.31.0" }