@@ -51,14 +51,14 @@ def ghsa_summary_to_dict(summary):
5151 }
5252
5353class GHSABackend :
54- def __init__ (self , memcache_state_dir : str ):
55- self . memcache_state_dir = memcache_state_dir
56- self .location_pattern = r"^([a-zA-Z]+)(:\d+){4}$"
57- if not Path (self .memcache_state_dir ).exists ():
58- db_dir = "sqlite://"
54+ def __init__ (self , db_dir : str ):
55+ # Directory in which the GHSA SQLite database file will be stored.
56+ self .db_dir = db_dir
57+ if not Path (self .db_dir ).exists ():
58+ db_uri = "sqlite://"
5959 else :
60- db_dir = f"sqlite:///{ self .memcache_state_dir } /ghsa.db"
61- self .engine = create_engine (db_dir , echo = False )
60+ db_uri = f"sqlite:///{ self .db_dir } /ghsa.db"
61+ self .engine = create_engine (db_uri , echo = False )
6262 Base .metadata .create_all (
6363 self .engine ,
6464 tables = [
@@ -162,13 +162,13 @@ def clear_repo(self, repo):
162162def parse_advisory (advisory : dict ) -> dict :
163163 logging .debug (f"advisory: { advisory } " )
164164 return {
165- "ghsa_id" : advisory .get ("ghsa_id" , "" ) ,
166- "cve_id" : advisory .get ("cve_id" , "" ) ,
167- "summary" : advisory .get ("summary" , "" ) ,
168- "description" : advisory .get ("description" , "" ) ,
169- "severity" : advisory .get ("severity" , "" ) ,
170- "published_at" : advisory .get ("published_at" , "" ) ,
171- "state" : advisory .get ("state" , "" ) ,
165+ "ghsa_id" : advisory .get ("ghsa_id" ) or "" ,
166+ "cve_id" : advisory .get ("cve_id" ) or "" ,
167+ "summary" : advisory .get ("summary" ) or "" ,
168+ "description" : advisory .get ("description" ) or "" ,
169+ "severity" : advisory .get ("severity" ) or "" ,
170+ "published_at" : advisory .get ("published_at" ) or "" ,
171+ "state" : advisory .get ("state" ) or "" ,
172172 }
173173
174174
0 commit comments