Skip to content

Commit 8678d54

Browse files
committed
Resolve merge conflicts
Add advisory_url to ruby importer Signed-off-by: ziadhany <ziadhany2016@gmail.com>
1 parent 97d1266 commit 8678d54

6 files changed

Lines changed: 21 additions & 7 deletions

File tree

vulnerabilities/importers/ruby.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from vulnerabilities.importer import VulnerabilitySeverity
2424
from vulnerabilities.severity_systems import SCORING_SYSTEMS
2525
from vulnerabilities.utils import build_description
26+
from vulnerabilities.utils import get_advisory_url
2627
from vulnerabilities.utils import load_yaml
2728

2829
logger = logging.getLogger(__name__)
@@ -60,13 +61,18 @@ def advisory_data(self) -> Iterable[AdvisoryData]:
6061
if file_path.name.startswith("OSVDB-"):
6162
continue
6263
raw_data = load_yaml(file_path)
63-
yield parse_ruby_advisory(raw_data, subdir)
64+
advisory_url = get_advisory_url(
65+
file=file_path,
66+
base_path=base_path,
67+
url="https://github.com/rubysec/ruby-advisory-db/blob/master/",
68+
)
69+
yield parse_ruby_advisory(raw_data, subdir, advisory_url)
6470
finally:
6571
if self.vcs_response:
6672
self.vcs_response.delete()
6773

6874

69-
def parse_ruby_advisory(record, schema_type):
75+
def parse_ruby_advisory(record, schema_type, advisory_url):
7076
"""
7177
Parse a ruby advisory file and return an AdvisoryData or None.
7278
Each advisory file contains the advisory information in YAML format.
@@ -86,6 +92,7 @@ def parse_ruby_advisory(record, schema_type):
8692
affected_packages=get_affected_packages(record, purl),
8793
references=get_references(record),
8894
date_published=get_publish_time(record),
95+
url=advisory_url,
8996
)
9097

9198
elif schema_type == "rubies":
@@ -100,6 +107,7 @@ def parse_ruby_advisory(record, schema_type):
100107
affected_packages=get_affected_packages(record, purl),
101108
references=get_references(record),
102109
date_published=get_publish_time(record),
110+
url=advisory_url,
103111
)
104112

105113

vulnerabilities/tests/test_data/ruby/CVE-2007-5770-expected.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@
4343
}
4444
],
4545
"date_published": "2007-10-08T00:00:00+00:00",
46-
"weaknesses": []
46+
"weaknesses": [],
47+
"url": "https://github.com/rubysec/ruby-advisory-db"
4748
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@
3232
}
3333
],
3434
"date_published": "2010-04-26T00:00:00+00:00",
35-
"weaknesses": []
35+
"weaknesses": [],
36+
"url": "https://github.com/rubysec/ruby-advisory-db"
3637
}

vulnerabilities/tests/test_data/ruby/CVE-2018-11627-expected.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@
3131
}
3232
],
3333
"date_published": "2018-05-31T00:00:00+00:00",
34-
"weaknesses": []
34+
"weaknesses": [],
35+
"url": "https://github.com/rubysec/ruby-advisory-db"
3536
}

vulnerabilities/tests/test_data/ruby/CVE-2018-7212-expected.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,6 @@
5454
}
5555
],
5656
"date_published": "2018-01-09T00:00:00+00:00",
57-
"weaknesses": []
57+
"weaknesses": [],
58+
"url": "https://github.com/rubysec/ruby-advisory-db"
5859
}

vulnerabilities/tests/test_ruby.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
def test_advisories(filename, expected_filename, schema_type):
4141
file_path = os.path.join(TEST_DATA, filename)
4242
mock_response = load_yaml(file_path)
43-
results = parse_ruby_advisory(mock_response, schema_type).to_dict()
43+
results = parse_ruby_advisory(
44+
mock_response, schema_type, "https://github.com/rubysec/ruby-advisory-db"
45+
).to_dict()
4446
expected_file = os.path.join(TEST_DATA, expected_filename)
4547
check_results_against_json(results=results, expected_file=expected_file)
4648

0 commit comments

Comments
 (0)