Skip to content

Commit 823c1e6

Browse files
committed
Drop OSVDB-derived OSV aliases from the rubygem data sources
The rubysec advisory data carries references to the defunct OSVDB database in its osvdb field, and both the ruby importer and the v2 ruby importer pipeline turned these into OSV-<number> aliases. These are not public aliases and the prefix collides with the modern OSV.dev namespace. Remove the code that imports them and add a data migration deleting the previously imported ones from both the Alias and AdvisoryAlias tables. Genuine OSV.dev identifiers (OSV-<year>-<number>, with two hyphens) are preserved by the migration regex. Closes #2421 Signed-off-by: Manoj Gowda <manojgowdabs18@gmail.com>
1 parent adc81cb commit 823c1e6

4 files changed

Lines changed: 44 additions & 7 deletions

File tree

vulnerabilities/importers/ruby.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,6 @@ def get_aliases(record) -> [str]:
145145
aliases = []
146146
if record.get("cve"):
147147
aliases.append("CVE-{}".format(record.get("cve")))
148-
if record.get("osvdb"):
149-
aliases.append("OSV-{}".format(record.get("osvdb")))
150148
if record.get("ghsa"):
151149
aliases.append("GHSA-{}".format(record.get("ghsa")))
152150
return aliases
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#
2+
# Copyright (c) nexB Inc. and others. All rights reserved.
3+
# VulnerableCode is a trademark of nexB Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
6+
# See https://github.com/aboutcode-org/vulnerablecode for support or download.
7+
# See https://aboutcode.org for more information about nexB OSS projects.
8+
#
9+
10+
from django.db import migrations
11+
12+
"""
13+
Remove the OSVDB-derived aliases imported from the rubygem data sources.
14+
15+
The rubysec advisory data contains legacy references to the defunct OSVDB
16+
database, and these were imported as "OSV-<number>" aliases. These are not
17+
public aliases and collide with the modern OSV.dev namespace. Genuine
18+
OSV.dev identifiers have the form "OSV-<year>-<number>" with two hyphens
19+
and are preserved.
20+
21+
See https://github.com/aboutcode-org/vulnerablecode/issues/2421
22+
"""
23+
24+
OSVDB_DERIVED_ALIAS_REGEX = r"^OSV-\d+$"
25+
26+
27+
def remove_osvdb_aliases(apps, schema_editor):
28+
Alias = apps.get_model("vulnerabilities", "Alias")
29+
Alias.objects.filter(alias__regex=OSVDB_DERIVED_ALIAS_REGEX).delete()
30+
31+
AdvisoryAlias = apps.get_model("vulnerabilities", "AdvisoryAlias")
32+
AdvisoryAlias.objects.filter(alias__regex=OSVDB_DERIVED_ALIAS_REGEX).delete()
33+
34+
35+
class Migration(migrations.Migration):
36+
dependencies = [
37+
("vulnerabilities", "0142_advisoryv2_is_curation_advisoryv2_resolves_todos"),
38+
]
39+
40+
operations = [
41+
migrations.RunPython(remove_osvdb_aliases, reverse_code=migrations.RunPython.noop),
42+
]

vulnerabilities/pipelines/v2_importers/ruby_importer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,6 @@ def get_aliases(record) -> [str]:
202202
aliases = []
203203
if record.get("cve"):
204204
aliases.append("CVE-{}".format(record.get("cve")))
205-
if record.get("osvdb"):
206-
aliases.append("OSV-{}".format(record.get("osvdb")))
207205
if record.get("ghsa"):
208206
aliases.append("GHSA-{}".format(record.get("ghsa")))
209207
return aliases

vulnerabilities/tests/test_data/ruby/CVE-2010-1330-expected.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"aliases": [
3-
"CVE-2010-1330",
4-
"OSV-77297"
3+
"CVE-2010-1330"
54
],
65
"summary": "CVE-2010-1330 jruby: XSS in the regular expression engine when processing invalid UTF-8 byte sequences\nThe regular expression engine in JRuby before 1.4.1, when $KCODE is set to 'u', does not properly handle characters immediately after a UTF-8 character, which allows remote attackers to conduct cross-site scripting (XSS) attacks via a crafted string.",
76
"affected_packages": [
@@ -29,4 +28,4 @@
2928
"date_published": "2010-04-26T00:00:00+00:00",
3029
"weaknesses": [],
3130
"url": "https://github.com/rubysec/ruby-advisory-db"
32-
}
31+
}

0 commit comments

Comments
 (0)