Skip to content

Commit 29ff24c

Browse files
authored
Merge branch 'aboutcode-org:main' into Page-Updated
2 parents 397210d + c21bf1f commit 29ff24c

38 files changed

+1925
-283
lines changed

CHANGELOG.rst

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

4-
Version (next)
5-
-----------------------
4+
5+
Version v35.0.0
6+
---------------------
7+
8+
- Add scores in bulk search V1 API #1675
9+
- Add improver pipeline to flag ghost packages #644 #917 #1395 by @keshav-space in https://github.com/aboutcode-org/vulnerablecode/pull/1533
10+
- Add base pipeline for importers and migrate PyPa importer to aboutcode pipeline by @keshav-space in https://github.com/aboutcode-org/vulnerablecode/pull/1559
11+
- Remove dupe Package.get_non_vulnerable_versions by @pombredanne in https://github.com/aboutcode-org/vulnerablecode/pull/1570
12+
- Import data from GSD #706 by @ziadhany in https://github.com/aboutcode-org/vulnerablecode/pull/787
13+
- Add curl advisories importer by @ambuj-1211 in https://github.com/aboutcode-org/vulnerablecode/pull/1439
14+
- Update dependencies by @TG1999 in https://github.com/aboutcode-org/vulnerablecode/pull/1590
15+
- Bump django from 4.2.0 to 4.2.15 by @dependabot in https://github.com/aboutcode-org/vulnerablecode/pull/1591
16+
- Bump cryptography from 42.0.4 to 43.0.1 by @dependabot in https://github.com/aboutcode-org/vulnerablecode/pull/1582
17+
- Bump actions/download-artifact from 3 to 4.1.7 in /.github/workflows by @dependabot in https://github.com/aboutcode-org/vulnerablecode/pull/1581
18+
- Improve export command by @pombredanne in https://github.com/aboutcode-org/vulnerablecode/pull/1571
19+
- Fix typo in Kev requests import by @ziadhany in https://github.com/aboutcode-org/vulnerablecode/pull/1594
20+
- Prepare for release v34.0.1 by @TG1999 in https://github.com/aboutcode-org/vulnerablecode/pull/1595
21+
- Bump upload-artifact to v4 by @keshav-space in https://github.com/aboutcode-org/vulnerablecode/pull/1596
22+
- Migrate Npm importer to aboutcode pipeline by @keshav-space in https://github.com/aboutcode-org/vulnerablecode/pull/1574
23+
- Use correct regex for CVE by @pombredanne in https://github.com/aboutcode-org/vulnerablecode/pull/1599
24+
- Migrate Nginx importer to aboutcode pipeline by @keshav-space in https://github.com/aboutcode-org/vulnerablecode/pull/1575
25+
- Migrate GitLab importer to aboutcode pipeline by @keshav-space in https://github.com/aboutcode-org/vulnerablecode/pull/1580
26+
- Migrate GitHub importer to aboutcode pipeline by @keshav-space in https://github.com/aboutcode-org/vulnerablecode/pull/1584
27+
- Migrate NVD importer to aboutcode pipeline by @keshav-space in https://github.com/aboutcode-org/vulnerablecode/pull/1587
28+
- Match affected and fixed-by Packages by @johnmhoran in https://github.com/aboutcode-org/vulnerablecode/pull/1528
29+
- Add management command to commit exported data by @keshav-space in https://github.com/aboutcode-org/vulnerablecode/pull/1600
30+
- Add support to Exploits model by @ziadhany in https://github.com/aboutcode-org/vulnerablecode/pull/1562
31+
- Fix 500 Server Error with DRF browsable API and resolve blank Swagger API documentation by @keshav-space in https://github.com/aboutcode-org/vulnerablecode/pull/1603
32+
- Release v34.0.2 by @TG1999 in https://github.com/aboutcode-org/vulnerablecode/pull/1604
33+
- Bump VCIO version by @TG1999 in https://github.com/aboutcode-org/vulnerablecode/pull/1605
34+
- Bump django from 4.2.15 to 4.2.16 by @dependabot in https://github.com/aboutcode-org/vulnerablecode/pull/1608
35+
- Bump fetchcode from v0.3.0 to v0.6.0 by @keshav-space in https://github.com/aboutcode-org/vulnerablecode/pull/1607
36+
- Use 4-tier system for storing package metadata by @keshav-space in https://github.com/aboutcode-org/vulnerablecode/pull/1609
37+
- Fix vers range crash by @pombredanne in https://github.com/aboutcode-org/vulnerablecode/pull/1598
38+
- Add GitHub action to publish aboutcode.hashid PyPI by @keshav-space in https://github.com/aboutcode-org/vulnerablecode/pull/1615
39+
- Segregate PackageRelatedVulnerability model to new models by @TG1999 in https://github.com/aboutcode-org/vulnerablecode/pull/1612
40+
- Add documentation for new pipeline design by @keshav-space in https://github.com/aboutcode-org/vulnerablecode/pull/1621
41+
- Fix 500 error in /api/cpes endpoint by @keshav-space in https://github.com/aboutcode-org/vulnerablecode/pull/1629
42+
- Migrate pysec importer to aboutcode pipeline by @keshav-space in https://github.com/aboutcode-org/vulnerablecode/pull/1628
43+
- Avoid memory exhaustion during data migration by @keshav-space in https://github.com/aboutcode-org/vulnerablecode/pull/1630
44+
- Add support for Calculating Risk in VulnerableCode by @ziadhany in https://github.com/aboutcode-org/vulnerablecode/pull/1593
45+
- Bulk create in migrations by @TG1999 in https://github.com/aboutcode-org/vulnerablecode/pull/1640
46+
- Update README.rst by @TG1999 in https://github.com/aboutcode-org/vulnerablecode/pull/1641
47+
- Prepare for release v34.1.0 by @TG1999 in https://github.com/aboutcode-org/vulnerablecode/pull/1642
48+
- Add V2 API endpoints by @TG1999 in https://github.com/aboutcode-org/vulnerablecode/pull/1631
49+
- Prepare for release v34.2.0 by @TG1999 in https://github.com/aboutcode-org/vulnerablecode/pull/1647
50+
- Refactor severity score model and fix incorrect suse scores by @keshav-space in https://github.com/aboutcode-org/vulnerablecode/pull/1636
51+
- Add bulk search in v2 by @TG1999 in https://github.com/aboutcode-org/vulnerablecode/pull/1649
52+
- Prepare release v34.3.0 by @TG1999 in https://github.com/aboutcode-org/vulnerablecode/pull/1652
53+
- Add `on_failure` to handle cleanup during pipeline failure by @keshav-space in https://github.com/aboutcode-org/vulnerablecode/pull/1651
54+
- Fix API bug by @TG1999 in https://github.com/aboutcode-org/vulnerablecode/pull/1654
55+
- Add reference score to package endpoint by @keshav-space in https://github.com/aboutcode-org/vulnerablecode/pull/1655
56+
- Prepare for release v34.3.2 by @TG1999 in https://github.com/aboutcode-org/vulnerablecode/pull/1656
57+
- Add support for storing exploitability and weighted severity by @ziadhany in https://github.com/aboutcode-org/vulnerablecode/pull/1646
58+
- Avoid migrations on version bumps by @keshav-space in https://github.com/aboutcode-org/vulnerablecode/pull/1660
59+
- Prepare v35.0.0rc1 by @TG1999 in https://github.com/aboutcode-org/vulnerablecode/pull/1664
60+
61+
62+
63+
Version v35.0.0rc1
64+
---------------------
65+
66+
- Add support for storing exploitability and weighted severity #1646
67+
- Avoid migrations on version bumps #1660
68+
69+
70+
Version v34.3.2
71+
----------------
72+
73+
- HOTFIX: Add reference score to package endpoint #1655
74+
75+
76+
Version v34.3.1
77+
----------------
78+
79+
- HOTFIX: Fix API bug #1654
80+
81+
82+
Version v34.3.0
83+
-----------------
84+
85+
- Add bulk search in v2 #1649
86+
- Refactor severity score model and fix incorrect suse scores #1636
687

788

889
Version v34.2.0

docs/source/contributing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Helpful Resources
8989

9090
- Review our `comprehensive guide <https://scancode-toolkit.readthedocs.io/en/latest/contribute/index.html>`_
9191
for more details on how to add quality contributions to our codebase and documentation
92-
- Check this free resource on `how to contribute to an open source project on github <https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github>`_
92+
- Check this free resource on `How to contribute to an open source project on github <https://egghead.io/lessons/javascript-identifying-how-to-contribute-to-an-open-source-project-on-github>`_
9393
- Follow `this wiki page <https://aboutcode.readthedocs.io/en/latest/contributing/writing_good_commit_messages.html>`_
9494
on how to write good commit messages
9595
- `Pro Git book <https://git-scm.com/book/en/v2>`_

docs/source/tutorial_add_importer_pipeline.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,14 @@ version management from `univers <https://github.com/aboutcode-org/univers>`_.
298298
**advisories_count** should never be directly added in steps.
299299

300300

301+
.. attention::
302+
303+
Implement ``on_failure`` to handle cleanup in case of pipeline failure.
304+
Cleanup of downloaded archives or cloned repos is necessary to avoid potential resource leakage.
301305

302306
.. note::
303307

304-
| Use ``make valid`` to format your code using black and isort automatically.
308+
| Use ``make valid`` to format your new code using black and isort automatically.
305309
| Use ``make check`` to check for formatting errors.
306310
307311
Register the Importer Pipeline

docs/source/tutorial_add_improver_pipeline.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ methods.
187187
self.log(f"Successfully flagged {ghost_package_count:,d} ghost Packages")
188188
189189
190+
.. attention::
191+
192+
Implement ``on_failure`` to handle cleanup in case of pipeline failure.
193+
Cleanup of downloaded archives or cloned repos is necessary to avoid potential resource leakage.
194+
190195
.. note::
191196

192197
| Use ``make valid`` to format your new code using black and isort automatically.

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.2.0
3+
version = 35.0.0
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: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222
from rest_framework import viewsets
2323
from rest_framework.decorators import action
2424
from rest_framework.response import Response
25-
from rest_framework.reverse import reverse
2625
from rest_framework.throttling import AnonRateThrottle
27-
from rest_framework.throttling import UserRateThrottle
2826

2927
from vulnerabilities.models import Alias
3028
from vulnerabilities.models import Exploit
@@ -54,13 +52,25 @@ def to_representation(self, instance):
5452

5553

5654
class VulnerabilityReferenceSerializer(serializers.ModelSerializer):
57-
scores = VulnerabilitySeveritySerializer(many=True, source="vulnerabilityseverity_set")
55+
scores = serializers.SerializerMethodField()
5856
reference_url = serializers.CharField(source="url")
5957

6058
class Meta:
6159
model = VulnerabilityReference
6260
fields = ["reference_url", "reference_id", "reference_type", "scores", "url"]
6361

62+
def get_scores(self, instance):
63+
severities_related_to_reference = [
64+
severity
65+
for severity in self.context.get("severities", [])
66+
if severity.url == instance.url
67+
]
68+
69+
return VulnerabilitySeveritySerializer(
70+
severities_related_to_reference,
71+
many=True,
72+
).data
73+
6474

6575
class BaseResourceSerializer(serializers.HyperlinkedModelSerializer):
6676
"""
@@ -143,17 +153,39 @@ class VulnSerializerRefsAndSummary(BaseResourceSerializer):
143153
many=True, source="filtered_fixed_packages", read_only=True
144154
)
145155

146-
references = VulnerabilityReferenceSerializer(many=True, source="vulnerabilityreference_set")
156+
references = serializers.SerializerMethodField()
147157

148158
aliases = serializers.SerializerMethodField()
149159

150160
def get_aliases(self, obj):
151161
# Assuming `obj.aliases` is a queryset of `Alias` objects
152162
return [alias.alias for alias in obj.aliases.all()]
153163

164+
def get_references(self, vulnerability):
165+
references = vulnerability.vulnerabilityreference_set.all()
166+
severities = vulnerability.severities.all()
167+
168+
serialized_references = VulnerabilityReferenceSerializer(
169+
references,
170+
context={"severities": severities},
171+
many=True,
172+
).data
173+
174+
return serialized_references
175+
154176
class Meta:
155177
model = Vulnerability
156-
fields = ["url", "vulnerability_id", "summary", "references", "fixed_packages", "aliases"]
178+
fields = [
179+
"url",
180+
"vulnerability_id",
181+
"summary",
182+
"references",
183+
"fixed_packages",
184+
"aliases",
185+
"risk_score",
186+
"exploitability",
187+
"weighted_severity",
188+
]
157189

158190

159191
class WeaknessSerializer(serializers.HyperlinkedModelSerializer):
@@ -199,8 +231,7 @@ class VulnerabilitySerializer(BaseResourceSerializer):
199231
many=True, source="filtered_fixed_packages", read_only=True
200232
)
201233
affected_packages = MinimalPackageSerializer(many=True, read_only=True)
202-
203-
references = VulnerabilityReferenceSerializer(many=True, source="vulnerabilityreference_set")
234+
references = serializers.SerializerMethodField()
204235
aliases = AliasSerializer(many=True, source="alias")
205236
exploits = ExploitSerializer(many=True, read_only=True)
206237
weaknesses = WeaknessSerializer(many=True)
@@ -214,10 +245,22 @@ def to_representation(self, instance):
214245

215246
return data
216247

248+
def get_references(self, vulnerability):
249+
references = vulnerability.vulnerabilityreference_set.all()
250+
severities = vulnerability.severities.all()
251+
252+
serialized_references = VulnerabilityReferenceSerializer(
253+
references,
254+
context={"severities": severities},
255+
many=True,
256+
).data
257+
258+
return serialized_references
259+
217260
def get_severity_range_score(self, instance):
218261
severity_vectors = []
219262
severity_values = set()
220-
for s in instance.severities:
263+
for s in instance.severities.all():
221264
if s.scoring_system == EPSS.identifier:
222265
continue
223266

@@ -251,6 +294,9 @@ class Meta:
251294
"weaknesses",
252295
"exploits",
253296
"severity_range_score",
297+
"exploitability",
298+
"weighted_severity",
299+
"risk_score",
254300
]
255301

256302

@@ -300,7 +346,7 @@ def get_vulnerabilities_for_a_package(self, package, fix) -> dict:
300346
otherwise return vulnerabilities fixed by the `package`.
301347
"""
302348
fixed_packages = self.get_fixed_packages(package=package)
303-
if fix:
349+
if not fix:
304350
qs = package.affected_by_vulnerabilities.all()
305351
else:
306352
qs = package.fixing_vulnerabilities.all()
@@ -321,6 +367,10 @@ def get_fixing_vulnerabilities(self, package) -> dict:
321367
"""
322368
Return a mapping of vulnerabilities fixed in the given `package`.
323369
"""
370+
# Ghost package should not fix any vulnerability.
371+
if package.is_ghost:
372+
return []
373+
324374
return self.get_vulnerabilities_for_a_package(package=package, fix=True)
325375

326376
def get_affected_vulnerabilities(self, package) -> dict:
@@ -595,7 +645,10 @@ def get_fixed_packages_qs(self):
595645
"""
596646
return (
597647
self.get_packages_qs()
598-
.filter(fixingpackagerelatedvulnerability__isnull=False)
648+
.filter(
649+
fixingpackagerelatedvulnerability__isnull=False,
650+
is_ghost=False,
651+
)
599652
.with_is_vulnerable()
600653
)
601654

@@ -621,6 +674,9 @@ def get_queryset(self):
621674
.get_queryset()
622675
.prefetch_related(
623676
"weaknesses",
677+
"references",
678+
"exploits",
679+
"severities",
624680
Prefetch(
625681
"fixed_by_packages",
626682
queryset=self.get_fixed_packages_qs(),

vulnerabilities/api_extension.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,10 @@ class Meta:
8484

8585
class V2VulnerabilitySeveritySerializer(ModelSerializer):
8686
score = CharField(source="value")
87-
reference = V2VulnerabilityReferenceSerializer()
8887

8988
class Meta:
9089
model = VulnerabilitySeverity
91-
fields = ("score", "scoring_system", "scoring_elements", "published_at", "reference")
90+
fields = ("url", "score", "scoring_system", "scoring_elements", "published_at")
9291

9392

9493
class V2WeaknessSerializer(ModelSerializer):
@@ -127,9 +126,9 @@ class V2VulnerabilitySerializer(ModelSerializer):
127126

128127
aliases = SerializerMethodField("get_aliases")
129128
weaknesses = V2WeaknessSerializer(many=True, source="weaknesses_set")
130-
scores = V2VulnerabilitySeveritySerializer(many=True, source="vulnerabilityseverity_set")
131129
references = V2VulnerabilityReferenceSerializer(many=True, source="vulnerabilityreference_set")
132130
exploits = V2ExploitSerializer(many=True, source="weaknesses")
131+
severities = V2VulnerabilitySeveritySerializer(many=True)
133132

134133
def get_aliases(self, vulnerability):
135134
return vulnerability.aliases.only("alias").values_list("alias", flat=True)
@@ -145,11 +144,11 @@ class Meta:
145144
"vulnerability_id",
146145
"aliases",
147146
"status",
148-
"scores",
149147
"weaknesses",
150148
"summary",
151149
"exploits",
152150
"references",
151+
"severities",
153152
)
154153

155154

@@ -358,7 +357,7 @@ def get_queryset(self):
358357
.get_queryset()
359358
.prefetch_related(
360359
"weaknesses",
361-
# "severities",
360+
"severities",
362361
# "exploits",
363362
)
364363
)

0 commit comments

Comments
 (0)