Skip to content
Merged
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
8 changes: 4 additions & 4 deletions vulnerabilities/api_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,11 +761,11 @@ def get_affected_advisories_bulk(packages, max_advisories, base_url, reachabilit
"exploitability": exploitability,
"risk_score": risk_score,
"fixed_by_packages": fixed_by_packages,
"introduced_in_patch": introduced_patches_by_set.get(
"introduced_in_patches": introduced_patches_by_set.get(
adv.id,
[],
),
"fixed_in_patch": fixed_patches_by_set.get(
"fixed_in_patches": fixed_patches_by_set.get(
adv.id,
[],
),
Expand Down Expand Up @@ -864,8 +864,8 @@ def get_affected_advisories_bulk(packages, max_advisories, base_url, reachabilit
"exploitability": advisory.exploitability,
"risk_score": advisory.risk_score,
"fixed_by_packages": fixed_by_packages,
"introduced_in_patch": introduced_patches_by_set.get(advisory_id, []),
"fixed_in_patch": introduced_patches_by_set.get(advisory_id, []),
"introduced_in_patches": introduced_patches_by_set.get(advisory_id, []),
"fixed_in_patches": introduced_patches_by_set.get(advisory_id, []),
"ssvc_trees": [
{
"vector": ssvc.vector,
Expand Down
12 changes: 7 additions & 5 deletions vulnerabilities/tests/test_api_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,14 +330,14 @@ def test_packages_commit_patch(self):
advisory_data = vulns[0]

assert advisory_data["advisory_id"] == "AVID-123"
assert advisory_data["introduced_in_patch"] == [
assert advisory_data["introduced_in_patches"] == [
{
"commit_hash": "06580c7f99c6fde7bcf18e30bdcc61f081430957",
"vcs_url": "https://github.com/aboutcode-org/sample",
}
]

assert advisory_data["fixed_in_patch"] == [
assert advisory_data["fixed_in_patches"] == [
{
"commit_hash": "98e516011d6e096e25247b82fc5f196bbeecff10",
"vcs_url": "https://github.com/aboutcode-org/sample",
Expand Down Expand Up @@ -450,7 +450,7 @@ def test_packages_commit_patch(self):
assert {
"commit_hash": "06580c7f99c6fde7bcf18e30bdcc61f081430957",
"vcs_url": "https://github.com/aboutcode-org/sample",
} in advisory_data["introduced_in_patch"]
} in advisory_data["introduced_in_patches"]

def test_advisory_set_member_patches_aggregation(self):
url = reverse("package-v3-list")
Expand All @@ -472,10 +472,12 @@ def test_advisory_set_member_patches_aggregation(self):
advisory_data = vulns[0]
assert advisory_data["advisory_id"] == "AVID-123"

introduced_hashes = [patch["commit_hash"] for patch in advisory_data["introduced_in_patch"]]
introduced_hashes = [
patch["commit_hash"] for patch in advisory_data["introduced_in_patches"]
]
assert "06580c7f99c6fde7bcf18e30bdcc61f081430957" in introduced_hashes
assert "98e516011d6e096e25247b82fc5f196bbeecff10" in introduced_hashes

fixed_hashes = [patch["commit_hash"] for patch in advisory_data["fixed_in_patch"]]
fixed_hashes = [patch["commit_hash"] for patch in advisory_data["fixed_in_patches"]]
assert "98e516011d6e096e25247b82fc5f196bbeecff10" in fixed_hashes
assert "2fc5f196bbeecff1098e516011d6e096e25247b8" in fixed_hashes