mirror of
https://github.com/resf/distro-tools.git
synced 2024-11-21 20:51:27 +00:00
added new URLs for oval data. (#19)
This commit is contained in:
parent
91bdc7ce41
commit
02e062f0d0
@ -42,17 +42,19 @@ async def get_last_indexed_date() -> Optional[str]:
|
||||
|
||||
async def fetch_mapped_oval() -> dict[str, ET.ElementTree]:
|
||||
# Download the oval_url using aiohttp, decompress using bzip and parse
|
||||
oval_url = (
|
||||
"https://access.redhat.com/security/data/oval/com.redhat.rhsa-all.xml.bz2"
|
||||
oval_urls = (
|
||||
'https://access.redhat.com/security/data/oval/v2/RHEL8/rhel-8.oval.xml.bz2',
|
||||
'https://access.redhat.com/security/data/oval/v2/RHEL9/rhel-9.oval.xml.bz2',
|
||||
)
|
||||
def_map = {}
|
||||
for url in oval_urls:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(oval_url) as response:
|
||||
async with session.get(url) as response:
|
||||
if response.status == 200:
|
||||
data = await response.read()
|
||||
tree = ET.fromstring(bz2.decompress(data))
|
||||
|
||||
# Index by advisory name
|
||||
def_map = {}
|
||||
definitions = tree.findall("definitions/definition", OVAL_NS)
|
||||
for definition in definitions:
|
||||
def_id = definition.attrib["id"]
|
||||
@ -60,10 +62,10 @@ async def fetch_mapped_oval() -> dict[str, ET.ElementTree]:
|
||||
name = f"{id_split[1].split('.')[2].upper()}-{id_split[3][0:4]}:{id_split[3][4:]}"
|
||||
def_map[name] = definition
|
||||
|
||||
return def_map
|
||||
else:
|
||||
raise Exception("Failed to fetch OVAL data")
|
||||
|
||||
return def_map
|
||||
|
||||
@activity.defn
|
||||
async def get_rh_advisories(from_timestamp: str = None) -> None:
|
||||
|
Loading…
Reference in New Issue
Block a user