Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for the propagation of vulnerabilities within git repositories #2140

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions osv/impact.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,16 @@ def _get_equivalent_commit(self,
# Ignore commits without parents and merge commits with multiple parents.
if not commit.parents or len(commit.parents) > 1:
continue

patch_id = repo.cache.get(commit.id)
if not patch_id:
#Handle repositories that do not support cache
if hasattr(repo, 'cache'):
patch_id = repo.cache.get(commit.id)
if not patch_id:
diff = repo.diff(commit.parents[0], commit)
patch_id = diff.patchid
repo.cache[commit.id] = patch_id
else:
diff = repo.diff(commit.parents[0], commit)
patch_id = diff.patchid
repo.cache[commit.id] = patch_id

if patch_id == target_patch_id:
return str(commit.id)
Expand Down
Loading