Skip to content

Commit baa44ae

Browse files
committed
Update Gentoo importer to treat revision versions as a regular version.
Signed-off-by: ziad hany <ziadhany2016@gmail.com>
1 parent d30d9f3 commit baa44ae

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

vulnerabilities/pipelines/v2_importers/gentoo_importer.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def process_file(self, file):
8484
for purl, constraints, is_unaffected in get_affected_and_fixed_purls(
8585
child, logger=self.log
8686
):
87-
constraints = build_constraints(constraints, logger=self.log)
87+
constraints = build_constraints([constraints], logger=self.log)
8888
version_range = EbuildVersionRange(constraints=constraints)
8989

9090
if is_unaffected:
@@ -164,6 +164,7 @@ def get_affected_and_fixed_purls(affected_elem, logger):
164164
# All possible values of info.attrib['range'] =
165165
# {'gt', 'lt', 'rle', 'rge', 'rgt', 'le', 'ge', 'eq'}
166166
# rge means revision greater than equals and rgt means revision greater than
167+
# TODO Revisit issue:
167168
range_value = info.attrib.get("range")
168169
slot_value = info.attrib.get("slot")
169170
comparator_dict = {
@@ -183,13 +184,4 @@ def get_affected_and_fixed_purls(affected_elem, logger):
183184

184185
qualifiers = {"slot": slot_value} if slot_value else {}
185186
purl = PackageURL(type="ebuild", name=pkg_name, namespace=pkg_ns, qualifiers=qualifiers)
186-
187-
constraints = [(comparator, info.text)]
188-
if range_value in ["rgt", "rge", "rle"]:
189-
try:
190-
next_minor_version = str(GentooVersion(info.text).bump())
191-
invert_comp = "<" if range_value in ["rgt", "rge"] else ">"
192-
constraints.append((invert_comp, next_minor_version))
193-
except Exception as e:
194-
logger(f"Invalid Gentoo version for bumping: {info.text} - {e}")
195-
yield purl, constraints, (info.tag == "unaffected")
187+
yield purl, (comparator, info.text), (info.tag == "unaffected")

vulnerabilities/tests/test_data/gentoo_v2/glsa-201709-09-expected.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"subpath": ""
4545
},
4646
"affected_version_range": null,
47-
"fixed_version_range": "vers:ebuild/>1.8.18|<1.9",
47+
"fixed_version_range": "vers:ebuild/>1.8.18",
4848
"introduced_by_commit_patches": [],
4949
"fixed_by_commit_patches": []
5050
},

0 commit comments

Comments
 (0)