Skip to content

Commit ef1df71

Browse files
authored
Merge pull request #1654 from aboutcode-org/fix_api_error
Fix API bug
2 parents bac2274 + fe4073f commit ef1df71

File tree

6 files changed

+67
-28
lines changed

6 files changed

+67
-28
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
Release notes
22
=============
33

4-
Version (next)
5-
-----------------------
4+
Version v34.3.1
5+
----------------
6+
7+
- HOTFIX: Fix API bug #1654
68

79

810
Version v34.3.0

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = vulnerablecode
3-
version = 34.3.0
3+
version = 34.3.1
44
license = Apache-2.0 AND CC-BY-SA-4.0
55

66
# description must be on ONE line https://github.com/pypa/setuptools/issues/1390

vulnerabilities/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def get_vulnerabilities_for_a_package(self, package, fix) -> dict:
323323
otherwise return vulnerabilities fixed by the `package`.
324324
"""
325325
fixed_packages = self.get_fixed_packages(package=package)
326-
if fix:
326+
if not fix:
327327
qs = package.affected_by_vulnerabilities.all()
328328
else:
329329
qs = package.fixing_vulnerabilities.all()
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Generated by Django 4.2.16 on 2024-11-15 02:18
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("vulnerabilities", "0079_alter_packagechangelog_software_version_and_more"),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name="packagechangelog",
15+
name="software_version",
16+
field=models.CharField(
17+
default="34.3.1",
18+
help_text="Version of the software at the time of change",
19+
max_length=100,
20+
),
21+
),
22+
migrations.AlterField(
23+
model_name="vulnerabilitychangelog",
24+
name="software_version",
25+
field=models.CharField(
26+
default="34.3.1",
27+
help_text="Version of the software at the time of change",
28+
max_length=100,
29+
),
30+
),
31+
]

vulnerabilities/tests/test_api.py

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -583,50 +583,56 @@ def test_api_with_lesser_and_greater_fixed_by_packages(self):
583583
"next_non_vulnerable_version": "2.14.0-rc1",
584584
"latest_non_vulnerable_version": "2.14.0-rc1",
585585
"affected_by_vulnerabilities": [
586-
{
587-
"url": "http://testserver/api/vulnerabilities/{0}".format(self.vul3.id),
588-
"vulnerability_id": "VCID-vul3-vul3-vul3",
589-
"summary": "This is VCID-vul3-vul3-vul3",
590-
"references": [],
591-
"fixed_packages": [],
592-
"aliases": ["CVE-2021-46877", "GHSA-3x8x-79m2-3w2w"],
593-
"resource_url": "http://testserver/vulnerabilities/VCID-vul3-vul3-vul3",
594-
}
595-
],
596-
"fixing_vulnerabilities": [
597586
{
598587
"url": "http://testserver/api/vulnerabilities/{0}".format(self.vul1.id),
599588
"vulnerability_id": "VCID-vul1-vul1-vul1",
600589
"summary": "This is VCID-vul1-vul1-vul1",
601590
"references": [],
602591
"fixed_packages": [
603592
{
604-
"url": "http://testserver/api/packages/{0}".format(
605-
self.pkg_2_12_6_1.id
606-
),
607-
"purl": "pkg:maven/com.fasterxml.jackson.core/jackson-databind@2.12.6.1",
593+
"url": "http://testserver/api/packages/{0}".format(self.pkg_2_13_2.id),
594+
"purl": "pkg:maven/com.fasterxml.jackson.core/jackson-databind@2.13.2",
608595
"is_vulnerable": True,
609596
"affected_by_vulnerabilities": [
610597
{"vulnerability": "VCID-vul2-vul2-vul2"}
611598
],
612-
"resource_url": "http://testserver/packages/pkg:maven/com.fasterxml.jackson.core/jackson-databind@2.12.6.1",
599+
"resource_url": "http://testserver/packages/pkg:maven/com.fasterxml.jackson.core/jackson-databind@2.13.2",
600+
}
601+
],
602+
"aliases": ["CVE-2020-36518", "GHSA-57j2-w4cx-62h2"],
603+
"resource_url": "http://testserver/vulnerabilities/VCID-vul1-vul1-vul1",
604+
}
605+
],
606+
"fixing_vulnerabilities": [
607+
{
608+
"url": "http://testserver/api/vulnerabilities/{0}".format(self.vul3.id),
609+
"vulnerability_id": "VCID-vul3-vul3-vul3",
610+
"summary": "This is VCID-vul3-vul3-vul3",
611+
"references": [],
612+
"fixed_packages": [
613+
{
614+
"url": "http://testserver/api/packages/{0}".format(self.pkg_2_12_6.id),
615+
"purl": "pkg:maven/com.fasterxml.jackson.core/jackson-databind@2.12.6",
616+
"is_vulnerable": False,
617+
"affected_by_vulnerabilities": [],
618+
"resource_url": "http://testserver/packages/pkg:maven/com.fasterxml.jackson.core/jackson-databind@2.12.6",
613619
},
614620
{
615-
"url": "http://testserver/api/packages/{0}".format(self.pkg_2_13_2.id),
616-
"purl": "pkg:maven/com.fasterxml.jackson.core/jackson-databind@2.13.2",
621+
"url": "http://testserver/api/packages/{0}".format(self.pkg_2_13_1.id),
622+
"purl": "pkg:maven/com.fasterxml.jackson.core/jackson-databind@2.13.1",
617623
"is_vulnerable": True,
618624
"affected_by_vulnerabilities": [
619-
{"vulnerability": "VCID-vul2-vul2-vul2"}
625+
{"vulnerability": "VCID-vul1-vul1-vul1"}
620626
],
621-
"resource_url": "http://testserver/packages/pkg:maven/com.fasterxml.jackson.core/jackson-databind@2.13.2",
627+
"resource_url": "http://testserver/packages/pkg:maven/com.fasterxml.jackson.core/jackson-databind@2.13.1",
622628
},
623629
],
624-
"aliases": ["CVE-2020-36518", "GHSA-57j2-w4cx-62h2"],
625-
"resource_url": "http://testserver/vulnerabilities/VCID-vul1-vul1-vul1",
630+
"aliases": ["CVE-2021-46877", "GHSA-3x8x-79m2-3w2w"],
631+
"resource_url": "http://testserver/vulnerabilities/VCID-vul3-vul3-vul3",
626632
}
627633
],
628-
"resource_url": "http://testserver/packages/pkg:maven/com.fasterxml.jackson.core/jackson-databind@2.13.1",
629634
"risk_score": None,
635+
"resource_url": "http://testserver/packages/pkg:maven/com.fasterxml.jackson.core/jackson-databind@2.13.1",
630636
}
631637

632638
assert response == expected

vulnerablecode/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import warnings
1313
from pathlib import Path
1414

15-
__version__ = "34.3.0"
15+
__version__ = "34.3.1"
1616

1717

1818
def command_line():

0 commit comments

Comments
 (0)