Skip to content

Commit 56a5a6c

Browse files
committed
Collected vulnerabilities from arch linux
Signed-off-by: Ayush Lohani <lohani.ayush01@gmail.com>
1 parent 55a633d commit 56a5a6c

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

vulnerabilities/data_dump.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,25 @@ def ubuntu_dump(html):
6868
vulnerability=vulnerability,
6969
package=package
7070
)
71+
72+
73+
def archlinux_dump(extract_data):
74+
"""
75+
Save data scraped from arch linux' security tracker.
76+
"""
77+
for data in extract_data:
78+
vulnerability = Vulnerability.objects.create(
79+
summary='',
80+
)
81+
VulnerabilityReference.objects.create(
82+
vulnerability=vulnerability,
83+
reference_id=data.get('vulnerability_id', ''),
84+
)
85+
package = Package.objects.create(
86+
name=data.get('package_name', ''),
87+
version=data.get('fixed_version', ''),
88+
)
89+
ImpactedPackage.objects.create(
90+
vulnerability=vulnerability,
91+
package=package
92+
)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#
2+
# Copyright (c) 2017 nexB Inc. and others. All rights reserved.
3+
# http://nexb.com and https://github.com/nexB/vulnerablecode/
4+
# The VulnerableCode software is licensed under the Apache License version 2.0.
5+
# Data generated with VulnerableCode require an acknowledgment.
6+
#
7+
# You may not use this software except in compliance with the License.
8+
# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0
9+
# Unless required by applicable law or agreed to in writing, software distributed
10+
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11+
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
# specific language governing permissions and limitations under the License.
13+
#
14+
# When you publish or redistribute any data created with VulnerableCode or any VulnerableCode
15+
# derivative work, you must accompany this data with the following acknowledgment:
16+
#
17+
# Generated with VulnerableCode and provided on an "AS IS" BASIS, WITHOUT WARRANTIES
18+
# OR CONDITIONS OF ANY KIND, either express or implied. No content created from
19+
# VulnerableCode should be considered or used as legal advice. Consult an Attorney
20+
# for any legal advice.
21+
# VulnerableCode is a free software code scanning tool from nexB Inc. and others.
22+
# Visit https://github.com/nexB/vulnerablecode/ for support and download.
23+
24+
import json
25+
from urllib.request import urlopen
26+
27+
28+
ARCHLINUX_TRACKER_URL = 'https://security.archlinux.org/json'
29+
30+
31+
def extract_vulnerabilities(arch_data):
32+
"""
33+
Return a sequence of mappings for each existing combination of
34+
package and vulnerability from a mapping of arch linux vulnerabilities
35+
data.
36+
"""
37+
package_vulnerabilities = []
38+
39+
for item in arch_data:
40+
if not item["name"] or not item["packages"][0]:
41+
continue
42+
43+
package_vulnerabilities.append({
44+
'package_name': item["packages"][0],
45+
'vulnerability_id': item["name"],
46+
'status': item["status"],
47+
'severity': item["severity"],
48+
'affected_version': item["affected"],
49+
'fixed_version': item["fixed"]
50+
})
51+
return package_vulnerabilities
52+
53+
54+
def scrape_vulnerabilities():
55+
"""
56+
Scrape arch linux' security tracker.
57+
"""
58+
json_content = urlopen(ARCHLINUX_TRACKER_URL).read()
59+
return extract_vulnerabilities(json.loads(json_content))

0 commit comments

Comments
 (0)