@@ -68,7 +68,8 @@ def advisory_data(self):
6868 """
6969 advisories = []
7070
71- for advisory_page in self .fetch_advisory_pages (self .security_updates_home ):
71+ # for advisory_page in self.fetch_advisory_pages(self.security_updates_home):
72+ for advisory_page in self .fetch_advisory_pages ():
7273 advisories .extend (self .extract_advisories_from_page (advisory_page ))
7374
7475 if TRACE :
@@ -179,83 +180,6 @@ def extract_advisories_from_page(self, apache_tomcat_advisory_html):
179180
180181 return advisories
181182
182- # XXX: 2023-01-02 Monday 14:48:57. We need to convert this from class method to
183- # independent function because it's now called by another independent function and thus has no `self`.
184- # def to_version_ranges(self, versions_data, fixed_versions):
185- # constraints = []
186-
187- # for version_item in versions_data:
188- # if "to" in version_item:
189- # version_item_split = version_item.split(" ")
190-
191- # constraints.append(
192- # VersionConstraint(
193- # comparator=">=",
194- # version=MavenVersion(version_item_split[0]),
195- # )
196- # )
197- # constraints.append(
198- # VersionConstraint(
199- # comparator="<=",
200- # version=MavenVersion(version_item_split[-1]),
201- # )
202- # )
203-
204- # elif "-" in version_item:
205- # version_item_split = version_item.split("-")
206-
207- # constraints.append(
208- # VersionConstraint(
209- # comparator=">=",
210- # version=MavenVersion(version_item_split[0]),
211- # )
212- # )
213- # constraints.append(
214- # VersionConstraint(
215- # comparator="<=",
216- # version=MavenVersion(version_item_split[-1]),
217- # )
218- # )
219-
220- # else:
221- # version_item_split = version_item.split(" ")
222-
223- # constraints.append(
224- # VersionConstraint(
225- # comparator="=",
226- # version=MavenVersion(version_item_split[0]),
227- # )
228- # )
229-
230- # for fixed_item in fixed_versions:
231- # if "-" in fixed_item and not any([i.isalpha() for i in fixed_item]):
232- # fixed_item_split = fixed_item.split(" ")
233-
234- # constraints.append(
235- # VersionConstraint(
236- # comparator=">=",
237- # version=MavenVersion(fixed_item_split[0]),
238- # ).invert()
239- # )
240- # constraints.append(
241- # VersionConstraint(
242- # comparator="<=",
243- # version=MavenVersion(fixed_item_split[-1]),
244- # ).invert()
245- # )
246-
247- # else:
248- # fixed_item_split = fixed_item.split(" ")
249-
250- # constraints.append(
251- # VersionConstraint(
252- # comparator="=",
253- # version=MavenVersion(fixed_item_split[0]),
254- # ).invert()
255- # )
256-
257- # return MavenVersionRange(constraints=constraints)
258-
259183
260184@dataclasses .dataclass (order = True )
261185class TomcatAdvisoryData :
@@ -563,224 +487,3 @@ def to_version_ranges(versions_data, fixed_versions):
563487 )
564488
565489 return MavenVersionRange (constraints = constraints )
566-
567- # =====================================================
568-
569- # for para in para_list:
570- # print("type(para) = {}".format(type(para)))
571- # cve_p = para.find(
572- # "strong",
573- # # text=lambda text: text and text.startswith(tuple(vuln_p_list)),
574- # text=lambda text: text and text.startswith(severities),
575- # )
576- # # 2022-12-31 Saturday 20:16:51. Seems this is False for the missing pair of CVEs?
577- # if cve_p:
578- # cve_p_parent = cve_p.find_parent()
579- # print("\ncve_p = {}\n".format(cve_p))
580- # print("\ncve_p_parent = {}\n".format(cve_p_parent))
581-
582- # # TODO: 2022-12-31 Saturday 18:58:00. Why does this omit the 1st pair, CVE-2020-9484 and CVE-2021-25329?
583- # # Seems cve_p_parent (just above) is also omitted for that data?
584- # cve_url_list = cve_p_parent.find_all("a")
585- # print("cve_url_list = {}\n".format(cve_url_list))
586-
587- # cve_id_list = [cve_text.text for cve_text in cve_url_list]
588- # print("cve_id_list = {}\n".format(cve_id_list))
589-
590- # for cve_id in cve_id_list:
591-
592- # test_dict = {
593- # "aliases": [cve_id],
594- # "fixed_version": fixed_version,
595- # "affected_versions": [],
596- # }
597-
598- # yield test_dict
599-
600- # else:
601- # print("\n\nALERT! This para failed the `if_cve_p` test: {} \n\n".format(para))
602-
603-
604- # ========================================================
605- # severity_score = para.text.split(" ")[0]
606- # severity_score = severity_score.split(":")[0]
607- # print("\nseverity_score = {}\n".format(severity_score))
608-
609- # print("===")
610-
611- # better_cve_url_list = para.find_all("a")
612- # print("better_cve_url_list = {}\n".format(better_cve_url_list))
613-
614- # better_cve_id_list = [cve_text.text for cve_text in better_cve_url_list]
615- # print("better_cve_id_list = {}\n".format(better_cve_id_list))
616-
617- # for better_cve_url in para.find_all("a"):
618- # print("better_cve_url = {}\n".format(better_cve_url))
619- # print("better_cve_url.text = {}".format(better_cve_url.text))
620-
621- # better_nextSiblings = para.find_next_siblings()
622-
623- # print("===")
624-
625- # section_parent = para.find_parent()
626-
627- # cve_url_list = section_parent.find_all("a")
628- # print("cve_url_list = {}\n".format(cve_url_list))
629-
630- # cve_id_list = [cve_text.text for cve_text in cve_url_list]
631- # print("cve_id_list = {}\n".format(cve_id_list))
632-
633- # for cve_url in section_parent.find_all("a"):
634- # print("cve_url = {}\n".format(cve_url))
635- # print("cve_url.text = {}".format(cve_url.text))
636-
637- # nextSiblings = section_parent.find_next_siblings()
638-
639- # print("===")
640-
641- # fixed_commit_list = []
642- # affected_versions = []
643-
644- # for sib in better_nextSiblings:
645- # if "was fixed in" in sib.text or "was fixed with" in sib.text:
646- # print("\nnext sib (was fixed) = {}".format(sib))
647- # fixed_commit_list = sib.find_all("a")
648- # print("\nfixed_commit_list = {}".format(fixed_commit_list))
649-
650- # elif "Affects" in sib.text:
651- # print("\nnext sib (affects) = {}\n".format(sib))
652-
653- # # 2022-12-27 Tuesday 18:47:28. We need the list of `sib` elements to examine -- and test -- the raw HTML.
654- # self.record_of_all_affects_elements.append(sib)
655-
656- # # 2022-12-27 Tuesday 14:47:51. We'll examine the affects_string and try to find and remove unwanted alpha and related characters/strings.
657- # # ===
658- # # This version is before stripping/replacing etc.
659- # affects_string = sib.text.split("Affects:")[-1].strip()
660- # print("affects_string = {}\n".format(affects_string))
661- # self.record_of_all_affects_strings.append(affects_string)
662-
663- # affected_versions = affects_string.split(", ")
664- # print("> affected_versions = {}\n".format(affected_versions))
665- # self.record_of_all_affected_version_strings.append(affected_versions)
666- # # ===
667- # # This version is with most but not all of the stripping/replacing.
668- # # affects_string = sib.text.split("Affects:")[-1].strip()
669- # # affects_string = affects_string.replace("\n", "")
670- # # affects_string = " ".join(affects_string.split())
671- # # affects_string_no_parens = re.sub(r" ?\([^)]+\)", "", affects_string)
672- # # # print("affects_string = {}\n".format(affects_string))
673- # # # self.record_of_all_affects_strings.append(affects_string)
674- # # print(
675- # # "affects_string_no_parens = {}\n".format(affects_string_no_parens)
676- # # )
677- # # self.record_of_all_affects_strings.append(affects_string_no_parens)
678-
679- # # # affected_versions = affects_string.split(", ")
680- # # affected_versions = affects_string_no_parens.split(", ")
681- # # print("> affected_versions = {}\n".format(affected_versions))
682- # # self.record_of_all_affected_version_strings.append(affected_versions)
683- # # ===
684-
685- # elif sib.find_all(
686- # "strong",
687- # text=lambda text: text and text.startswith(tuple(severities)),
688- # ):
689- # break
690-
691- # # Starting to flesh out this new approach.
692- # # for cve_id_record in cve_id_list:
693- # # test_advisory_dict["fixed_versions"] = fixed_versions
694- # # test_advisory_dict["aliases"] = [cve_id_record]
695-
696- # temp_dict_list = []
697-
698- # print("\n1. affected_versions = {}\n".format(affected_versions))
699-
700- # for better_cve_id_record in better_cve_id_list:
701- # # 2022-12-26 Monday 14:41:11. This is where `test_advisory_dict = {}` belongs! Now we have data for the double-CVEs!
702- # test_advisory_dict = {}
703- # test_advisory_dict["fixed_versions"] = fixed_versions
704- # test_advisory_dict["aliases"] = [better_cve_id_record]
705-
706- # self.updated_temp_advisory_dict_list.append(test_advisory_dict)
707-
708- # print(
709- # "==========================> better_cve_id_record = {}".format(
710- # better_cve_id_record
711- # )
712- # )
713-
714- # temp_dict_list.append(test_advisory_dict)
715-
716- # # TODO: 2022-12-26 Monday 14:55:49. Is this where we build the "better" AdvisoryData() objects?
717- # better_severities = []
718- # better_severities.append(
719- # VulnerabilitySeverity(
720- # system=APACHE_TOMCAT,
721- # value=severity_score,
722- # scoring_elements="",
723- # )
724- # )
725-
726- # print("\n2. affected_versions = {}\n".format(affected_versions))
727-
728- # affected_version_range = self.to_version_ranges(
729- # # versions_data, fixed_versions
730- # affected_versions,
731- # # TODO: 2022-12-26 Monday 16:01:08. fix this!
732- # # ["1.1"],
733- # # ["8.5.0 to 8.5.4", " 8.0.0.RC1 to 8.0.36"],
734- # # ["3.0", " 3.1-3.1.1", " 3.2-3.2.1"],
735- # # TODO: 2022-12-26 Monday 17:56:04. This identified the problem -- a space at the start of the 2nd range!
736- # # ["8.5.0 to 8.5.4", "8.0.0.RC1 to 8.0.36"],
737- # fixed_versions,
738- # )
739- # references = [
740- # Reference(
741- # # url=f"https://cve.mitre.org/cgi-bin/cvename.cgi?name={cve_id}",
742- # url=f"https://cve.mitre.org/cgi-bin/cvename.cgi?name={better_cve_id_record}",
743- # # reference_id=cve_id,
744- # reference_id=better_cve_id_record,
745- # # severities=severities,
746- # severities=better_severities,
747- # ),
748- # ]
749-
750- # # for commit_url in fixed_in_commits:
751- # for commit_url in fixed_commit_list:
752- # # references.append(Reference(url=commit_url))
753- # # TODO: 2022-12-26 Monday 17:23:38. Does this fix the error TypeError: Object of type Tag is not JSON serializable? Yes.
754- # references.append(Reference(url=commit_url["href"]))
755-
756- # # 2022-12-26 Monday 15:37:02. Does this belong here?
757- # affected_packages = []
758-
759- # affected_packages.append(
760- # AffectedPackage(
761- # package=PackageURL(
762- # type="maven",
763- # namespace="apache",
764- # name="tomcat",
765- # ),
766- # affected_version_range=affected_version_range,
767- # )
768- # )
769-
770- # advisories.append(
771- # AdvisoryData(
772- # aliases=[better_cve_id_record],
773- # summary="",
774- # affected_packages=affected_packages,
775- # references=references,
776- # )
777- # )
778-
779- # self.temp_list_of_fixed_versions.append(fixed_versions)
780-
781- # yield AdvisoryData(
782- # aliases=aliases,
783- # summary="",
784- # affected_packages=affected_packages,
785- # references=references,
786- # )
0 commit comments