File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2323
2424import json
2525from urllib .request import urlopen
26-
26+ from schema import Regex , Schema , Or
2727ARCHLINUX_TRACKER_URL = 'https://security.archlinux.org/json'
2828
2929
30+ def validate_schema (advisory_dict ):
31+ scheme = {
32+
33+ 'advisories' : list ,
34+ 'affected' : str ,
35+ 'fixed' : Or (None , str ),
36+ 'issues' : [Regex (r'CVE-\d+-\d+' )],
37+ 'name' : str ,
38+ 'packages' : [str ],
39+ 'status' : str ,
40+ 'ticket' : object ,
41+ 'type' : str ,
42+ 'severity' : str ,
43+
44+ }
45+
46+ Schema (scheme ).validate (advisory_dict )
47+
48+
3049def scrape_vulnerabilities ():
3150 """
3251 Fetch and return data scraped from archlinux security tracker.
3352 """
3453 json_content = urlopen (ARCHLINUX_TRACKER_URL ).read ()
3554 arch_data = json .loads (json_content )
55+ for advisory in arch_data :
56+ validate_schema (advisory )
57+
3658 return arch_data
You can’t perform that action at this time.
0 commit comments