@@ -30,6 +30,51 @@ def prepare_link(link):
3030 #print("Replaced " + link)
3131 return link
3232
33+ def get_version (desc , link ):
34+ if ("msm-3.4" in link ) or ("3.4" in desc ):
35+ return "3.4"
36+ elif ("msm-3.10" in link ) or ("3.10" in desc ):
37+ return "3.10"
38+ elif ("msm-3.18" in link ) or ("3.18" in desc ):
39+ return "3.18"
40+ elif ("msm-4.4" in link ) or ("4.4" in desc ):
41+ return "4.4"
42+ elif ("msm-4.9" in link ) or ("4.9" in desc ):
43+ return "4.9"
44+ elif ("msm-" in link ) or ("2." in desc ) or ("3." in desc ) or ("4." in desc ):
45+ return "other"
46+ else :
47+ return "None"
48+
49+ def skip_link (link ):
50+ # skip all vendor stuff
51+ if "vendor" in link :
52+ return True
53+
54+ # skip lineage coz IDK how to parse it
55+ if "lineageos" in link :
56+ return True
57+
58+ if "cve.mitre.org" in link :
59+ return True
60+
61+ if "www.codeaurora.org" in link :
62+ return True
63+
64+ if "chromium" in link :
65+ return True
66+
67+ if "bulletin" in link :
68+ return True
69+
70+ if "alephsecurity.com" in link :
71+ return True
72+
73+ if ("codeaurora.org" in link ) and ("/log/?" in link ):
74+ return True
75+
76+ return False
77+
3378
3479def load_tracker_cves ():
3580
@@ -49,46 +94,24 @@ def load_tracker_cves():
4994 version = curr_link ["desc" ]
5095 patch_link = curr_link ["link" ]
5196
52- # skip all vendor stuff
53- if "vendor" in patch_link :
97+ if (skip_link (patch_link )):
5498 continue
5599
56- # skip lineage coz IDK how to parse it
57- if "lineageos" in patch_link :
58- continue
59-
60- if "cve.mitre.org" in patch_link :
61- continue
100+ kernel_version = get_version (version , patch_link )
62101
63- if "www.codeaurora.org" in patch_link :
64- continue
65-
66- if "chromium" in patch_link :
102+ if (kernel_version == "other" ):
67103 continue
68104
69- if (version == "3.4" ) or (version == "3.10" ) or (version == "3.18" ) or (version == "4.4" ) or (version == "4.9" ):
70- cve_object .patchfiles [version ] = prepare_link (patch_link )
71- # handle all patches without desc or with dummy desc
72- elif (version .lower () == "patch" ) or (version == "" ):
73- if "msm-3.4" in patch_link :
74- cve_object .patchfiles ["3.4" ] = prepare_link (patch_link )
75- elif "msm-3.10" in patch_link :
76- cve_object .patchfiles ["3.10" ] = prepare_link (patch_link )
77- elif "msm-3.18" in patch_link :
78- cve_object .patchfiles ["3.18" ] = prepare_link (patch_link )
79- elif "msm-4.4" in patch_link :
80- cve_object .patchfiles ["4.4" ] = prepare_link (patch_link )
81- elif "msm-4.9" in patch_link :
82- cve_object .patchfiles ["4.9" ] = prepare_link (patch_link )
83- elif "msm-" in patch_link :
84- # skip other versions
85- continue
86- else :
87- cve_object .patchfiles ["3.4" ] = prepare_link (patch_link )
88- cve_object .patchfiles ["3.10" ] = prepare_link (patch_link )
89- cve_object .patchfiles ["3.18" ] = prepare_link (patch_link )
90- cve_object .patchfiles ["4.4" ] = prepare_link (patch_link )
91- cve_object .patchfiles ["4.9" ] = prepare_link (patch_link )
105+ prepared_link = prepare_link (patch_link )
106+
107+ if (kernel_version == "None" ):
108+ cve_object .patchfiles ["3.4" ] = prepared_link
109+ cve_object .patchfiles ["3.10" ] = prepared_link
110+ cve_object .patchfiles ["3.18" ] = prepared_link
111+ cve_object .patchfiles ["4.4" ] = prepared_link
112+ cve_object .patchfiles ["4.9" ] = prepared_link
113+ else :
114+ cve_object .patchfiles [kernel_version ] = prepared_link
92115
93116 # collect all our CveWrapper instances
94117 cves [name ] = cve_object
@@ -151,23 +174,13 @@ def run(patches_dir, replace_local_files=False):
151174 if os .path .exists (target_path ):
152175 if not replace_local_files :
153176 print ("[I] " + target_path + " already exists!" )
154- answer = ""
155- while answer == "" :
156- answer = input ("options: (r)emove local file" +
157- " and sync from server\n " +
158- " (s)kip\n " +
159- "answer: " )
160- if answer == "r" :
161- # remove the local file
162- os .remove (target_path )
163- elif answer == "s" :
164- continue
177+ continue
165178 else :
166179 # remove the local file
167180 os .remove (target_path )
168181
169182 # download the patch
170- print ("[I] Downloading " + os .path .basename (target_path ) + " from " + remote_patchfile )
183+ print ("[I] Downloading " + os .path .basename (target_path ) + " from " + remote_patchfile , end = '' )
171184 try :
172185 urllib .request .urlretrieve (remote_patchfile , target_path )
173186 print (" * Saved!" )
0 commit comments