diff options
author | Carsten Schoenert <c.schoenert@t-online.de> | 2023-11-05 10:37:51 +0100 |
---|---|---|
committer | Thomas Lange <lange@debian.org> | 2023-12-02 16:47:03 +0100 |
commit | 042ba6220bcf9a91ce3877038ecf783dafa839fa (patch) | |
tree | c9e6c9f9e4f7aa22b117a413f26c537cb77c1b24 /english/security | |
parent | a215df58b97423573c8e055d5017f9010a154aa7 (diff) |
generate.py: Add new function collect_dsa_data()
Diffstat (limited to 'english/security')
-rwxr-xr-x | english/security/oval/generate.py | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/english/security/oval/generate.py b/english/security/oval/generate.py index e7d7c2a0fe9..fb04dc6237d 100755 --- a/english/security/oval/generate.py +++ b/english/security/oval/generate.py @@ -16,10 +16,10 @@ import logging import pprint import re import subprocess +from typing import Any import oval.definition.generator -from oval.parser import dsa -from oval.parser import wml +from oval.parser import dsa, tracker, wml # TODO: # - these may need changed or reworked. @@ -40,6 +40,8 @@ DEBIAN_VERSION = { "sid": "1000", } +DSA_DATA_FILE = "../data/dsa.data" + def printdsas(ovals): """Generate and print OVAL Definitions for collected DSA information""" @@ -156,6 +158,38 @@ def parsedirs(ovals, directory, regex, depth, debian_release): return ovals +def collect_dsa_data( + ovals: dict[str, Any], + debian_release: str, + dsa_data_file: str) -> None: + """ Collect DSA data and kick out XML data + + Extract and collect data from the tracker file of the Security team as a + dictionary and initate the creation of the XML data. + + Parameters: + ovals (dict): Dictionary containing packages with CVE data. + debian_release (str): The Debian release number e.g "12". + dsa_data_file (str): Reference to tracker data from the Security Team. + Returns: + None + """ + data = tracker.parse_tracker_data(dsa_data_file, DEBIAN_VERSION) + for key, value in data.items(): + dsaResult = value[0] + #print(f"\ndsaResult\n {dsaResult}") + + wmlResult = value[1], value[2] + #print(f"\nwmlResult\n {wmlResult}") + + dsaRef = key + #print(f"\ndsaRef\n {dsaRef}") + if dsaResult and wmlResult: + ovals = add_dsa_info( + ovals, dsaResult, wmlResult, dsaRef, debian_release + ) + + def parseJSON(ovals, json_data, debian_release): """ Parse the JSON data and extract information needed for OVAL definitions @@ -269,7 +303,8 @@ def main(args): ovals = {} ovals = parseJSON(ovals, json_data, release) logging.info("Finished parsing JSON data") - ovals = parsedirs(ovals, data_dir, re.compile("^d[ls]a.+\.data$"), 2, release) + #ovals = parsedirs(ovals, data_dir, re.compile("^d[ls]a.+\.data$"), 2, release) + collect_dsa_data(ovals, release, DSA_DATA_FILE) printdsas(ovals) |