def insert_vulnerabilites_into_report()

in src/safety_report_generator.py [0:0]


    def insert_vulnerabilites_into_report(self, scanned_vulnerabilities):
        """
        Takes the list of vulnerabilites produced by safety scan as the input and iterates through the list to insert
        the vulnerabilites into the vulnerability_dict.

        :param scanned_vulnerabilities: list[list], consists of a list of Vulnerabilities. Each vulnerability is a list itself.
        """
        for vulnerability in scanned_vulnerabilities["vulnerabilities"]:
            package = vulnerability["package_name"]
            vulnerability_id = vulnerability["vulnerability_id"]
            spec = vulnerability["vulnerable_spec"]
            installed = vulnerability["analyzed_version"]
            advisory = vulnerability["advisory"]
            vulnerability_details = {
                "vulnerability_id": vulnerability_id,
                "advisory": advisory,
                "spec": spec,
                "reason_to_ignore": "N/A",
                "ignored": False,
            }

            if package not in self.ignored_vulnerability_count:
                self.ignored_vulnerability_count[package] = 0

            if vulnerability_id in self.ignore_dict:
                vulnerability_details["reason_to_ignore"] = self.ignore_dict[vulnerability_id]
                vulnerability_details["ignored"] = True
                self.ignored_vulnerability_count[package] += 1

            if package not in self.vulnerability_dict:
                self.vulnerability_dict[package] = {
                    "package": package,
                    "scan_status": "TBD",
                    "installed": installed,
                    "vulnerabilities": [vulnerability_details],
                    "date": self.timestamp,
                }
            else:
                self.vulnerability_dict[package]["vulnerabilities"].append(vulnerability_details)